# This file is part of the src2pkg program: # Copyright 2005-2008 Gilbert Ashley # src2pkg is released under the GNU General Public License Version 2 # make_package make_package() { if [[ "$FAILED" = "" ]] ; then # first get rid of any zero-length files if ! [[ $FORCE_ZERO_LENGTH = "YES" ]] ; then cd $PKG_DIR ; if [[ $(find . -type f -size 0) ]] ; then echo $CYAN"NOTICE! "$NORMAL" Zero-length files were found in the package tree These are" echo "usually blank documents, so we remove them by default. You can always force" echo "installation with: FORCE_ZERO_LENGTH=YES if any of them are really needed." echo "Zero-length files installed under /etc are allowed (some conf files are blank)." echo $BLUE"List of removed files:"$NORMAL for dir in $(ls |grep -v etc) ; do ( cd $dir find . -type f -size 0 -exec echo $(basename {}) \; find . -type f -size 0 -exec rm -f {} \; cd ../ ) done fi find . -type f -name '*.gz' -size 20c | while read file ; do echo "WARNING: Possible empty gzipped file $file" done fi # recheck the directory permissions ? #fix_pkg_perms echo -n $BLUE"Making installable package - "$NORMAL # Build the package: if [[ $QUIET = "YES" ]] ; then cd $PKG_DIR ; tiny_make_package $PACKAGE &> /dev/null else cd $PKG_DIR ; echo "" tiny_make_package $PACKAGE fi if [[ $? -ne 0 ]] ; then echo "" echo $RED"FAILED! "$NORMAL"Creation of package has failed." FAILED="PACKAGE CREATION" else [[ $QUIET = "YES" ]] && echo $GREEN"Done"$NORMAL || echo "" echo $BLUE"Package Creation - "$GREEN"Successful! "$BLUE"- Package Location:"$NORMAL echo $PACKAGE fi [[ $REALLY_INSTALL = "YES" ]] && really_install fi } # tiny_make_package tiny_make_package() { PACKAGE_NAME=$1 TARGET_NAME="$(dirname $PACKAGE_NAME)" PACKAGE_NAME="$(basename $PACKAGE_NAME)" TAR_NAME="$(basename $PACKAGE_NAME .tgz)" umask 022 echo "" if [ "$EUID" = "0" ] ; then ${TAR_STATIC} cvf $TAR_NAME.tar . else ${TAR_STATIC} --owner=root --group=root -cvf $TAR_NAME.tar . fi echo "" echo "Gzipping $TAR_NAME.tar to $TAR_NAME.tar.gz" gzip -9 $TAR_NAME.tar echo "Renaming $TAR_NAME.tar.gz to $PACKAGE_NAME" mv $TAR_NAME.tar.gz $PACKAGE_NAME if [ ! "$TARGET_NAME" = "." ]; then echo "Moving $PACKAGE_NAME to $TARGET_NAME" mv $PACKAGE_NAME $TARGET_NAME fi } # Internal Routines mini_installpkg() { echo $BLUE"Installing package "$NORMAL"$PKG_NAME" ( cd $ROOT/ ; $TAR_STATIC -xzlUpvf - ) < $PACKAGE 2> /dev/null DATABASE_FILE=$ROOT/$ADM_DIR_NAME/packages/$SHORT_NAME make_database if [ -x /sbin/ldconfig ]; then /sbin/ldconfig fi if [ -f $ROOT/install/doinst.sh ]; then echo "Executing install script for $SHORT_NAME..." ( cd $ROOT/ ; sh install/doinst.sh -install; ) fi if [ -d $ROOT/install ]; then if [ -r $ROOT/install/doinst.sh ]; then cp $ROOT/install/doinst.sh $ROOT/$ADM_DIR_NAME/scripts/$SHORT_NAME chmod 755 $ROOT/$ADM_DIR_NAME/scripts/$SHORT_NAME fi # /install/doinst.sh and /install/slack-* are reserved locations for the package system. ( cd $ROOT/install ; rm -f doinst.sh slack-* *desc *require* 1> /dev/null 2>&1 ) rmdir $ROOT/install 1> /dev/null 2>&1 fi } # really install the package only if REALLY_INSTALL="YES" really_install() { if [[ "$FAILED" = "" ]] && [[ $REALLY_INSTALL = "YES" ]] ; then if [[ "$INSTALLPKG" = "internal" ]] ; then mini_installpkg else echo $BLUE"Installing package $PKG_NAME"$NORMAL if [[ $QUIET="YES" ]] ; then $INSTALLPKG $PACKAGE 2> /dev/null 1> /dev/null else $INSTALLPKG $PACKAGE fi fi fi }