# 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_dirs make_dirs() { if [[ "$PACKAGE" = "$SOURCE" ]] ; then echo $RED"FAILED! "$NORMAL"You appear to be trying to repackage" echo "a package with the same name from inside your PKG_DEST_DIR." FAILED=" SOURCE_EQUALS_PACKAGE" fi if [[ "$FAILED" = "" ]] ; then # check validity of directories again -even harder cause we're going to use 'rm -rf' here to cleanup check_dirs2 # clean up any leftover directories, packages and logs. Use rm -rf as safely as possible if [[ -f $PACKAGE ]] || [[ -d $PKG_DIR ]] ; then [[ "$QUIET" = "YES" ]] && echo -n $BLUE"Deleting old build files - "$NORMAL if [[ -f $PKG_DEST_DIR/$PKG_NAME ]] && [[ "$PACKAGE" != "$SOURCE" ]] ; then [[ "$QUIET" = "NO" ]] && echo $BLUE"Removing existing package from previous build - "$NORMAL ( cd $PKG_DEST_DIR && rm -f $PKG_NAME 2> /dev/null 1> /dev/null ) fi if [[ -d $PKG_BUILDS_DIR/$PKG_DIR_NAME ]] ; then [[ "$QUIET" = "NO" ]] && echo $BLUE"Removing existing package build directory from previous build - "$NORMAL ( cd $PKG_BUILDS_DIR && rm -rf $PKG_DIR_NAME 2> /dev/null 1> /dev/null ) fi if [[ $OBJ_DIR_NAME != "" ]] && [[ -d $SRC_BUILDS_DIR/$OBJ_DIR_NAME ]] ; then [[ "$QUIET" = "NO" ]] && echo $BLUE"Removing existing object build directory from previous build - "$NORMAL ( cd $SRC_BUILDS_DIR && rm -rf $OBJ_DIR_NAME 2> /dev/null 1> /dev/null ) fi if [[ -d $SRC_BUILDS_DIR/$SRC_DIR_NAME ]] ; then if [[ $SRC_DIR = $CWD ]] || [[ $SRC_BUILDS_DIR/$SRC_DIR_NAME = $CWD ]] ; then [[ "$QUIET" = "NO" ]] && echo $BLUE"Skipping source build directory - "$NORMAL # be sure to skip this if SRC_DIR=CWD or we remove ourselves true else [[ "$QUIET" = "NO" ]] && echo $BLUE"Removing existing source build directory from previous build - "$NORMAL ( cd $SRC_BUILDS_DIR && rm -rf $SRC_DIR_NAME 2> /dev/null 1> /dev/null ) fi fi # remove any logfiles leftover from fake_install. They should only exist if the build # was interrupted or if we were asked to save them [[ -e $CWD/FILELIST ]] && rm -f $CWD/FILELIST 2> /dev/null 1> /dev/null [[ -e $CWD/FILELIST.tmp ]] && rm -f $CWD/FILELIST.tmp 2> /dev/null 1> /dev/null [[ -e $CWD/DIRLIST ]] && rm -f $CWD/DIRLIST 2> /dev/null 1> /dev/null [[ -e $CWD/patched-files-$NAME-$VERSION ]] && rm -f $CWD/patched-files-$NAME-$VERSION 2> /dev/null 1> /dev/null [[ -e $CWD/deps_list ]] && rm -f $CWD/deps_list [[ -e $CWD/deps_list.tmp ]] && rm -f $CWD/deps_list.tmp [[ -e $CWD/libsentry.debug ]] && rm -f $CWD/libsentry.debug # clean up any debugging list or logs [[ -e $CWD/LINKLIST ]] && rm -f $CWD/LINKLIST 2> /dev/null 1> /dev/null [[ -e $CWD/FILELIST.orig ]] && rm -f $CWD/FILELIST.orig 2> /dev/null 1> /dev/null # cleanup any reports left from post_process [[ -e $DATABASE_FILE ]] && rm -f $DATABASE_FILE [[ -e $REPORT_FILE ]] && rm -f $REPORT_FILE # if the -backup dir still exists something really went wrong last time -remove it if [[ -d $BACKUP_DIR/$NAME-$VERSION-backup-$BUILD$SIG ]] ; then cd $BACKUP_DIR rm -rf $NAME-$VERSION-backup-$BUILD$SIG 2> /dev/null 1> /dev/null fi [[ "$QUIET" = "YES" ]] && echo $GREEN"Done"$NORMAL fi # create new working directories echo $BLUE"Creating working directories:"$NORMAL # these general directories are usually already present -we don't ever remove these # since by default all these are equal to /tmp. [[ ! -d $SRC_BUILDS_DIR ]] && mkdir -p $SRC_BUILDS_DIR [[ ! -d $PKG_BUILDS_DIR ]] && mkdir -p $PKG_BUILDS_DIR [[ ! -d $PKG_DEST_DIR ]] && mkdir -p $PKG_DEST_DIR # create the PKG_DIR where package content is prepared. PRE_FIX is only created later # in fake_install if installation is successful. That way an empty PKG_DIR can serve as a test later. if [[ ! -d $PKG_DIR ]] ; then cd $PKG_BUILDS_DIR && mkdir -p $PKG_DIR_NAME && echo " PKG_DIR=$PKG_DIR" fi # Create a separate OBJ_DIR if asked for. This must be in the same directory as the sources # so that we can call 'configure' using a relative path name which we know: ../$SRC_DIR_NAME/configure if [[ $USE_OBJ_DIR ]] ; then cd $SRC_BUILDS_DIR && mkdir -p $OBJ_DIR_NAME && echo " OBJ_DIR=$OBJ_DIR" fi # be sure and not recreate the directory you are in (running src2pkg like trackinstall where SRC_DIR=$CWD) if [[ $SOURCE_NAME ]] && [[ "$SRC_DIR" != "$CWD" ]] ; then cd $SRC_BUILDS_DIR [[ ! -d $SRC_DIR_NAME ]] && mkdir -p $SRC_DIR_NAME && echo " SRC_DIR=$SRC_DIR" fi fi } # end make_dirs