# This file is part of the src2pkg program: # Copyright 2005-2008 Gilbert Ashley # src2pkg is released under the GNU General Public License Version 2 ### create_docs create_docs() { if [[ "$FAILED" = "" ]] ; then cd $PKG_DIR ; if [[ $(find . -type f) = "" ]] ; then echo $RED"ERROR! "$NORMAL"The package tree has no content!" echo "For now, we bail out from the top of create_docs." FAILED="EMPTY PKG_DIR" elif [[ "$CORRECT_DOCS" = "YES" ]] ; then # Move docs badly placed by the script writer -note that only stuff under /usr/share gets moved if [[ -d $PKG_DIR/usr/share/doc ]] && [[ "$CORRECT_DOCS" = "YES" ]] ; then [[ -L $PKG_DIR/usr/doc ]] && rm -f $PKG_DIR/usr/doc echo $CYAN"NOTICE! "$NORMAL"Moving docs installed under usr/share/doc to usr/doc." ( cd $PKG_DIR/usr/share && mv doc .. &> /dev/null ) # if nothing else was installed under share then remove it if [[ $(ls $PKG_DIR/usr/share/ 2> /dev/null) = "" ]] ; then echo $BLUE"Removing empty usr/share - "$NORMAL rm -rf $PKG_DIR/usr/share fi fi # if docs have been installed without a version number correct it if [[ -d $PKG_DIR/usr/doc ]] && [ $(ls $PKG_DIR/usr/doc |wc -l) -eq 1 ] ; then if [[ ! -d $PKG_DIR/usr/doc/$NAME-$VERSION ]] && [[ "$CORRECT_DOCS" = "YES" ]] ; then DIRME=$(ls $PKG_DIR/usr/doc) echo $CYAN"NOTICE! "$NORMAL"Renaming doc directory installed without a version number." mv $PKG_DIR/usr/doc/$DIRME $PKG_DIR/usr/doc/$NAME-$VERSION &> /dev/null fi fi ! [[ -d $PKG_DIR/usr/doc/$NAME-$VERSION ]] && mkdir -p $PKG_DIR/usr/doc/$NAME-$VERSION if ! [[ $DOCLIST = "" ]] ; then echo -n $BLUE"Copying documents - "$NORMAL"Using user-supplied DOCLIST - " for doc in $DOCLIST ; do if [[ -e $CONFIG_DIR/$doc ]] ; then cp -a $CONFIG_DIR/$doc $PKG_DIR/usr/doc/$NAME-$VERSION 2> /dev/null 1> /dev/null elif [[ -e $SRC_DIR/$doc ]] ; then cp -a $SRC_DIR/$doc $PKG_DIR/usr/doc/$NAME-$VERSION 2> /dev/null 1> /dev/null fi done else echo -n $BLUE"Checking for standard documents - "$NORMAL for doc in ABOUT ANNOUNCE AUTHORS BUGS CHANGELOG CHANGES ChangeLog Changelog CONTRIBUTORS COPYING COPYRIGHT CREDITS FAQ FEATURES History HISTORY INSTALL LICENSE LICENCE LSM MANIFEST NEWS README README.txt README.TXT README.* *.README Readme readme readme.txt THANKS TIPS TODO VERSION CONFIGURATION GPL LGPL License ; do if [[ -f $CONFIG_DIR/$doc ]] ; then cp -a $CONFIG_DIR/$doc $PKG_DIR/usr/doc/$NAME-$VERSION 2> /dev/null 1> /dev/null elif [[ -f $SRC_DIR/$doc ]] ; then cp -a $SRC_DIR/$doc $PKG_DIR/usr/doc/$NAME-$VERSION 2> /dev/null 1> /dev/null fi done fi cd $PKG_DIR/usr/doc/$NAME-$VERSION ; ls * &> /dev/null if [[ $? -eq 0 ]] ; then echo $GREEN"Done"$NORMAL elif [[ -d $SRC_DIR/doc ]] ; then cp -a $SRC_DIR/doc/*.txt $SRC_DIR/doc/*.doc $SRC_DIR/doc/*.ps \ $SRC_DIR/doc/*.html $SRC_DIR/doc/*.htm $PKG_DIR/usr/doc/$NAME-$VERSION/ 1> /dev/null 2> /dev/null echo $GREEN"Done"$NORMAL elif [[ -d $SRC_DIR/docs ]] ; then cp -a $SRC_DIR/docs/*.txt $SRC_DIR/docs/*.doc $SRC_DIR/docs/*.ps \ $SRC_DIR/docs/*.html $SRC_DIR/docs/*.htm $PKG_DIR/usr/doc/$NAME-$VERSION/ 1> /dev/null 2> /dev/null echo $GREEN"Done2"$NORMAL fi cd $PKG_DIR/usr/doc/$NAME-$VERSION if [[ $(find . -type f) = "" ]] ; then echo "None found" echo $YELLOW"Warning! "$NORMAL"No documents were found for the package." cd $PKG_DIR/usr && rm -rf doc else cd $PKG_DIR/usr/doc ; if [[ $(find . -type f -size 0) ]] && [[ "$CORRECT_DOCS" = "YES" ]] ; then echo $BLUE"Found empty documents - "$NORMAL"Removing zero-length files in /usr/doc." find . -type f -size 0 -exec rm -f {} \; fi cd $PKG_DIR ; find $PKG_DIR/usr/doc -type f -exec chmod 644 {} \; # be more thorough... for really weird installations find $PKG_DIR/$PRE_FIX -path './*/doc/*' -type f -exec chmod 644 {} \; find $PKG_DIR/$PRE_FIX -path './*/share/doc/*' -type f -exec chmod 644 {} \; find $PKG_DIR/$PRE_FIX -path './*/share/$NAME/doc/*' -type f -exec chmod 644 {} \; advanced_docs fi fi fi } # Internal Routine advanced_docs() { # look for pkgconfig .pc files in sources if [[ $(find $SRC_DIR -maxdepth 1 -name '*.pc' 2> /dev/null) ]] ; then echo $BLUE"Found pkgconfig '*.pc' file - "$NORMAL"Copying into the PKG_DIR" mkdir -p $PKG_DIR/usr/lib/pkgconfig find $SRC_DIR -maxdepth 1 -name '*.pc' -exec cp -a {} $PKG_DIR/usr/lib/pkgconfig \; find $PKG_DIR -maxdepth 1 -name '*uninstalled.pc' -exec rm -f {} \; fi # look for *.desktop file in sources: if [[ $(find $SRC_DIR -maxdepth 1 -name '*.desktop' 2> /dev/null) ]] ; then echo $BLUE"Found '*.desktop' file - "$NORMAL"Copying into the PKG_DIR" mkdir -p $PKG_DIR/usr/share/applications find $SRC_DIR -maxdepth 1 -name '*.desktop' -exec cp -a {} $PKG_DIR/usr/share/applications \; fi # look for *.desktop file in CWD also if [[ $(find $CWD -maxdepth 1 -name '*.desktop' 2> /dev/null) ]] ; then echo $BLUE"Found '*.desktop' file in CWD - "$NORMAL"Copying into the PKG_DIR" mkdir -p $PKG_DIR/usr/share/applications find $CWD -maxdepth 1 -name '*.desktop' -exec cp -a {} $PKG_DIR/usr/share/applications \; &> /dev/null fi # Below are Advanced package handling routines [[ $SAVE_SPACE -gt 2 ]] && \ [[ -f $PKG_DIR/usr/doc/$NAME-$VERSION/COPYING ]] && \ { mkdir -p $PKG_DIR/usr/share/licenses mv $PKG_DIR/usr/doc/$NAME-$VERSION/COPYING $PKG_DIR/usr/share/licenses/COPYING cd $PKG_DIR/usr/doc/$NAME-$VERSION ln -sf ../../share/licenses/COPYING $COPYING } [[ $SAVE_SPACE -gt 1 ]] && \ { cd $PKG_DIR/usr/doc ${TAR_STATIC} -cjf $NAME-$VERSION-doc.tbz $NAME-$VERSION cd $PKG_DIR rm -rf $PKG_DIR/usr/doc/$NAME-$VERSION } # purge_locales if [[ "$PURGE_LOCALES" = "YES" ]] ; then ! [[ $DONT_PURGE_LIST ]] && DONT_PURGE_LIST="/etc/src2pkg/DONT_PURGE.locales" ! [[ $LOCALE_LIST ]] && LOCALE_LIST="/etc/src2pkg/all-locales.txt" if [[ -e $DONT_PURGE_LIST ]] && [[ -e $LOCALE_LIST ]] ; then $BLUE"Purging locale files- "$NORMAL"Removing extra language files if found" for LOCALE_DIR in $LOCALE_DIRS ; do if [[ -d $PKG_DIR/$LOCALE_DIR ]] ; then for LOCALE in $(/bin/ls $PKG_DIR/$LOCALE_DIR) ; do [[ "$(grep -x ^$LOCALE $LOCALE_LIST)" ]] && \ [[ ! "$(grep -x ^$LOCALE $DONT_PURGE_LIST)" ]] && \ [[ -d $PKG_DIR/$LOCALE_DIR/$LOCALE/LC_MESSAGES ]] && { rm -f $(find $PKG_DIR/$LOCALE_DIR/$LOCALE -type f) rm -f $(find $PKG_DIR/$LOCALE_DIR/$LOCALE/LC_MESSAGES -type f) rmdir $PKG_DIR/$LOCALE_DIR/$LOCALE/LC_MESSAGES rmdir $PKG_DIR/$LOCALE_DIR/$LOCALE } done fi done else echo $YELLOW"Notice! "$NORMAL"LOCALE_PURGE configuration files were not found." echo "See the documentation for how to set up locale purging. "$BLUE"Skipping..."$NORMAL fi fi # check to make sure directroy perms are correct: if [[ -d $PKG_DIR/usr/doc ]] ; then chmod 775 $PKG_DIR/usr/doc ( cd $PKG_DIR/usr/doc && find -type d | xargs -r chmod 755 ) fi if [[ -d $PKG_DIR/usr/share ]] ; then chmod 775 $PKG_DIR/usr/share ( cd $PKG_DIR/usr/share && find -type d | xargs -r chmod 755 ) fi if [[ -d $PKG_DIR/usr/lib/pkgconfig ]] ; then chmod 775 $PKG_DIR/usr/lib chmod 775 $PKG_DIR/usr/lib/pkgconfig fi } # End advanced_docs