Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Flareget package for Slackware. I didn't use makepkg, in case Flareget upstream want an easy way to create Slackware compatible packages directly, without requiring local copies of Slackware packaging tools.
#!/bin/sh
# As this is a binary repack, it can be run on any Linux distro.
# I account for the 'quirks' of Slackware packaging.
flareget_version=${flareget_version:-4.1.80}
deb_ver=$(echo ${flareget_version} | sed 's/\([0-9]\+\.[0-9]\+\)\.\([0-9]\+\)/\1-\2/')
ARCH=${ARCH:-$(uname -m)}
case "$ARCH" in
x86_64) deb_arch=amd64 ;;
i?86) deb_arch=i386 ;;
*) echo "$ARCH is unsupported"; exit 1 ;;
esac
if ! command -v ar >/dev/null 2>&1; then
echo "Install GNU Binutils to use this script!" >&2
exit 1
fi
set -eu
if [ -e flareget_${deb_ver}_${deb_arch}.deb ]; then
echo "Using ./flareget_${deb_ver}_${deb_arch}.deb as a source" >&2
else
wget http://flareget.com/files/flareget/debs/${deb_arch}/flareget_${deb_ver}_${deb_arch}.deb
fi
if [ -d "repack-flareget-${flareget_version}" ]; then
rm -r "repack-flareget-${flareget_version}"
fi
mkdir -p "repack-flareget-${flareget_version}/install"
cd "repack-flareget-${flareget_version}"
ar p ../flareget_${deb_ver}_${deb_arch}.deb data.tar.xz | tar -xJf- --exclude=./usr/share/lintian
# Move the doc and man directories to Slackware expected locations
mv usr/share/doc usr/share/man usr
mv usr/doc/flareget usr/doc/flareget-${flareget_version}
# Fix the lib directory location on 64-bit
if [ "$ARCH" = "x86_64" ]; then
mv usr/lib usr/lib64
if command -v patchelf >/dev/null 2>&1; then
patchelf --set-rpath '$ORIGIN/../lib64/flareget' usr/bin/flareget
else
# Since I don't have a good way to reset the rpath, use a startup script
mv usr/bin/flareget usr/lib64/flareget/flareget
echo '#!/bin/sh' > usr/bin/flareget
echo 'export LD_LIBRARY_PATH="/usr/lib64/flareget:$LD_LIBRARY_PATH"' >> usr/bin/flareget
echo 'exec /usr/lib64/flareget/flareget "$@"' >> usr/bin/flareget
chmod +x usr/bin/flareget
fi
fi
# Now create the post-install to register the desktop file and icons.
cat <<EOS> install/doinst.sh
# Register desktop file
if command -v update-desktop-database >/dev/null 2>&1; then
update-desktop-database -q usr/share/applications
fi
# Register icons
touch -c usr/share/icons/hicolor
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
gtk-update-icon-cache -tq usr/share/icons/hicolor
fi
EOS
# Slackware packages cannot contain symlinks directly. If added in the future,
# then the following will move symlink creation to post install, using a
# method that allows the Slackware package manager to track them.
if find * -type l | grep -qm1 .; then
find * -type l -printf '( cd %h ; rm -rf %f )\n( cd %h ; ln -sf %l %f )\n' -delete >> install/doinst.sh
fi
# Add a package description
cat <<EOD > install/slack-desc
flareget: flareget (Multi-threaded download accelerator and manager)
flareget:
flareget: A full featured, multi-threaded and multi-segment download manager
flareget: and accelerator, with browser integration.
flareget:
flareget:
flareget:
flareget:
flareget:
flareget:
flareget: Homepage: http://flareget.com
EOD
# Slackware tar packages have a quirk with regards to top level directory naming.
# The transform below causes modern GNU tar to use the same style, so that
# "installpkg" handles the package correctly.
# I also reset ownership of files and directories to root.
tar --owner 0 --group 0 --format gnu --transform 'sx^\./\(.\)x\1x' -cJf ../flareget-${flareget_version}-${ARCH}-1.txz .
echo "Created: flareget-${flareget_version}-${ARCH}-1.txz"
cd ..
rm -r "repack-flareget-${flareget_version}"
@ruario

This comment has been minimized.

Copy link
Owner Author

@ruario ruario commented Jan 23, 2015

It is preferable (though not required) to run the above on a system with patchelf installed. If your distro does not provide it directly, you can use these instructions: Fetching, building and installing patchelf for just your user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment