# This file is part of the src2pkg program: # Copyright 2005-2008 Gilbert Ashley # src2pkg is released under the GNU General Public License Version 2 ### compile_source compile_source() { if [[ "$FAILED" = "" ]] ; then if [[ "$MAKE_COMMAND" = "skip" ]] ; then echo $BLUE"Skipping compile_source - "$NORMAL elif [[ "$MAKE_COMMAND" = "copyall" ]] ; then # examine_source sets MAKE_COMMAND to copyall for sources with binary content. We copy it here directly to PKG_DIR SHOW_DEPS=1 cd $SRC_DIR ; if [[ -f control ]] ; then echo $BLUE"Found Debian binary content - "$NORMAL elif [[ -d install ]] ; then echo $BLUE"Found Slackware package content - "$NORMAL"Contents of the install directory are" echo "copied into the CWD. Be sure to correct if needed and rebuild package." elif [[ $EXT = "rpm" ]] ; then echo $BLUE"Found RPM binary content - "$NORMAL else echo $BLUE"Found generic binary package content - "$NORMAL fi DOCPATH=$(find . -type d -name doc) if [[ -d $DOCPATH ]] ; then cd $DOCPATH ; DOCDIR=$(ls) else mkdir -p $SRC_DIR/usr/doc/$NAME-$VERSION DOCPATH="usr/doc" DOCDIR="$NAME-$VERSION" fi echo -n $BLUE"Checking contents - "$NORMAL ; [[ $DEBUG ]] && echo "" cd $SRC_DIR for item in $(ls) ; do if [[ -d $item ]] ; then case $item in # looks like some kind of installable directory structure. usr|etc|var|lib|bin|opt|sbin|boot|dev|tmp) [[ $DEBUG ]] && echo "Found directory: $item" ; shift ;; # var) echo ; echo $YELLOW"Warning! "$NORMAL"Directory 'var' may need special permissons" ; shift ;; install) cp -a $SRC_DIR/install/* $CWD; shift ;; esac elif [[ -f $item ]] ; then case $item in preinst|prerm|postinst|md5sums|control) [[ $DEBUG ]] && echo "Moving file: $item into docs" ; cp -a $item $DOCPATH/$DOCDIR/ ; rm -f $item ; ;; # What's this? maybe some sort of installer or other debian file? *) [[ $DEBUG ]] && echo "Removing unrecognized file: $item " ; rm -f $item ;; esac else [[ $DEBUG ]] && echo "Removing unrecognized item: $item " ; rm -f $item fi done ! [[ $DEBUG ]] && echo $GREEN"Done!"$NORMAL if [[ $(ls $DOCPATH/$DOCDIR) = "" ]] ; then echo $CYAN"Notice - "$NORMAL"No documents were found in the content. Creating default README" echo "Notice - This package was created by src2pkg from:" > $DOCPATH/$DOCDIR/README echo "$SOURCE_NAME" >> $DOCPATH/$DOCDIR/README echo "No documents were installed for the package." >> $DOCPATH/$DOCDIR/README fi [[ -d $PKG_DIR ]] && mkdir -p $PKG_DIR echo -n $BLUE"Copying contents to PKG_DIR - "$NORMAL cp -a * $PKG_DIR &> /dev/null echo $GREEN"Done!"$NORMAL else # this is the routine for compiling sources ! [[ $OBJ_DIR ]] && OBJ_DIR="$CONFIG_DIR" find_makefile if [[ $MAKEFILE ]] && [[ $MAKE_COMMAND ]] ; then trap safe_user_cancel 2 CFLAGS="$(echo $STD_FLAGS $EXTRA_FLAGS |white_out)" echo $BLUE"Compiling sources - "$NORMAL"Using: '$MAKE_COMMAND'" export CFLAGS if [[ $QUIET = "YES" ]] ; then cd $OBJ_DIR ; make clean 1> /dev/null 2> /dev/null $MAKE_COMMAND &> /dev/null else cd $OBJ_DIR ; echo $BLUE"Running 'make clean':"$NORMAL make clean 2> /dev/null echo $BLUE"Compiler Messages:"$NORMAL $MAKE_COMMAND fi if [[ $? -eq 0 ]] ; then echo $BLUE"Compiling has been - "$GREEN"Successful!"$NORMAL elif [[ $USER_CANCELLED ]] ; then echo $RED"STOPPED! "$NORMAL"Operation cancelled during compilation! "$NORMAL FAILED="CANCELLED" else FAILED="compile_source" echo "$RED""ERROR! "$NORMAL"Compiling source code has failed." echo "This usually happens because of missing libraries, or" echo "badly written Makefiles or configure scripts." show_requires if [[ $REPLAY_ERRORS = "YES" ]] && [[ $QUIET = "YES" ]] ; then cd $OBJ_DIR ; export CFLAGS=$STD_FLAGS$EXTRA_FLAGS if [[ $DISPLAY ]] ; then echo $CYAN"NOTICE-"$NORMAL"Replaying failed compilation in a separate xterm." ( xterm -hold -e $MAKE_COMMAND & ) else echo $CYAN"NOTICE-"$NORMAL"Replaying failed compilation:" $MAKE_COMMAND fi fi fi else echo $BLUE"Skipping compile_source - "$NORMAL fi fi fi } # show_requires() { if [[ -e $CONFIG_DIR/$NAME.spec ]] ; then if grep "Requires:" $CONFIG_DIR/$NAME.spec 1> /dev/null ; then echo $BLUE"Found an RPM .spec file which shows this:"$NORMAL grep "Requires:" $CONFIG_DIR/$NAME.spec |uniq else echo "No Requires information found in $NAME.spec." fi elif [[ -e $CONFIG_DIR/$NAME.spec.in ]] ; then if grep "Requires:" $CONFIG_DIR/$NAME.spec.in 1> /dev/null ; then echo $BLUE"Searching the RPM .spec.in file turns up this:"$NORMAL grep "Requires:" $CONFIG_DIR/$NAME.spec.in |uniq else echo "No Requires information found in $NAME.spec.in." fi elif [[ -e $CONFIG_DIR/debian/control ]] ; then if grep "Depends:" $CONFIG_DIR/debian/control 1> /dev/null ; then echo $BLUE"Searching the Debian control file turns up this:"$NORMAL grep "Depends:" $CONFIG_DIR/debian/control |uniq else echo $BLUE"Sorry! "$NORMAL"No Depends: information found in Debian control file.." fi else echo $BLUE"Sorry! ""$NORMAL""No Dependency or Requirements information found." fi echo "" }