|
| 1 | +pkgname=skyrepo |
| 2 | +_pkgname=skyrepo |
| 3 | +pkgdesc="Skycoin apt repo configuration & repo signing key - debian package" |
| 4 | +pkgver='1.3.11' |
| 5 | +_pkgver=${pkgver} |
| 6 | +pkgrel=1 |
| 7 | +_pkgrel=${pkgrel} |
| 8 | +arch=( 'any' ) |
| 9 | +_pkgarches=('amd64' 'arm64' 'armhf' 'armel' 'riscv64') |
| 10 | +_pkgpath="github.com/skycoin/${_pkgname}" |
| 11 | +url="https://${_pkgpath}" |
| 12 | +makedepends=('dpkg') |
| 13 | +depends=() |
| 14 | +_debdeps="" |
| 15 | + |
| 16 | +build() { |
| 17 | + #create the apt repo config |
| 18 | + echo "deb http://deb.skywire.skycoin.com sid main |
| 19 | + # deb-src http://deb.skywire.skycoin.com sid main" | tee ${srcdir}/skycoin.list |
| 20 | + #create the pubkey file |
| 21 | + gpg --export 48F19E5157BE6014D80A47328D6D51BC4AD7AE64 | tee ${srcdir}/skycoin.gpg |
| 22 | + #create the update script |
| 23 | + echo "#!/bin/bash |
| 24 | + apt update -o Dir::Etc::sourcelist=/etc/apt/sources.list.d/skycoin.list && apt -qq --yes reinstall skywire-bin && systemctl is-active --quiet install-skywire && systemctl disable install-skywire 2> /dev/null" | tee ${srcdir}/install-skywire.sh |
| 25 | + #create the update service |
| 26 | + echo "[Unit] |
| 27 | + Description=install skywire service |
| 28 | + After=network-online.target |
| 29 | + Wants=network-online.target |
| 30 | +
|
| 31 | + [Service] |
| 32 | + Type=simple |
| 33 | + ExecStart=/bin/install-skywire |
| 34 | +
|
| 35 | + [Install] |
| 36 | + WantedBy=multi-user.target |
| 37 | + " | tee ${srcdir}/install-skywire.service |
| 38 | + |
| 39 | +echo '#!/bin/bash |
| 40 | +##/usr/bin/skywire-chrootconfig |
| 41 | +#called by the postinstall script of the skyrepo .deb package |
| 42 | +################################################################# |
| 43 | +#meant to run when the skyrepo package is installed in chroot |
| 44 | + if [[ $INSTALLFIRSTBOOT == "1" ]] ; then |
| 45 | + if [[ -f /etc/systemd/system/install-skywire.service ]] ; then |
| 46 | + systemctl enable install-skywire.service |
| 47 | + fi |
| 48 | + fi |
| 49 | + # create envfile |
| 50 | + if [[ ! -f /etc/profile.d/skyenv.sh && -d /etc/profile.d ]] ; then |
| 51 | + touch /etc/profile.d/skyenv.sh |
| 52 | + fi |
| 53 | + # SKYBIAN=true enables autostart of skywire via skywire-autoconfig - on ARM architectures |
| 54 | + if [[ $(cat /etc/profile.d/skyenv.sh | grep SKYBIAN ) != *"SKYBIAN"* ]] ; then |
| 55 | + if [[ $(dpkg --print-architecture) == *"amd64"* ]] ; then |
| 56 | + echo "#SKYBIAN=true" | tee -a /etc/profile.d/skyenv.sh |
| 57 | + else |
| 58 | + echo "SKYBIAN=true" | tee -a /etc/profile.d/skyenv.sh |
| 59 | + fi |
| 60 | + fi |
| 61 | + # VPNSERVER=1 enables autostart of the vpn server - on ARM architectures |
| 62 | + if [[ $(cat /etc/profile.d/skyenv.sh | grep VPNSERVER ) != *"VPNSERVER"* ]] ; then |
| 63 | + if [[ $(dpkg --print-architecture) == *"amd64"* ]] ; then |
| 64 | + echo "#export VPNSERVER=1" | tee -a /etc/profile.d/skyenv.sh |
| 65 | + else |
| 66 | + echo "export VPNSERVER=1" | tee -a /etc/profile.d/skyenv.sh |
| 67 | + fi |
| 68 | + fi |
| 69 | +' | tee ${srcdir}/skywire-chrootconfig.sh |
| 70 | + #create the postinstall script |
| 71 | + echo '#!/bin/bash |
| 72 | + #skybian post install script ; executed by dpkg upon package installation or updates |
| 73 | + /usr/bin/skywire-chrootconfig |
| 74 | +' | tee ${srcdir}/postinst.sh |
| 75 | + #create the DEBIAN/control files |
| 76 | + for _i in ${_pkgarches[@]}; do |
| 77 | + _msg2 "_pkgarch=${_i}" |
| 78 | + local _pkgarch=${_i} |
| 79 | + _msg2 "Creating DEBIAN/control file for ${_pkgarch}" |
| 80 | + echo "Package: ${_pkgname}" > ${srcdir}/${_pkgarch}.control |
| 81 | + echo "Version: ${_pkgver}-${_pkgrel}" >> ${srcdir}/${_pkgarch}.control |
| 82 | + echo "Priority: optional" >> ${srcdir}/${_pkgarch}.control |
| 83 | + echo "Section: web" >> ${srcdir}/${_pkgarch}.control |
| 84 | + echo "Architecture: ${_pkgarch}" >> ${srcdir}/${_pkgarch}.control |
| 85 | + echo "Depends: ${_debdeps}" >> ${srcdir}/${_pkgarch}.control |
| 86 | + echo "Maintainer: Skycoin" >> ${srcdir}/${_pkgarch}.control |
| 87 | + echo "Description: ${pkgdesc}" >> ${srcdir}/${_pkgarch}.control |
| 88 | + cat ${srcdir}/${_pkgarch}.control |
| 89 | + done |
| 90 | +} |
| 91 | + |
| 92 | +package() { |
| 93 | + for _i in ${_pkgarches[@]}; do |
| 94 | + _msg2 "_pkgarch=${_i}" |
| 95 | + local _pkgarch=${_i} |
| 96 | + echo ${_pkgarch} |
| 97 | + #set up to create a .deb package with dpkg |
| 98 | + _debpkgdir="${_pkgname}-${pkgver}-${_pkgrel}-${_pkgarch}" |
| 99 | + _pkgdir="${pkgdir}/${_debpkgdir}" |
| 100 | + ######################################################################### |
| 101 | + #package normally here using ${_pkgdir} instead of ${pkgdir} |
| 102 | + _msg2 "Creating dirs" |
| 103 | + mkdir -p ${_pkgdir}/etc/apt/sources.list.d/ |
| 104 | + mkdir -p ${_pkgdir}/etc/apt/trusted.gpg.d/ |
| 105 | + mkdir -p ${_pkgdir}/usr/bin/ |
| 106 | + mkdir -p ${_pkgdir}/etc/systemd/system/ |
| 107 | + _msg2 "Installing install-skywire.sh skywire installation script" |
| 108 | + install -Dm755 ${srcdir}/install-skywire.sh ${_pkgdir}/usr/bin/install-skywire |
| 109 | + _msg2 "Installing install-skywire.service service for install-skywire.sh" |
| 110 | + install -Dm644 ${srcdir}/install-skywire.service ${_pkgdir}/etc/systemd/system/install-skywire.service |
| 111 | + _msg2 "Installing skywire-chrootconfig" #called by postinstall |
| 112 | + install -Dm755 ${srcdir}/skywire-chrootconfig.sh ${_pkgdir}/usr/bin/skywire-chrootconfig |
| 113 | + _msg2 "Installing apt repository configuration to:\n /etc/apt/sources.list.d/skycoin.list" |
| 114 | + install -Dm644 ${srcdir}/skycoin.list ${_pkgdir}/etc/apt/sources.list.d/skycoin.list |
| 115 | + _msg2 "Installing apt repository signing key to:\n /etc/apt/trusted.gpg.d/skycoin.gpg" |
| 116 | + install -Dm644 ${srcdir}/skycoin.gpg ${_pkgdir}/etc/apt/trusted.gpg.d/skycoin.gpg |
| 117 | + ######################################################################### |
| 118 | + _msg2 'Installing control file and postinst script' |
| 119 | + install -Dm755 ${srcdir}/${_pkgarch}.control ${_pkgdir}/DEBIAN/control |
| 120 | + install -Dm755 ${srcdir}/postinst.sh ${_pkgdir}/DEBIAN/postinst |
| 121 | + _msg2 'Creating the debian package' |
| 122 | + cd $pkgdir |
| 123 | + if command -v tree &> /dev/null ; then |
| 124 | + _msg2 'package tree' |
| 125 | + tree -a ${_debpkgdir} |
| 126 | + fi |
| 127 | + dpkg-deb --build -z9 ${_debpkgdir} |
| 128 | + mv *.deb ../../ |
| 129 | + done |
| 130 | + #clean up manually just in case |
| 131 | + rm -rf ${srcdir} |
| 132 | + #exit so the arch package doesn't get built |
| 133 | + exit |
| 134 | +} |
| 135 | + |
| 136 | +_msg2() { |
| 137 | + (( QUIET )) && return |
| 138 | + local mesg=$1; shift |
| 139 | + printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" |
| 140 | +} |
0 commit comments