First check in progress for binary packages.

It's explained in the BINPKG_INFO.txt file, and will be extended
probably in a not so distant future. My next work will be working
in the code to handle binary packages with a new utility in C.

--HG--
extra : convert_revision : 1a1846e330fdb11f3dd79cf9d9f12c614098cfe8
This commit is contained in:
Juan RP 2008-12-11 03:22:54 +01:00
parent bab85c98e2
commit b2c180348e
4 changed files with 172 additions and 11 deletions

1
.gitignore vendored
View file

@ -4,3 +4,4 @@ destdir/
srcdistdir/
builddir/
utils/
packages/

40
binpkg/BINPKG_INFO.txt Normal file
View file

@ -0,0 +1,40 @@
A binary package built with xbps is a normal tar(1) archive, compressed
with gzip, bzip2 or lzma and has the following structure:
/
/usr ------|
/var ------| => Package structure that will be installed.
/etc ------|
...
/xbps-metadata
/xbps-metadata/flist
/xbps-metadata/props.plist
/xbps-metadata/postpre-action.sh
The xbps-metadata directory contains all the metadata related to this
package. The flist file contains the list of files that the package will
install. The props.plist file is a proplib(3) property list and
has the following structure:
<dict>
<key>architecture</key>
<string>x86_64</string>
<key>installed_size</key>
<integer>500000</integer>
<key>configuration_files</key>
<array>
<string>/etc/foo.conf</string>
...
</array>
<key>run_depends</key>
<array>
<string>bofh-2.0</string>
<string>foof-1.1</string>
...
</array>
</dict>
This plist might be extended in the future if it's required or useful.
The postpre-action.sh script will be run as specified in the script,
and will do post/pre installation steps required for this package.

118
binpkg/create.sh Executable file
View file

@ -0,0 +1,118 @@
#!/bin/sh
#
# Builds a binary package from an installed xbps package in the
# destination directory. This binary package is just a simple tar(1)
# archive with gzip, bzip2 or lzma compression (all compression
# modes that libarchive supports).
#
# Passed argument: pkgname.
write_metadata()
{
local destdir=$XBPS_DESTDIR/$pkgname-$version
if [ ! -d "$destdir" ]; then
echo "ERROR: $pkgname not installed into destdir."
exit 1
fi
echo -n "=> Writing package metadata ... "
# Write the files list.
local TMPFLIST=$(mktemp -t flist.XXXXXXXXXX) || exit 1
find $destdir | sort -ur | \
sed -e "s|$destdir||g;s|^\/$||g;/^$/d" > $TMPFLIST
# Write the property list file.
local TMPFPROPS=$(mktemp -t fprops.XXXXXXXXXX) || exit 1
cat > $TMPFPROPS <<_EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>architecture</key>
<string>$(uname -m)</string>
<key>installed_size</key>
<integer>$(du -sb $destdir|awk '{print $1}')</integer>
_EOF
# Dependencies
if [ -n "$run_depends" ]; then
printf "\t<key>run_depends</key>\n" >> $TMPFPROPS
printf "\t<array>\n" >> $TMPFPROPS
for f in ${run_depends}; do
printf "\t\t<string>$f</string>\n" >> $TMPFPROPS
done
printf "\t</array>\n" >> $TMPFPROPS
fi
# Configuration files
if [ -n "$config_files" ]; then
printf "\t<key>config_files</key>\n" >> $TMPFPROPS
printf "\t<array>\n" >> $TMPFPROPS
for f in ${config_files}; do
printf "\t\t<string>$f</string>\n" >> $TMPFPROPS
done
printf "\t</array>\n" >> $TMPFPROPS
fi
# Terminate the property list file.
printf "</dict>\n</plist>\n" >> $TMPFPROPS
# Write metadata files into destdir and cleanup.
if [ ! -d $destdir/xbps-metadata ]; then
mkdir -p $destdir/xbps-metadata
fi
cp -f $TMPFLIST $destdir/xbps-metadata/flist
cp -f $TMPFPROPS $destdir/xbps-metadata/props.plist
chmod 644 $destdir/xbps-metadata/*
rm -f $TMPFLIST $TMPFPROPS
echo "done."
}
make_archive()
{
local destdir=$XBPS_DESTDIR/$pkgname-$version
local pkgsdir=$XBPS_DISTRIBUTIONDIR/packages
cd $destdir || exit 1
echo -n "=> Building package ... "
tar cfjp $XBPS_DESTDIR/$pkgname-$version-xbps.tbz2 .
[ $? -eq 0 ] && echo "done."
[ ! -d $pkgsdir ] && mkdir -p $pkgsdir
mv -f $XBPS_DESTDIR/$pkgname-$version-xbps.tbz2 $pkgsdir
echo "=> Built package: ${destdir}-xbps.tbz2"
}
pkg=$1
if [ -z "$pkg" ]; then
echo "ERROR: missing package name as argument."
exit 1
fi
if [ -z "$XBPS_DISTRIBUTIONDIR" ]; then
echo "ERROR: XBPS_DISTRIBUTIONDIR not set."
exit 1
fi
if [ -z "$XBPS_DESTDIR" ]; then
echo "ERROR: XBPS_DESTDIR not set."
exit 1
fi
if [ ! -f $XBPS_DISTRIBUTIONDIR/templates/$pkg.tmpl ]; then
echo "ERROR: missing package template file."
exit 1
fi
. $XBPS_DISTRIBUTIONDIR/templates/$pkg.tmpl
write_metadata
make_archive
return 0

24
xbps.sh
View file

@ -1271,7 +1271,7 @@ list_pkg_files()
msg_error "cannot find $pkg in $XBPS_DESTDIR."
fi
cat $XBPS_DESTDIR/$pkg-$ver/.xbps-filelist|sort -u
cat $XBPS_DESTDIR/$pkg-$ver/xbps-metadata/flist
}
#
@ -1319,7 +1319,6 @@ stow_pkg()
{
local pkg="$1"
local i=
local flist="$XBPS_BUILDDIR/.xbps-filelist-$pkgname-$version"
[ -z "$pkg" ] && return 2
@ -1335,11 +1334,14 @@ stow_pkg()
[ "$build_style" = "meta-template" ] && return 0
fi
# Copy files into masterdir.
cd $XBPS_DESTDIR/$pkgname-$version || exit 1
find . > $flist
sed -i -e "s|^.$||g;s|^./||g;s|.xbps-filelist||g;/^$/d" $flist
cp -ar . $XBPS_MASTERDIR
mv -f $flist $XBPS_DESTDIR/$pkgname-$version/.xbps-filelist
# Build a binary package.
env XBPS_DESTDIR=$XBPS_DESTDIR \
XBPS_DISTRIBUTIONDIR=$XBPS_DISTRIBUTIONDIR \
$XBPS_DISTRIBUTIONDIR/binpkg/create.sh $pkgname
$XBPS_PKGDB_CMD register $pkgname $version "$short_desc"
[ $? -ne 0 ] && exit 1
@ -1382,14 +1384,14 @@ unstow_pkg()
#
[ "$build_style" = "meta-template" ] && return 0
cd $XBPS_DESTDIR/$pkgname-$ver || exit 1
if [ ! -f .xbps-filelist ]; then
msg_error "$pkg is incomplete, missing .xbps-filelist file."
elif [ ! -O .xbps-filelist ]; then
cd $XBPS_DESTDIR/$pkgname-$ver/xbps-metadata || exit 1
if [ ! -f flist ]; then
msg_error "$pkg is incomplete, missing flist."
elif [ ! -O flist ]; then
msg_error "$pkg cannot be removed (permission denied)."
fi
for f in $(cat .xbps-filelist|sort -ur); do
for f in $(cat flist); do
if [ -f $XBPS_MASTERDIR/$f -o -h $XBPS_MASTERDIR/$f ]; then
rm $XBPS_MASTERDIR/$f >/dev/null 2>&1
if [ $? -eq 0 ]; then
@ -1398,7 +1400,7 @@ unstow_pkg()
fi
done
for f in $(cat .xbps-filelist|sort -ur); do
for f in $(cat flist); do
if [ -d $XBPS_MASTERDIR/$f ]; then
rmdir $XBPS_MASTERDIR/$f >/dev/null 2>&1
if [ $? -eq 0 ]; then