diff options
-rw-r--r-- | cc.deb.PKGBUILD | 30 | ||||
-rw-r--r-- | monitor.PKGBUILD | 9 | ||||
-rw-r--r-- | monitor.cc.deb.PKGBUILD | 77 |
3 files changed, 114 insertions, 2 deletions
diff --git a/cc.deb.PKGBUILD b/cc.deb.PKGBUILD index 5e32a3cb1586..8344d23016e2 100644 --- a/cc.deb.PKGBUILD +++ b/cc.deb.PKGBUILD @@ -90,6 +90,7 @@ _package _msg2 'installing control file and install scripts' install -Dm755 "${srcdir}/${_pkgarch}.control" "${_pkgdir}/DEBIAN/control" +#_debscripts #install -Dm755 ${srcdir}/${_scripts}/preinst.sh ${_pkgdir}/DEBIAN/preinst install -Dm755 "${srcdir}/postinst.sh" "${_pkgdir}/DEBIAN/postinst" install -Dm755 "${srcdir}/prerm.sh" "${_pkgdir}/DEBIAN/prerm" @@ -104,3 +105,32 @@ done #exit so the arch package doesn't get built exit } + +_descripts() { + func=$1 + input_file=$2 + # Check if the function is defined in the .install file + if grep -q "^$func()" "${install}"; then + # Create the script + case "$func" in + pre_install) _script="preinst";; + post_install) _script="postinst";; + pre_upgrade) _script="preinst";; + post_upgrade) _script="postinst";; + pre_remove) _script="prerm";; + post_remove) _script="postrm";; + backup) _script="preinst";; + restore) _script="postinst";; + clean) _script="postrm";; + check) _script="preinst";; + fix_install) _script="postinst";; + fix_upgrade) _script="postinst";; + *) echo "Unknown function: $func"; continue;; + esac + _debscript="${_script}.sh" + echo "#!/bin/sh" > "${_pkgdir}/DEBIAN/${_debscript}" + echo "$(grep -A999 "^$func()" "${_pkgdir}/DEBIAN/${_debscript}" | sed '/^}$/Q')" >> "${_pkgdir}/DEBIAN/${_debscript}" + chmod +x "${_pkgdir}/DEBIAN/${_debscript}" + _msg3 "Created ${_debscript}" + fi +} diff --git a/monitor.PKGBUILD b/monitor.PKGBUILD index 82e7ef339bb0..55b52e81d443 100644 --- a/monitor.PKGBUILD +++ b/monitor.PKGBUILD @@ -20,9 +20,14 @@ sha256sums=('72c189a1c1994e90cab0ab3e21a3bf2932b229210a0bc9e296d6a4400e2a52a1' 'f26f0d3aa3baeb22fe1f0c94fe86113a638195f0070c5a2cd80e72463de5319a') package() { + _pkgdir="${pkgdir}" + _systemddir="usr/lib/systemd/system" +_package +} +#_package function - used in build variants +_package() { #declare the _pkgdir and systemd directory -_pkgdir="${pkgdir}" -_systemddir="usr/lib/systemd/system" + _msg2 'Installing systemd services' for _i in "${_service[@]}" ; do _msg3 ${_i} diff --git a/monitor.cc.deb.PKGBUILD b/monitor.cc.deb.PKGBUILD new file mode 100644 index 000000000000..91a457df8ab1 --- /dev/null +++ b/monitor.cc.deb.PKGBUILD @@ -0,0 +1,77 @@ +# Maintainer: Moses Narrow <moses@skycoin.com> +source monitor.PKGBUILD +pkgdesc="${pkgdesc} debian package" +_pkgarches=('amd64' 'arm64' 'armhf' 'armel') +_pkgrel=${pkgrel} +license=('license-free') +depends=("gnu-netcat" "ansifilter" "expect") +_service=("skywire-monitor.service") +_serviceconf=("override.conf") +_source=( +"${_service[@]}" +"${_serviceconf[@]}" +"${install}" +) +source=("${_source[@]}") +sha256sums=('72c189a1c1994e90cab0ab3e21a3bf2932b229210a0bc9e296d6a4400e2a52a1' + 'f26f0d3aa3baeb22fe1f0c94fe86113a638195f0070c5a2cd80e72463de5319a' + 'bb44fa8eba36636b4e766030634737cbc85e2203906a0b25e42c23645e0563cd') + + +build() { +_msg2 'creating the DEBIAN/control files' +for i in ${_pkgarches[@]}; do +_msg2 "_pkgarch=$i" +local _pkgarch=$i +#create control file for the debian package +echo "Package: ${pkgname}" > ${srcdir}/${_pkgarch}.control +echo "Version: ${pkgver}-${_pkgrel}" >> ${srcdir}/${_pkgarch}.control +echo "Priority: optional" >> ${srcdir}/${_pkgarch}.control +echo "Section: web" >> ${srcdir}/${_pkgarch}.control +echo "Architecture: ${_pkgarch}" >> ${srcdir}/${_pkgarch}.control +echo "Depends: ${_debdeps}" >> ${srcdir}/${_pkgarch}.control +echo "Provides: ${_pkgname}" >> ${srcdir}/${_pkgarch}.control +echo "Maintainer: Skycoin" >> ${srcdir}/${_pkgarch}.control +echo "Description: ${pkgdesc}" >> ${srcdir}/${_pkgarch}.control +done +} + + +package() { + for _i in "${_pkgarches[@]}"; do + _msg2 "_pkgarch=${_i}" + local _pkgarch="${_i}" + #set up to create a .deb package + _debpkgdir="${pkgname}-${pkgver}-${pkgrel}-${_pkgarch}" + _pkgdir="${pkgdir}/${_debpkgdir}" + [[ -d "${_pkgdir}" ]] && rm -rf "${_pkgdir}" + #declare the _pkgdir and systemd directory${_githuborg} + _systemddir="etc/systemd/system" + _package + _msg2 'installing control file and install scripts' + install -Dm755 "${srcdir}/${_pkgarch}.control" "${_pkgdir}/DEBIAN/control" + _msg2 'creating debian install scripts' + echo -e "#!/bin/sh \n systemctl is-active --quiet skywire && systemctl daemon-reload && systemctl restart skywire && systemctl enable --now skywire-monitor 2> /dev/null" | tee "${_pkgdir}/DEBIAN/postinst.sh" + echo -e "#!/bin/sh \n systemctl is-active --quiet skywire && systemctl daemon-reload && systemctl restart skywire" | tee "${_pkgdir}/DEBIAN/postrm.sh" + chmod +x ${_pkgdir}/DEBIAN/* + _msg2 'creating the debian package' + #create the debian package! + cd "${pkgdir}" + dpkg-deb --build -z9 "${_debpkgdir}" + mv *.deb ../../ + done + #exit so the arch package doesn't get built + exit +} + +_msg2() { +(( QUIET )) && return +local mesg=$1; shift +printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" +} + +_msg3() { +(( QUIET )) && return +local mesg=$1; shift +printf "${BLUE} -->${ALL_OFF} ${mesg}${ALL_OFF}\n" "$@" +} |