Skip to content

Commit

Permalink
Mirrored package() from PKGBUILD to install-to-dest.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
hirak99 committed Nov 7, 2023
1 parent 99d4db4 commit 2feda02
Showing 1 changed file with 17 additions and 42 deletions.
59 changes: 17 additions & 42 deletions scripts/install-to-dest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,45 +24,20 @@ readonly MY_PATH=$(cd $(dirname "$0") && pwd)

cd $MY_PATH/..

mkdir -p $PKGDIR/usr/share
rsync -rltXHSv src/ $PKGDIR/usr/share/yabsnap \
--chown=root:root \
--chmod=u=rwX,go=rX \
--exclude '*_test.py' \
--include '*/' --include '*.py' --include '*.sh' --include '*.conf' \
--exclude '*' \
--prune-empty-dirs \
--delete
if $(which selinuxenabled 2>/dev/null); then
restorecon -R src/ $PKGDIR/usr/share/yabsnap
fi

mkdir -p $PKGDIR/usr/bin
# Link needs to be to /usr/share/yabsnap/yabsnap.sh (without $PKGDIR/).
# That's where the file will reside after installation.
# Note: Do not use chmod on the symlink. A chmod on symlink is unnecessary,
# and also it will cause an error if the file does not exist.
ln -sf /usr/share/yabsnap/yabsnap.sh $PKGDIR/usr/bin/yabsnap

mkdir -p $PKGDIR/usr/lib/systemd/system
install -Z artifacts/services/yabsnap.service $PKGDIR/usr/lib/systemd/system
install -Z artifacts/services/yabsnap.timer $PKGDIR/usr/lib/systemd/system
if [[ -z "$PKGDIR" ]]; then
# Reload if installed as root (i.e. $PKGDIR should be empty).
# But not during AUR PKGBUILD, since it doesn't have system access.
sudo systemctl daemon-reload
fi

readonly HOOKDIR=/usr/share/libalpm/hooks/
if [[ -d "$HOOKDIR" ]]; then
mkdir -p $PKGDIR/$HOOKDIR
install -Z artifacts/pacman/01-yabsnap-pacman-pre.hook $PKGDIR/$HOOKDIR
else
printf 'Not an Arch based distro, will not install hook.\n' >&2
fi

mkdir -p $PKGDIR/usr/share/man/man1
# Note: makepkg will gzip automatically for Arch, but we gzip explicitly to
# support other distributions.
install -m 644 artifacts/yabsnap.manpage $PKGDIR/usr/share/man/man1/yabsnap.1
gzip -f $PKGDIR/usr/share/man/man1/yabsnap.1
readonly PKGNAME=yabsnap

# This mirrors PKGBUILD with slight modifications.

for file in $(ls -A src/code/*.{py,conf} | grep -v "_test.py")
do
install -Dm 644 "$file" "$PKGDIR"/usr/share/"$PKGNAME"/code/"${file##*/}"
done
cd artifacts
install -Dm 644 services/"$PKGNAME".{service,timer} -t "$PKGDIR"/usr/lib/systemd/system/
install -Dm 664 pacman/*.hook -t "$PKGDIR"/usr/share/libalpm/hooks/
install -Dm 644 yabsnap.manpage "$PKGDIR"/usr/share/man/man1/yabsnap.1
gzip -f "$PKGDIR"/usr/share/man/man1/"$PKGNAME".1
cd ../src
install -Dm 755 "$PKGNAME".sh -t "$PKGDIR"/usr/share/"$PKGNAME"/
install -d "$PKGDIR"/usr/bin
ln -sf /usr/share/"$PKGNAME"/"$PKGNAME".sh "$PKGDIR"/usr/bin/"$PKGNAME"

0 comments on commit 2feda02

Please sign in to comment.