diff --git a/.gitignore b/.gitignore index ccfaac58ef..cd22bf0aab 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ destdir/ srcdistdir/ builddir/ utils/ +packages/ diff --git a/binpkg/BINPKG_INFO.txt b/binpkg/BINPKG_INFO.txt new file mode 100644 index 0000000000..3a0d30497f --- /dev/null +++ b/binpkg/BINPKG_INFO.txt @@ -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: + + + architecture + x86_64 + installed_size + 500000 + configuration_files + + /etc/foo.conf + ... + + run_depends + + bofh-2.0 + foof-1.1 + ... + + + +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. diff --git a/binpkg/create.sh b/binpkg/create.sh new file mode 100755 index 0000000000..331b51bcd4 --- /dev/null +++ b/binpkg/create.sh @@ -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 + + + + + architecture + $(uname -m) + installed_size + $(du -sb $destdir|awk '{print $1}') +_EOF + # Dependencies + if [ -n "$run_depends" ]; then + printf "\trun_depends\n" >> $TMPFPROPS + printf "\t\n" >> $TMPFPROPS + for f in ${run_depends}; do + printf "\t\t$f\n" >> $TMPFPROPS + done + printf "\t\n" >> $TMPFPROPS + fi + + # Configuration files + if [ -n "$config_files" ]; then + printf "\tconfig_files\n" >> $TMPFPROPS + printf "\t\n" >> $TMPFPROPS + for f in ${config_files}; do + printf "\t\t$f\n" >> $TMPFPROPS + done + printf "\t\n" >> $TMPFPROPS + fi + + # Terminate the property list file. + printf "\n\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 diff --git a/xbps.sh b/xbps.sh index 15fa5c127a..91a25fb2b6 100755 --- a/xbps.sh +++ b/xbps.sh @@ -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