# Maintainer: Moses Narrow # Maintainer: Rudi [KittyCash] _pkgname=privateness pkgname=${_pkgname} _githuborg=NESS-Network pkgdesc=".deb build for NESS Core and Wallet. privateness.network" #set to native architecture with dpkg _pkgarch=$(dpkg --print-architecture) #Uncoment to select architecture - cross compile not working currently #_pkgarch=amd64 #_pkgarch=arm64 #_pkgarch=armhf #leave arch package as any arch=('any') #manually version for now _pkgver=0.27.1 #_tag_ver=0.27.1 pkgver=${_pkgver} #pkgver='autogenerated' #pkgrel keeps getting reset when build is run _pkgrel=1 #pkgrel=1 pkgrel=${_pkgrel} _pkggopath="github.com/${_githuborg}/${_pkgname}" url="https://${_pkggopath}" license=() #make deps for every architecture are included here.. makedepends=('dpkg' 'git' 'go' 'musl' 'kernel-headers-musl') #'aarch64-linux-musl' 'arm-linux-gnueabihf-musl' 'skycoin-keyring') depends=() source=("git+${url}.git" ##branch=${BRANCH:-develop}" "ness-wallet.sh" ) sha256sums=('SKIP' '23babd4af4ebdff1fb914161bcec54cfa9307a5f26fc74ae388f5b131335efb2') # 'SKIP' # 'SKIP') #validpgpkeys=('DE08F924EEE93832DABC642CA8DC761B1C0C0CFC') # Moses Narrow prepare() { #skip signature verification for now because yay handles it differently than makepkg #verify PKGBUILD signature # gpg --verify ${srcdir}/deb.PKGBUILD.sig ${srcdir}/deb.PKGBUILD # https://wiki.archlinux.org/index.php/Go_package_guidelines mkdir -p ${srcdir}/go/src/github.com/${_githuborg}/ ${srcdir}/go/bin.${_pkgarch} ${srcdir}/go/apps.${_pkgarch} ln -rTsf ${srcdir}/${_pkgname} ${srcdir}/go/src/${_pkggopath} cd ${srcdir}/go/src/${_pkggopath}/ } build() { local GOPATH=${srcdir}/go local GOBIN=${GOPATH}/bin.${_pkgarch} local _GOAPPS=${GOPATH}/apps.${_pkgarch} local GOOS=linux export CC=musl-gcc #static cross-compilation #[[ $_pkgarch == "amd64" ]] && local GOARCH=amd64 && local CC=musl-gcc #[[ $_pkgarch == "arm64" ]] && local GOARCH=arm64 && local CC=aarch64-linux-musl-gcc #[[ $_pkgarch == "armhf" ]] && local GOARCH=arm && local GOARM=6 && local CC=arm-linux-gnueabihf-musl-gcc #_ldflags=('-linkmode external -extldflags "-static" -buildid=') #create the skywire binaries cd ${srcdir}/go/src/${_pkggopath} _cmddir=${srcdir}/go/src/${_pkggopath}/cmd _buildbins address_gen _buildbins cipher-testdata _buildbins monitor-peers _buildbins newcoin _buildbins privateness _buildbins privateness-cli #binary transparency cd $GOBIN _msg2 'binary sha256sums' sha256sum $(ls) #create control file for the debian package echo "Package: privateness" > ${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 "Maintainer: github.com/NESS-network" >> ${srcdir}/${_pkgarch}.control echo "Description: ${pkgdesc}" >> ${srcdir}/${_pkgarch}.control } #I had to speed up the build for testing but there's a risk of using old binaries. #will change this when the commit for the build tracks a branch _buildbins() { _GOHERE=$GOBIN #target bin dir _binpath=$3 #find the binary here- expecting 'apps/' or empty _binname=$1 #which binary to build _msg2 "building ${_binname} binary" if [[ ! -f ${_GOHERE}/${_binname} ]] ; then #don't waste time rebuilding existing bins cd ${_cmddir}/${_binpath}${_binname} go build -trimpath --ldflags '-s -w -linkmode external -extldflags "-static" -buildid=' -o $_GOHERE/ . fi } package() { _msg2 'creating dirs' #set up to create a .deb package _debpkgdir="${_pkgname}-${pkgver}-${_pkgrel}-${_pkgarch}" _pkgdir="${pkgdir}/${_debpkgdir}" _nessdir="opt/privateness" _nessbin="${_nessdir}/bin" #create directory trees _nesssrcdir=${srcdir}/${_pkgname} _nesspath=${_pkgdir}/${_nessdir} _nessgobin=${_nesspath}/bin _nessguidir=${_nesspath}/src/gui mkdir -p ${_pkgdir}/usr/bin mkdir -p ${_nessgobin} mkdir -p ${_nessguidir} #install binaries & symlink to /usr/bin _msg2 'installing binaries' _nessbin=${srcdir}/go/bin #collect the binaries & install _nessbins=$( ls "$_nessbin") for i in $_nessbins; do install -Dm755 ${srcdir}/go/bin.${_pkgarch}/${i} ${_nessgobin}/${i} ln -rTsf ${_nessgobin}/$i ${_pkgdir}/usr/bin/${i} chmod 755 ${_pkgdir}/usr/bin/${i} done _msg2 'installing gui sources' #install the web dir (UI) cp -r ${_nesssrcdir}/src/gui/static ${_nessguidir} _msg2 'installing scripts' #install the scripts #_nessscripts=$( ls --ignore=*.service ${srcdir}/${_pkgname}-scripts/ ) #for i in $_nessscripts; do install -Dm755 ${srcdir}/ness-wallet.sh ${_nessgobin}/ness-wallet ln -rTsf ${_nessgobin}/ness-wallet ${_pkgdir}/usr/bin/ness-wallet chmod 755 ${_pkgdir}/usr/bin/ness-wallet #done #_msg2 'installing systemd services' #install the system.d service # install -Dm644 ${srcdir}/${_pkgname}-scripts/${_pkgname}-node.service ${pkgdir}/usr/lib/systemd/system/${_pkgname}-node.service _msg2 'correcting symlink names' #correct symlink names cd ${_pkgdir}/usr/bin/ mv newcoin privateness-newcoin mv address_gen privateness-address-gen mv cipher-testdata privateness-cipher-testdata mv monitor-peers privateness-monitor-peers _msg2 'available binaries and scripts in /usr/bin :' ls _msg2 'installing control file' install -Dm755 ${srcdir}/${_pkgarch}.control ${_pkgdir}/DEBIAN/control #install -Dm755 ${srcdir}/${_scripts}/postinst.sh ${_pkgdir}/DEBIAN/postinst #install -Dm755 ${srcdir}/${_scripts}/postrm.sh ${_pkgdir}/DEBIAN/postrm _msg2 'creating the debian package' #create the debian package cd $pkgdir dpkg-deb --build -z9 ${_debpkgdir} mv *.deb ../../ #exit so the arch package doesn't get built exit } #_install2() { #_binname="${1##*/}" #_binname="${_binname%%.*}" #install -Dm755 ${1} ${_pkgdir}/${2}/${_binname} #ln -rTsf ${_pkgdir}/${2}/${_binname} ${_pkgdir}/usr/bin/${_binname} #chmod +x ${_pkgdir}/usr/bin/${_binname} #} _msg2() { (( QUIET )) && return local mesg=$1; shift printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" }