Artifact Content

Artifact 0c4022467794024aaea7e7290e82ba56633bbb16:


#! /usr/bin/env bash

version="$1"
url="$2"

if [ -z "${version}" ]; then
	echo 'usage: make-slackware-package <version> [<url>]' >&2
	exit 1
fi
if [ -z "${url}" ]; then
	url="http://rkeene.org/devel/appfs/appfs-${version}.tar.gz"
fi

version_release='1'
platform="$(uname -m)"
make_args=(
	prefix=/usr
	sbindir=/sbin
	mandir=/usr/man
)

if [ ! -f '/etc/slackware-version' ]; then
	echo 'This script is meant to be run on a Slackware system.' >&2

	exit 1
fi

if [ -z "${version}" ]; then
	echo 'Usage: make-slackware-package <version>' >&2

	exit 1
fi

workdir="${TMPDIR:-/tmp}/appfs-slackware-package-${version}-$$${RANDOM}${RANDOM}${RANDOM}"
package="appfs-${version}-${platform}-${version_release}.txz"
mkdir "${workdir}" || exit 1

(
	PATH="${PATH}:/sbin:/opt/appfs/rkeene.org/tardy/platform/latest/bin"

	set -x

	cd "${workdir}" || exit 1

	installdir="$(pwd)/installed"

	case "${url}" in
		*tp://*)
			wget -O appfs.tar.gz "${url}"
			;;
		*)
			cp "${url}" appfs.tar.gz
			;;
	esac
	tar -xf appfs.tar.gz || exit 1

	cd "appfs-${version}" || exit 1

	make "${make_args[@]}" || exit 1
	make "${make_args[@]}" DESTDIR="${installdir}" install || exit 1

	cd "${installdir}" || exit 1

	mkdir install || exit 1
	cat << \_EOF_ > install/slack-desc || exit 1
appfs: appfs (App Filesystem)
appfs:
appfs: AppFS is a manifest-based FUSE filesystem that lazily fetches files over HTTP.
appfs: It is intended to be a universal packaging format.
appfs:
appfs:
appfs:
appfs:
appfs:
appfs:
appfs:
_EOF_

	makepkg -c n -l y "../${package}" || exit 1

	if [ "$(id -u)" != '0' ]; then
		set -o pipefail
		xz -dc "../${package}" | tardy -User 0 -Group 0 | xz -9c > "../${package}.new" || exit 1
		mv "../${package}.new" "../${package}" || exit 1
	fi
) || exit 1

mv "${workdir}/${package}" .

rm -rf "${workdir}"

exit 0