# This file is part of the src2pkg program: # Copyright 2005-2010 Gilbert Ashley # src2pkg is released under the GNU General Public License Version 2 # make_package make_package() { if [[ $ALLOW_USER_EXTENSIONS = "YES" ]] ; then # check if the user has any pre-execution extensions to this file and run them, if so. [[ -f "$HOME"/.src2pkg/extensions/15.pre ]] && . "$HOME"/.src2pkg/extensions/15.pre fi if [[ "$FAILED" = "" ]] && [[ ! $USER_CANCELLED ]] ; then if [[ ! $RESUME ]] || [[ $RESUME = $FUNCNAME ]] || [[ $HAVE_RESUMED ]] ; then [[ $RESUME = $FUNCNAME ]] && HAVE_RESUMED=1 && echo $CYAN" Notice - "$BLUE"Resuming build at: "$NORMAL "$FUNCNAME" if [[ $PAUSE = "BEFORE" ]] || [[ $PAUSE = $FUNCNAME ]] ; then echo $MAGENTA"Notice - "$BLUE"Pausing before: "$NORMAL" '$FUNCNAME' Press ENTER to continue" read fi #segregate_package nahh() { if [[ $HAVE_RESUMED ]] ; then if [[ -f $PACKAGE ]] ; then [[ $DEBUG ]] && echo $CYAN" Notice - "$NORMAL"Removing old PACKAGE" rm -f $PACKAGE fi fi } rm -f $PACKAGE # Build the package: if [[ "$PKG_FORMAT" = "deb" ]] ; then . "$SRC2PKG_LIBDIR/make_package/15-make_package_deb" make_debian_pkg elif [[ "$PKG_FORMAT" = "pet" ]] ; then . "$SRC2PKG_LIBDIR/make_package/15-make_package_pet" make_pet_pkg elif [[ "$PKG_FORMAT" = "rpm" ]] ; then . "$SRC2PKG_LIBDIR/make_package/15-make_package_rpm" make_rpm_pkg elif [[ "$PKG_FORMAT" = "tazpkg" ]] ; then . "$SRC2PKG_LIBDIR/make_package/15-make_package_taz" make_taz_pkg else . "$SRC2PKG_LIBDIR/make_package/15-make_package_slack" make_slack_pkg fi if ! [[ $DEBUG ]] ; then rm -f "$SRC_DIR"/$NAME-libtool-files "$SRC_DIR"/$NAME-header-files rm -f "$SRC_DIR"/$NAME-static-libs "$SRC_DIR"/$NAME-ELF-libs rm -f "$SRC_DIR"/$NAME-ELF-bins "$SRC_DIR"/$NAME-ELF-compressed-bins fi fi fi if [[ $ALLOW_USER_EXTENSIONS = "YES" ]] ; then # check if the user has any post-execution extensions to this file and run them, if so. [[ -f "$HOME"/.src2pkg/extensions/15.post ]] && . "$HOME"/.src2pkg/extensions/15.post fi } # end make_package # really install the package only if REALLY_INSTALL="YES" really_install() { if [[ "$FAILED" = "" ]] && [[ "$REALLY_INSTALL" = "YES" ]] ; then case $PKG_FORMAT in tbz|tgz|tlz|txz) if [[ "$INSTALLPKG" = "internal" ]] ; then mini_installpkg_slack "$PACKAGE" 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 ;; *) echo $CYAN" Notice - "$NORMAL"No installation routine available for '$PKG_FORMAT' packages." ;; esac fi } # duplicate any links from the main package in child package duplicate_pkg_dir_links() { if [[ -f $PKG_DIR/install/doinst.sh ]] ; then # create a list of files in this package find * -type f ! -name file.list > file.list # compare the list against the doinst.sh for the main package if [[ -s file.list ]] ; then # [[ $DEBUG ]] && echo -e '\n'$CYAN" Notice - "$NORMAL"Duplicating links from main package" while read FILE ; do # use the basename since the paths are relative in the doinst.sh FILE=${FILE##*/} # only use lines which have 'ln -sf' in them if [[ $(grep ${FILE} $PKG_DIR/install/doinst.sh |grep 'ln -sf' 2> /dev/null) ]] ; then grep ${FILE} $PKG_DIR/install/doinst.sh >> doinst.sh fi done < file.list # create referenced directories in the child package if needed if [[ -s doinst.sh ]] ; then # [[ $DEBUG ]] && echo $CYAN" Notice - "$NORMAL"Duplicating links from main package" while read LINE ; do # lines look like this: ( cd dir ; ln -sf/rm -rf DIR=${LINE%% ;*} DIR=${DIR#*( cd } # strip any leading slashes case $DIR in /*) DIR=${DIR#*/} ;; esac ! [[ -d $DIR ]] && mkdir -p $DIR done < doinst.sh # execute the script in the child package and then remove it sh doinst.sh rm -f doinst.sh fi fi rm -f file.list fi } segregate_package() { if [[ "$SPLIT_PACKAGE" != "" ]] ; then OLD_IFS=$IFS IFS=',' for SPLITPKG in $SPLIT_PACKAGE ; do case $SPLITPKG in dev|devel) ! [[ $DEVEL_TAG ]] && DEVEL_TAG='-devel' # if there are libtool files, headers or static libs listed for the main package, move them here if [[ -s $SRC_DIR/$NAME-libtool-files ]] \ || [[ -s $SRC_DIR/$NAME-static-libs ]] \ || [[ -s $SRC_DIR/$NAME-header-files ]] ; then [[ $DEBUG ]] && echo $CYAN" Notice - "$NORMAL"Separating content for: ${NAME}${DEVEL_TAG}" rm -rf "$PKG_BUILDS_DIR"/$DEVEL_PKG_NAME mkdir -p "$PKG_BUILDS_DIR"/$DEVEL_PKG_NAME IFS=$OLD_IFS if [[ -s $SRC_DIR/$NAME-header-files ]] ; then while read header ; do THIS_DIR="$(dirname $header)" mkdir -p "$PKG_BUILDS_DIR"/$DEVEL_PKG_NAME/$THIS_DIR cp -a "$PKG_DIR"/$header "$PKG_BUILDS_DIR"/$DEVEL_PKG_NAME/$THIS_DIR rm -f $"$PKG_DIR"/$header if [[ $(find "$PKG_DIR"/$THIS_DIR -type f) = "" ]] ; then rm -rf "$PKG_DIR"/$THIS_DIR fi done < "$SRC_DIR"/$NAME-header-files fi if [[ -s $SRC_DIR/$NAME-libtool-files ]] ; then cat "$SRC_DIR"/$NAME-libtool-files |while read FILE ; do THIS_DIR="$(dirname $FILE)" mkdir -p "$PKG_BUILDS_DIR"/$DEVEL_PKG_NAME/$THIS_DIR cp -a "$PKG_DIR"/$FILE "$PKG_BUILDS_DIR"/$DEVEL_PKG_NAME/$THIS_DIR rm -f $"$PKG_DIR"/$FILE if [[ $(find "$PKG_DIR"/$THIS_DIR -type f) = "" ]] ; then rm -rf "$PKG_DIR"/$THIS_DIR fi done fi if [[ -s $SRC_DIR/$NAME-static-libs ]] ; then cat "$SRC_DIR"/$NAME-static-libs |while read FILE ; do THIS_DIR="$(dirname $FILE)" mkdir -p "$PKG_BUILDS_DIR"/$DEVEL_PKG_NAME/$THIS_DIR cp -a "$PKG_DIR"/$FILE "$PKG_BUILDS_DIR"/$DEVEL_PKG_NAME/$THIS_DIR rm -f $"$PKG_DIR"/$FILE if [[ $(find "$PKG_DIR"/$THIS_DIR -type f) = "" ]] ; then rm -rf "$PKG_DIR"/$THIS_DIR fi done fi # also move pkgconfig and/or aclocal files ( cd "$PKG_DIR" for DIR in $(find * -type d -a \( -name pkgconfig -o -name "aclocal*" \)) ; do DIRNAME=$(dirname $DIR) mkdir -p "$PKG_BUILDS_DIR"/$DEVEL_PKG_NAME/$DIRNAME mv "$DIR" "$PKG_BUILDS_DIR"/$DEVEL_PKG_NAME/$DIRNAME done # put man2 and man3 files into the devel package for DIR in $(find * -type d -a \( -name man2 -o -name man3 \)) ; do DIRNAME=$(dirname $DIR) mkdir -p "$PKG_BUILDS_DIR"/$DEVEL_PKG_NAME/$DIRNAME mv "$DIR" "$PKG_BUILDS_DIR"/$DEVEL_PKG_NAME/$DIRNAME done ) # make the devel package depend on the main package mkdir -p "$PKG_BUILDS_DIR"/$DEVEL_PKG_NAME/install # the devel package also depends on the main package, so add that to the depends echo "# $DEVEL_PKG_NAME" >> "$PKG_BUILDS_DIR"/$DEVEL_PKG_NAME/install/$PKG_REQUIRED echo "# Requires:" >> "$PKG_BUILDS_DIR"/$DEVEL_PKG_NAME/install/$PKG_REQUIRED echo "$SHORT_NAME" >> "$PKG_BUILDS_DIR"/$DEVEL_PKG_NAME/install/$PKG_REQUIRED # If the main package has requireds, then the devel package will need them also ,but we'll # go ahead and list them here for more complete info, in case no depends-resolution is being done if [[ -f $PKG_DIR/install/$PKG_REQUIRED ]] ; then cat $PKG_DIR/install/$PKG_REQUIRED >> "$PKG_BUILDS_DIR"/$DEVEL_PKG_NAME/install/$PKG_REQUIRED fi if [[ $EXTENDED_DATABASE = "YES" ]] ; then # write the package meta-data write_meta_data "$PKG_BUILDS_DIR"/$DEVEL_PKG_NAME fi fi ;; nls|i18n) ! [[ $I18N_TAG ]] && I18N_TAG='-i18n' IFS=$OLD_IFS rm -rf "$PKG_BUILDS_DIR"/$I18N_PKG_NAME if [[ $(find "$PKG_DIR" -type d -a \( -name locale -o -name i18n -o -name nls \)) != "" ]] ; then [[ $DEBUG ]] && echo $CYAN" Notice - "$NORMAL"Separating content for: ${NAME}${I18N_TAG}" mkdir -p "$PKG_BUILDS_DIR"/$I18N_PKG_NAME cd $"$PKG_DIR" for DIR in $(find * -type d -a \( -name locale -o -name i18n -o -name nls \)) ; do DIRNAME=$(dirname $DIR) mkdir -p "$PKG_BUILDS_DIR"/$I18N_PKG_NAME/$DIRNAME mv "$DIR" "$PKG_BUILDS_DIR"/$I18N_PKG_NAME/$DIRNAME done fi if [[ $(find "$MAN_DIR" -type f 2> /dev/null) != "" ]] ; then ( cd "$MAN_DIR" if [[ $(find * -maxdepth 1 -type d \( ! -name "*[1-8]" \) 2> /dev/null) != "" ]] ; then mkdir -p "$PKG_BUILDS_DIR"/$I18N_PKG_NAME/$GOOD_MAN_PATH for DIR in $(find * -maxdepth 1 -type d \( ! -name "*[1-8]" \) ) ; do [[ -n $DIR ]] && mv "$DIR" "$PKG_BUILDS_DIR"/$I18N_PKG_NAME/$GOOD_MAN_PATH done fi ) # The MAN_DIR (in main package) is not likely to be empty, but remove it if it is rmdir $MAN_DIR 2> /dev/null fi ;; docs|doc) ! [[ $DOCS_TAG ]] && DOCS_TAG='-docs' IFS=$OLD_IFS rm -rf "$PKG_BUILDS_DIR"/$DOCS_PKG_NAME if [[ -d "$DOC_DIR" ]] ; then [[ $DEBUG ]] && echo $CYAN" Notice - "$NORMAL"Separating content for: ${NAME}${DOCS_TAG}" mkdir -p "$PKG_BUILDS_DIR"/$DOCS_PKG_NAME/$GOOD_DOC_PATH/$NAME-$VERSION ( cd "$DOC_DIR" && mv * "$PKG_BUILDS_DIR"/$DOCS_PKG_NAME/$GOOD_DOC_PATH/$NAME-$VERSION ) ( cd "$PKG_BUILDS_DIR"/$DOCS_PKG_NAME/$GOOD_DOC_PATH/$NAME-$VERSION && { cp -a *README* *Readme* *ReadeMe* *readme* *LICENSE* \ *license* *License* *COPYING* "$DOC_DIR" 2> /dev/null } ) fi if [[ $(find "$MAN_DIR" -type f 2> /dev/null) != "" ]] ; then mkdir -p "$PKG_BUILDS_DIR"/$DOCS_PKG_NAME/$GOOD_MAN_PATH ( cd "$MAN_DIR" && mv * "$PKG_BUILDS_DIR"/$DOCS_PKG_NAME/$GOOD_MAN_PATH ) ( cd "$PKG_DIR" && rm -rf "$GOOD_MAN_PATH" ) fi if [[ $(find "$INFO_DIR" -type f 2> /dev/null) != "" ]] ; then # write the postinst/postrm scripts first write_install_info_postinst "$PKG_BUILDS_DIR"/$DOCS_PKG_NAME if [[ $EXTENDED_DATABASE = "YES" ]] ; then write_install_info_postrm "$PKG_BUILDS_DIR"/$DOCS_PKG_NAME fi # the move the files mkdir -p "$PKG_BUILDS_DIR"/$DOCS_PKG_NAME/$GOOD_INFO_PATH ( cd "$INFO_DIR" && mv * "$PKG_BUILDS_DIR"/$DOCS_PKG_NAME/$GOOD_INFO_PATH ) ( cd "$PKG_DIR" && rm -rf "$GOOD_INFO_PATH" ) fi ;; solibs|libs) ! [[ $SOLIBS_TAG ]] && SOLIBS_TAG='-solibs' IFS=$OLD_IFS if [[ -s "$SRC_DIR"/$NAME-ELF-libs ]] ; then [[ $DEBUG ]] && echo $CYAN" Notice - "$NORMAL"Separating content for: ${NAME}${SOLIBS_TAG}" rm -rf "$PKG_BUILDS_DIR"/$SOLIBS_PKG_NAME mkdir -p "$PKG_BUILDS_DIR"/$SOLIBS_PKG_NAME ( cd $"$PKG_BUILDS_DIR"/$SOLIBS_PKG_NAME while read LIB ; do DIRNAME=$(dirname $LIB) mkdir -p $DIRNAME cp -a "$PKG_DIR/$LIB" $DIRNAME done < "$SRC_DIR"/$NAME-ELF-libs # if there are any config files for the main package, the solibs may need them also if [[ -d $PKG_DIR/etc ]] ; then cp -a $PKG_DIR/etc . fi if [[ -f $PKG_DIR/install/$PKG_REQUIRED ]] ; then mkdir -p "$PKG_BUILDS_DIR"/$SOLIBS_PKG_NAME/install cp $PKG_DIR/install/$PKG_REQUIRED "$PKG_BUILDS_DIR"/$SOLIBS_PKG_NAME/install fi ) if [[ $EXTENDED_DATABASE = "YES" ]] ; then # write the package meta-data write_meta_data "$PKG_BUILDS_DIR"/$SOLIBS_PKG_NAME fi fi ;; esac IFS=',' done IFS=$OLD_IFS fi }