#!/bin/bash # Slackware build script for snapd # Copyright 2024 Nathaniel Russell # All rights reserved. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #wget -c https://github.com/snapcore/snapd/releases/download/2.68.3/snapd_2.68.3.vendor.tar.xz wget -c https://github.com/canonical/snapd/releases/download/2.68.3/snapd_2.68.3.vendor.tar.xz cd $(dirname $0) ; CWD=$(pwd) PRGNAM=snapd SRCNAM=snapd_ VERSION=${VERSION:-2.68.3} SRCVER=$VERSION.vendor TAG=_njr BUILD=${BUILD:-1} PKGTYPE=${PKGTYPE:-txz} if [ -z "$ARCH" ]; then case "$( uname -m )" in i?86) ARCH=i586 ;; arm*) ARCH=arm ;; *) ARCH=$( uname -m ) ;; esac fi if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE" exit 0 fi TMP=${TMP:-/tmp/build} PKG=$TMP/package-$PRGNAM OUTPUT=${OUTPUT:-$CWD} if [ "$ARCH" = "i586" ]; then SLKCFLAGS="-O2 -march=i586 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=i686 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fPIC" LIBDIRSUFFIX="64" elif [ "$ARCH" = "aarch64" ]; then SLKCFLAGS="-O2 -fPIC" LIBDIRSUFFIX="64" else SLKCFLAGS="-O2" LIBDIRSUFFIX="" fi set -e rm -rf $PKG mkdir -p $TMP $PKG cd $TMP rm -rf $PRGNAM-$VERSION tar xvf $CWD/$SRCNAM$SRCVER.tar.?z cd $PRGNAM-$VERSION chown -R root:root . export CGO_ENABLED="1" export CGO_CFLAGS="${SLKCFLAGS}" export CGO_CPPFLAGS="${SLKCFLAGS}" export CGO_CXXFLAGS="${SLKCFLAGS}" export CGO_LDFLAGS="${SLKCFLAGS}" cat >"packaging/snapd.defines.mk" <<__DEFINES__ # This file is generated by snapd packaging # Directory variables. prefix = /usr bindir = $prefix/bin sbindir = $prefix/sbin libexecdir = $prefix/lib${LIBDIRSUFFIX} mandir = $prefix/share/man datadir = $prefix/share localstatedir = /var sharedstatedir = /var/lib unitdir = $prefix/lib/systemd/system builddir = $TMP/$PRGNAM-$VERSION/_go_build # Build configuration with_core_bits = 0 with_alt_snap_mount_dir = 1 with_apparmor = 0 with_testkeys = ${WITH_TEST_KEYS:-0} EXTRA_GO_BUILD_FLAGS = -trimpath EXTRA_GO_LDFLAGS = -compressdwarf=false -w -s __DEFINES__ sed -i 's/\/gccgoflags/g' packaging/snapd.mk #sed -i 's/^GO_TAGS = nosecboot$/GO_TAGS =/' packaging/snapd.mk echo "$VERSION" > VERSION make -f packaging/snapd.mk \ SNAPD_DEFINES_DIR="$TMP/$PRGNAM-$VERSION/packaging" make -C data \ BINDIR=/bin \ LIBEXECDIR=/usr/lib${LIBDIRSUFFIX} \ SYSTEMDSYSTEMUNITDIR=/usr/lib/systemd/system \ SNAP_MOUNT_DIR=/var/lib/snapd/snap \ SNAPD_ENVIRONMENT_FILE=/etc/default/snapd cd cmd autoreconf -i -f ./configure \ --prefix=/usr \ --sysconfdir=/etc \ --localstatedir=/var \ --libexecdir=/usr/lib${LIBDIRSUFFIX}/snapd \ --with-snap-mount-dir=/var/lib/snapd/snap \ --disable-apparmor \ --enable-selinux=no \ --enable-nvidia-biarch \ --enable-merged-usr make make install-strip DESTDIR=$PKG cd .. make -C data install \ DBUSSERVICESDIR=/usr/share/dbus-1/services \ BINDIR=/usr/bin \ SYSTEMDSYSTEMUNITDIR=/usr/lib/systemd/system \ SNAP_MOUNT_DIR=/var/lib/snapd/snap \ DESTDIR="$PKG" make -C cmd install DESTDIR="$PKG" make -f packaging/snapd.mk \ SNAPD_DEFINES_DIR="$TMP/$PRGNAM-$VERSION/packaging" \ DESTDIR="$PKG" \ install rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true mv $PKG/usr/share/man $PKG/usr # Compress and link manpages, if any: if [ -d $PKG/usr/man ]; then ( cd $PKG/usr/man for manpagedir in $(find . -type d -name "man*") ; do ( cd $manpagedir for eachpage in $( find . -type l -maxdepth 1) ; do ln -s $( readlink $eachpage ).gz $eachpage.gz rm $eachpage done gzip -9 *.* ) done ) fi # Compress info files, if any: if [ -d $PKG/usr/info ]; then ( cd $PKG/usr/info rm -f dir gzip -9 * ) fi mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION cp -a *.md \ $PKG/usr/doc/$PRGNAM-$VERSION cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG/usr/doc/$PRGNAM-$VERSION/ChangeLog touch -r ChangeLog $PKG/usr/doc/$PRGNAM/ChangeLog fi # It's a bad idea to ship these in the packages. If they aren't kept # updated, there will be missing icons. Let the user create them if # they care to. find $PKG -name icon-theme.cache -exec rm "{}" \+ find $PKG -name .icon-theme.cache -exec rm "{}" \+ mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc #zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh if [ -f $CWD/slack-required ]; then cat $CWD/slack-required > $PKG/install/slack-required; fi if [ -f $CWD/slack-suggests ]; then cat $CWD/slack-suggests > $PKG/install/slack-suggests; fi if [ -f $CWD/slack-conflicts ]; then cat $CWD/slack-conflicts > $PKG/install/slack-conflicts; fi cd $PKG /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE