23fa45a18b
- Template helpers have been moved to templates/helpers. - Documentation to docs/. - Common scripts have been moved to utils/sh. - Fixed install-destdir when executed via chroot. - Added a build-pkg target that builds a binary package. The package must be installed into destdir before using. - Misc tweaks and fixes. --HG-- extra : convert_revision : 0896e8f24bb7592116aaf77ae9c776033818a3d8
90 lines
2.3 KiB
Bash
90 lines
2.3 KiB
Bash
#
|
|
# This function writes the metadata files into package's destdir,
|
|
# these will be used for binary packages.
|
|
#
|
|
|
|
xbps_write_metadata_pkg()
|
|
{
|
|
local destdir=$XBPS_DESTDIR/$pkgname-$version
|
|
|
|
if [ ! -d "$destdir" ]; then
|
|
echo "ERROR: $pkgname not installed into destdir."
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -d $destdir/xbps-metadata ]; then
|
|
mkdir -p $destdir/xbps-metadata >/dev/null 2>&1
|
|
if [ $? -ne 0 ]; then
|
|
echo "ERROR: you don't have enough perms for this."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Write the files list.
|
|
local TMPFLIST=$(mktemp -t flist.XXXXXXXXXX) || exit 1
|
|
find $destdir | sort -ur | \
|
|
sed -e "s|$destdir||g;s|^\/$||g;s|/xbps-metadata||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.
|
|
cp -f $TMPFLIST $destdir/xbps-metadata/flist
|
|
cp -f $TMPFPROPS $destdir/xbps-metadata/props.plist
|
|
chmod 644 $destdir/xbps-metadata/*
|
|
rm -f $TMPFLIST $TMPFPROPS
|
|
}
|
|
|
|
#
|
|
# This functions builds a binary package from an installed xbps
|
|
# package in destdir.
|
|
#
|
|
|
|
xbps_make_binpkg()
|
|
{
|
|
local destdir=$XBPS_DESTDIR/$pkgname-$version
|
|
local pkgsdir=$XBPS_DISTRIBUTIONDIR/packages
|
|
|
|
cd $destdir || exit 1
|
|
|
|
tar cfjp $destdir-xbps.tbz2 .
|
|
[ ! -d $pkgsdir ] && mkdir -p $pkgsdir
|
|
mv -f $destdir-xbps.tbz2 $pkgsdir
|
|
|
|
echo "=> Built package: $pkgname-$version-xbps.tbz2."
|
|
}
|