jhalfs - delete old package dirs upon restart

George Boudreau georgeb at linuxfromscratch.org
Wed May 31 14:54:22 PDT 2006


Manuel,

   I am trying out the following pieces of code before committing them. 
They address the request for 'delete before unpack' that is necessary 
when restarting the makefile.  Other than the addition of these two 
functions I insert calls to these routines from within wrt_unpack, 
wrt_unpack2 and wrt_unpack3.

   This may not be the cleanest method but it seems to do the job. The 
only issue I see is if we *WANT* to keep the directories ( binutils? ) 
then this method will fail. The books do not keep any directories 
hanging around between passes or phases do they?

Examnple:::

#----------------------------------#
wrt_unpack() {                     # Unpack and set 'ROOT' var
#----------------------------------#
   local FILE=$1

   wrt_remove_existing_dirs "$FILE"  <<<<<< NEW CALL
(
cat << EOF
	@\$(call unpack,$FILE)
	@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
	echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
	chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT
EOF
) >> $MKFILE.tmp
}


##### NEW functions #####

#----------------------------------#
wrt_remove_existing_dirs() {       #
#----------------------------------#
   local PKG_NAME=$1
(
cat << EOF
	@ROOT=\`tar -tf \$(MOUNT_PT)\$(SRC)/${PKG_NAME} | head -n1 | sed -e 
's@^./@@;s@/.*@@'\` && \\
	rm -rf \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
	if [ -e \$(MOUNT_PT)\$(SRC)/${PKG_NAME%%-*}-build ]; then \\
		rm -rf \$(MOUNT_PT)\$(SRC)/${PKG_NAME%%-*}-build; \\
	fi;
EOF
) >> $MKFILE.tmp
}

#----------------------------------#
wrt_remove_existing_dirs2() {      #
#----------------------------------#
   local PKG_NAME=$1
(
cat << EOF
	@ROOT=\`tar -tf \$(SRC)/${PKG_NAME} | head -n1 | sed -e 
's@^./@@;s@/.*@@'\` && \\
	rm -rf \$(SRC)/\$\$ROOT && \\
	if [ -e \$(SRC)/${PKG_NAME%%-*}-build ]; then \\
		rm -rf \$(SRC)/${PKG_NAME%%-*}-build; \\
	fi;
EOF
) >> $MKFILE.tmp
}



More information about the alfs-discuss mailing list