# This file is part of the src2pkg program: # Copyright 2005-2009 Gilbert Ashley # src2pkg is released under the GNU General Public License Version 2 ### compile_source compile_source() { 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/07.pre ]] && . "$HOME"/.src2pkg/extensions/07.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" ]] ; then echo $MAGENTA"Notice - "$BLUE"Pausing before: "$NORMAL" '$FUNCNAME' Press ENTER to continue" read fi ! [[ $CONFIG_DIR ]] && CONFIG_DIR=$SRC_DIR 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 "$DOC_DIR" DOCPATH="$GOOD_DOC_PATH" 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 ;; 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" 2> /dev/null) = "" ]] ; then mkdir -p "$DOCPATH"/"$DOCDIR" 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 if [[ $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 [[ $LOG_COMMANDS = "YES" ]] ; then cd "$OBJ_DIR" ; echo $BLUE"Logging compiler messages to: "$NORMAL"LOG_DIR/$NAME-make.log" $MAKE_COMMAND &> "$LOG_DIR"/$NAME-make.log elif [[ $QUIET = "YES" ]] ; then cd "$OBJ_DIR" ; $MAKE_COMMAND &> /dev/null else cd "$OBJ_DIR" ; 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 in: $FUNCNAME" else FAILED="COMPILING in: $FUNCNAME" 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 if [[ $PAUSE = "AFTER" ]] ; then echo $MAGENTA"Notice - "$BLUE"Pausing after: "$NORMAL" '$FUNCNAME' Press ENTER to continue" read 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/07.post ]] && . "$HOME"/.src2pkg/extensions/07.post fi } # end compile_source # 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 "" }