2008-12-13 04:23:16 +00:00
|
|
|
#-
|
|
|
|
# Copyright (c) 2008 Juan Romero Pardines.
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#-
|
|
|
|
|
2008-12-11 02:22:54 +00:00
|
|
|
#
|
2008-12-13 02:01:24 +00:00
|
|
|
# This function writes the metadata files into package's destdir,
|
|
|
|
# these will be used for binary packages.
|
2008-12-11 02:22:54 +00:00
|
|
|
#
|
2008-12-13 02:01:24 +00:00
|
|
|
xbps_write_metadata_pkg()
|
2008-12-11 02:22:54 +00:00
|
|
|
{
|
|
|
|
local destdir=$XBPS_DESTDIR/$pkgname-$version
|
2008-12-17 07:27:28 +00:00
|
|
|
local metadir=$destdir/var/cache/xbps/metadata/$pkgname
|
2008-12-11 02:22:54 +00:00
|
|
|
|
|
|
|
if [ ! -d "$destdir" ]; then
|
|
|
|
echo "ERROR: $pkgname not installed into destdir."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Write the files list.
|
|
|
|
local TMPFLIST=$(mktemp -t flist.XXXXXXXXXX) || exit 1
|
|
|
|
find $destdir | sort -ur | \
|
2008-12-17 07:27:28 +00:00
|
|
|
sed -e "s|$destdir||g;s|^\/$||g;/^$/d" > $TMPFLIST
|
2008-12-11 02:22:54 +00:00
|
|
|
|
|
|
|
# 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>
|
2008-12-18 06:14:01 +00:00
|
|
|
<key>pkgname</key>
|
|
|
|
<string>$pkgname</string>
|
|
|
|
<key>version</key>
|
2008-12-19 02:01:11 +00:00
|
|
|
<string>$version</string>
|
2008-12-11 02:22:54 +00:00
|
|
|
<key>architecture</key>
|
2008-12-18 01:11:12 +00:00
|
|
|
<string>$xbps_machine</string>
|
2008-12-11 02:22:54 +00:00
|
|
|
<key>installed_size</key>
|
|
|
|
<integer>$(du -sb $destdir|awk '{print $1}')</integer>
|
2008-12-13 07:44:51 +00:00
|
|
|
<key>maintainer</key>
|
2008-12-19 02:24:49 +00:00
|
|
|
<string>$(echo $maintainer|sed -e 's|<|[|g;s|>|]|g')</string>
|
2008-12-13 07:44:51 +00:00
|
|
|
<key>short_desc</key>
|
2008-12-19 02:01:11 +00:00
|
|
|
<string>$short_desc</string>
|
2008-12-13 07:44:51 +00:00
|
|
|
<key>long_desc</key>
|
|
|
|
<string>$long_desc</string>
|
2008-12-11 02:22:54 +00:00
|
|
|
_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
|
2008-12-14 00:54:18 +00:00
|
|
|
if [ -n "$conf_files" ]; then
|
|
|
|
printf "\t<key>conf_files</key>\n" >> $TMPFPROPS
|
2008-12-11 02:22:54 +00:00
|
|
|
printf "\t<array>\n" >> $TMPFPROPS
|
2008-12-14 00:54:18 +00:00
|
|
|
for f in ${conf_files}; do
|
2008-12-11 02:22:54 +00:00
|
|
|
printf "\t\t<string>$f</string>\n" >> $TMPFPROPS
|
|
|
|
done
|
|
|
|
printf "\t</array>\n" >> $TMPFPROPS
|
|
|
|
fi
|
2008-12-14 00:48:36 +00:00
|
|
|
# Keep directories while removing.
|
|
|
|
if [ -n "$keep_dirs" ]; then
|
|
|
|
printf "\t<key>keep_dirs</key>\n" >> $TMPFPROPS
|
|
|
|
printf "\t<array>\n" >> $TMPFPROPS
|
|
|
|
for f in ${keep_dirs}; do
|
|
|
|
printf "\t\t<string>$f</string>\n" >> $TMPFPROPS
|
|
|
|
done
|
|
|
|
printf "\t</array>\n" >> $TMPFPROPS
|
|
|
|
fi
|
2008-12-11 02:22:54 +00:00
|
|
|
|
|
|
|
# Terminate the property list file.
|
|
|
|
printf "</dict>\n</plist>\n" >> $TMPFPROPS
|
|
|
|
|
2008-12-17 07:27:28 +00:00
|
|
|
if [ ! -d $metadir ]; then
|
|
|
|
mkdir -p $metadir >/dev/null 2>&1
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "ERROR: you don't have enough perms for this."
|
|
|
|
rm -f $TMPFLIST $TMPFPROPS
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Write metadata files and cleanup.
|
|
|
|
cp -f $TMPFLIST $metadir/flist
|
|
|
|
cp -f $TMPFPROPS $metadir/props.plist
|
|
|
|
chmod 644 $metadir/*
|
2008-12-11 02:22:54 +00:00
|
|
|
rm -f $TMPFLIST $TMPFPROPS
|
|
|
|
}
|
|
|
|
|
2008-12-13 02:01:24 +00:00
|
|
|
#
|
2008-12-13 04:23:16 +00:00
|
|
|
# This function builds a binary package from an installed xbps
|
2008-12-13 02:01:24 +00:00
|
|
|
# package in destdir.
|
|
|
|
#
|
|
|
|
xbps_make_binpkg()
|
2008-12-11 02:22:54 +00:00
|
|
|
{
|
|
|
|
local destdir=$XBPS_DESTDIR/$pkgname-$version
|
2008-12-18 01:11:12 +00:00
|
|
|
local binpkg=$pkgname-$version.$xbps_machine.xbps
|
2008-12-11 02:22:54 +00:00
|
|
|
|
|
|
|
cd $destdir || exit 1
|
|
|
|
|
2008-12-18 01:11:12 +00:00
|
|
|
run_rootcmd tar cfjp $XBPS_DESTDIR/$binpkg .
|
2008-12-13 06:04:53 +00:00
|
|
|
[ ! -d $XBPS_PACKAGESDIR ] && mkdir -p $XBPS_PACKAGESDIR
|
2008-12-18 01:11:12 +00:00
|
|
|
mv -f $XBPS_DESTDIR/$binpkg $XBPS_PACKAGESDIR
|
2008-12-11 02:22:54 +00:00
|
|
|
|
2008-12-18 01:11:12 +00:00
|
|
|
echo "=> Built package: $binpkg"
|
2008-12-11 02:22:54 +00:00
|
|
|
}
|