#- # 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. #- # # 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 local metadir=$destdir/var/db/xbps/metadata/$pkgname local prioinst= local arch= if [ ! -d "$destdir" ]; then echo "ERROR: $pkgname not installed into destdir." exit 1 fi if [ -n "$install_priority" ]; then prioinst=$install_priority else prioinst=0 fi if [ -n "$noarch" ]; then arch=noarch else arch=$xbps_machine fi # Write the files list. local TMPFLIST=$(mktemp -t flist.XXXXXXXXXX) || exit 1 # First add the regular files. find -L $destdir -type f | \ sed -e "s|$destdir||g;s|^\/$||g;/^$/d" > $TMPFLIST # and add the directories at the end. find -L $destdir -type d | 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 pkgname $pkgname version $version architecture $arch priority $prioinst installed_size $(du -sb $destdir|awk '{print $1}') maintainer $(echo $maintainer|sed -e 's|<|[|g;s|>|]|g') short_desc $short_desc long_desc $long_desc _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 "$conf_files" ]; then printf "\tconf_files\n" >> $TMPFPROPS printf "\t\n" >> $TMPFPROPS for f in ${conf_files}; do printf "\t\t$f\n" >> $TMPFPROPS done printf "\t\n" >> $TMPFPROPS fi # Keep directories while removing. if [ -n "$keep_dirs" ]; then printf "\tkeep_dirs\n" >> $TMPFPROPS printf "\t\n" >> $TMPFPROPS for f in ${keep_dirs}; do printf "\t\t$f\n" >> $TMPFPROPS done printf "\t\n" >> $TMPFPROPS fi # Terminate the property list file. printf "\n\n" >> $TMPFPROPS 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/* rm -f $TMPFLIST $TMPFPROPS if [ -f "$XBPS_TEMPLATESDIR/$pkgname/prepost-inst" ]; then cp -f $XBPS_TEMPLATESDIR/$pkgname/prepost-inst \ $destdir/XBPS_PREPOST_INSTALL chmod +x $destdir/XBPS_PREPOST_INSTALL fi if [ -f "$XBPS_TEMPLATESDIR/$pkgname/prepost-rm" ]; then cp -f $XBPS_TEMPLATESDIR/$pkgname/prepost-rm \ $metadir/prepost-rm chmod +x $metadir/prepost-rm fi } # # This function builds a binary package from an installed xbps # package in destdir. # xbps_make_binpkg() { local destdir=$XBPS_DESTDIR/$pkgname-$version local binpkg= local pkgdir= local arch= cd $destdir || exit 1 if [ -n "$noarch" ]; then arch=noarch else arch=$xbps_machine fi binpkg=$pkgname-$version.$arch.xbps pkgdir=$XBPS_PACKAGESDIR/$arch run_rootcmd yes tar cfjp $XBPS_DESTDIR/$binpkg . if [ $? -eq 0 ]; then [ ! -d $pkgdir ] && mkdir -p $pkgdir mv -f $XBPS_DESTDIR/$binpkg $pkgdir echo "=> Built package: $binpkg" fi return $? }