FreeBSD package creation

This commit is contained in:
Stefan Grundmann 2018-10-06 23:34:47 +00:00
parent b66be32e8b
commit 6e925700f5
2 changed files with 137 additions and 0 deletions

83
packaging/MANIFEST Normal file
View File

@ -0,0 +1,83 @@
name: albatross
version: 1.0.%%GITVER%%_1
origin: local/albatross
comment: Albatross: Managing virtual machines
www: https://github.com/hannesm/vmm
maintainer: Hannes Mehnert <hannes@mehnert.org>
prefix: /usr/local
licenselogic: single
licenses: [NONE]
flatsize: %%FLATSIZE%%
categories: [local]
deps {
gmp {
origin = "math/gmp";
version = "6.1.2";
}
}
scripts : {
pre-install = <<EOD
if [ -n "${PKG_ROOTDIR}" ] && [ "${PKG_ROOTDIR}" != "/" ]; then
PW="/usr/sbin/pw -R ${PKG_ROOTDIR}"
else
PW=/usr/sbin/pw
fi
echo "===> Creating groups."
if ! ${PW} groupshow albatross >/dev/null 2>&1; then
echo "Creating group 'albatross' with gid '496'."
${PW} groupadd albatross -g 496
else
echo "Using existing group 'albatross'."
fi
echo "===> Creating users"
if ! ${PW} usershow albatross >/dev/null 2>&1; then
echo "Creating user 'albatross' with uid '496'."
${PW} useradd albatross -u 496 -g 496 -c "albatross daemon" -d /nonexistent -s /usr/sbin/nologin
else
echo "Using existing user 'albatross'."
fi
EOD;
post-install = <<EOD
mkdir -p /var/run/albatross/util /var/run/albatross/fifo
chown albatross:albatross /var/run/albatross/util /var/run/albatross/fifo
chmod 2760 /var/run/albatross/fifo
chgrp albatross /usr/local/libexec/albatross/vmmd
chmod 2700 /usr/local/libexec/albatross/vmmd
EOD;
post-deinstall = <<EOD
if [ -n "${PKG_ROOTDIR}" ] && [ "${PKG_ROOTDIR}" != "/" ]; then
PW="/usr/sbin/pw -R ${PKG_ROOTDIR}"
else
PW=/usr/sbin/pw
fi
if ${PW} usershow albatross >/dev/null 2>&1; then
echo "==> You should manually remove the \"albatross\" user. "
fi
if ${PW} groupshow albatross >/dev/null 2>&1; then
echo "==> You should manually remove the \"albatross\" group "
fi
EOD;
}
desc = <<EOD
A set of binaries to manage, provision, and deploy virtual machine images.
EOD;
messages [
{
message = <<EOD
===================================================================
you need to:
* modify /etc/devfs.rules to include:
add path 'vmm/solo5*' mode 0660 group albatross
* install solo5-hvt.net solo5-hvt.none in /var/db/albatross
===================================================================
EOD;
}
]

54
packaging/create_package.sh Executable file
View File

@ -0,0 +1,54 @@
#!/bin/sh -e
basedir=$(realpath "$(dirname "$0")"/..)
#tmptmpl=$(basename "$0")
#tmpd=$(mktemp -t "$tmptmpl")
tmpd=$basedir/_build/stage
manifest=$tmpd/+MANIFEST
rootdir=$tmpd/rootdir
trap 'rm -rf $tmpd' 0 INT EXIT
mkdir -p "$rootdir"/usr/local/sbin \
"$rootdir"/usr/local/libexec/albatross \
"$rootdir"/usr/local/etc/rc.d
# stage service scripts
for f in albatross_log \
albatross_stat \
albatross_console \
albatross_daemon \
albatross_x
do install -U $basedir/packaging/rc.d/$f $rootdir/usr/local/etc/rc.d/$f; done
# stage albatross app binaries
for f in vmmd vmm_log vmm_console; do
install -U $basedir/_build/app/$f.native \
$rootdir/usr/local/libexec/albatross/$f; done
install -U $basedir/_build/stats/vmm_stats_lwt.native \
$rootdir/usr/local/libexec/albatross/vmm_stats_lwt
install -U $basedir/_build/app/vmmc.native \
$rootdir/usr/local/sbin/vmmc
# create +MANIFEST
flatsize=$(find "$rootdir" -type f -exec stat -f %z {} + |
awk 'BEGIN {s=0} {s+=$1} END {print s}')
gitver=$(git rev-parse --short HEAD)
sed -e "s:%%GITVER%%:${gitver}:" -e "s:%%FLATSIZE%%:${flatsize}:" \
"$basedir/packaging/MANIFEST" > "$manifest"
{
printf '\nfiles {\n'
find "$rootdir" -type f -exec sha256 -r {} + |
awk '{print " " $2 ": \"" $1 "\"," }'
find "$rootdir" -type l |
awk "{print \" \"\$1 \": -,\"}"
printf '}\n'
} | sed -e "s:${rootdir}::" >> "$manifest"
pkg create -r "$rootdir" -M "$manifest" -o $basedir/_build/