#!/bin/bash # Slackware build script for snap-slack # Set up variables PRGNAM=snap-slack VERSION=1.0 BUILD=${BUILD:-1} TAG=${TAG:-_SBo} CWD=$(pwd) TMP=${TMP:-/tmp/SBo} PKG=${TMP}/package-${PRGNAM} OUTPUT=${OUTPUT:-/tmp} # Determine architecture (noarch for Python script) ARCH=noarch # Create directories rm -rf $PKG mkdir -p $PKG/usr/bin mkdir -p $PKG/usr/share/$PRGNAM/hooks mkdir -p $PKG/etc/$PRGNAM mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/examples mkdir -p $PKG/var/log mkdir -p $PKG/install # Copy program files cp $CWD/src/snap-slack.py $PKG/usr/bin/snap-slack chmod 0755 $PKG/usr/bin/snap-slack # Copy hook files cp $CWD/hooks/install-hooks.sh $PKG/usr/share/$PRGNAM/hooks/ cp $CWD/hooks/pre-install.sh $PKG/usr/share/$PRGNAM/hooks/ cp $CWD/hooks/post-install.sh $PKG/usr/share/$PRGNAM/hooks/ chmod 0755 $PKG/usr/share/$PRGNAM/hooks/*.sh # Copy configuration file as a .new file to prevent overwriting user's config cp $CWD/config.toml $PKG/etc/$PRGNAM/config.toml.new chmod 0644 $PKG/etc/$PRGNAM/config.toml.new # Copy example configuration files cp $CWD/docs/config-examples/config-*.toml $PKG/usr/doc/$PRGNAM-$VERSION/examples/ chmod 0644 $PKG/usr/doc/$PRGNAM-$VERSION/examples/* # Create an empty log file touch $PKG/var/log/snap-slack.log.new chmod 0644 $PKG/var/log/snap-slack.log.new # Copy documentation cp $CWD/docs/README.md $PKG/usr/doc/$PRGNAM-$VERSION/ cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild # Create doinst.sh for handling .new files and running post-install actions cat > $PKG/install/doinst.sh << EOF config() { NEW="\$1" OLD="\$(dirname \$NEW)/\$(basename \$NEW .new)" # If there's no config file by that name, mv it over: if [ ! -r \$OLD ]; then mv \$NEW \$OLD elif [ "\$(cat \$OLD | md5sum)" = "\$(cat \$NEW | md5sum)" ]; then # toss the redundant copy rm \$NEW fi # Otherwise, we leave the .new copy for the admin to consider... } # Handle config files config etc/$PRGNAM/config.toml.new config var/log/snap-slack.log.new # Suggest installing hooks echo "" echo "To install SlackPkg hooks for automatic snapshots, run:" echo " snap-slack install-hooks" echo "" EOF # Create the Slackware package description cat << EOF > $PKG/install/slack-desc # HOW TO EDIT THIS FILE: # The "handy ruler" below makes it easier to edit a package description. # Line up the first '|' above the ':' following the base package name, and # the '|' on the right side marks the last column you can put a character in. # You must make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':' except on otherwise blank lines. |-----handy-ruler------------------------------------------------------| $PRGNAM: $PRGNAM (BTRFS snapshot manager with bootloader integration) $PRGNAM: $PRGNAM: Snap-Slack is a comprehensive utility for managing Btrfs snapshots on $PRGNAM: Slackware Linux. It provides functionality to create snapshots, manage $PRGNAM: existing snapshots, clean up old snapshots, and adopt snapshots as the $PRGNAM: new root subvolume. The tool also integrates with ELILO and GRUB $PRGNAM: bootloaders, supports encrypted volumes, and has hibernation support. $PRGNAM: It can also automatically create snapshots before package operations. $PRGNAM: $PRGNAM: Version: $VERSION $PRGNAM: Homepage: https://git.bernardomagri.eu/bernardo/snap-slack/ EOF # Build the package cd $PKG /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.txz