Add a "-P olddistfiles" facility to prefetch ports distfiles, using an

old distfile directory as primary source:

      mkdir /freebsd/ports/distfiles.old
      mv /freebsd/ports/distfiles/* /freebsd/ports/distfiles.old
      sh sysbuild.sh -c $yourconfig -P /freebsd/ports/distfiles.old
      rm -rf /freebsd/ports/distfiles.old

Unfortunately bsd.ports.mk does not attempt to use a hard-link so
while this runs you need diskspace for both your old and your "new"
distfiles.
This commit is contained in:
Poul-Henning Kamp 2011-10-23 19:46:01 +00:00
parent 987415b113
commit b2d1ddebf1

View File

@ -113,6 +113,17 @@ final_chroot() (
)
#######################################################################
# -P is a pretty neat way to clean junk out from your ports dist-files:
#
# mkdir /freebsd/ports/distfiles.old
# mv /freebsd/ports/distfiles/* /freebsd/ports/distfiles.old
# sh sysbuild.sh -c $yourconfig -P /freebsd/ports/distfiles.old
# rm -rf /freebsd/ports/distfiles.old
#
# Unfortunately bsd.ports.mk does not attempt to use a hard-link so
# while this runs you need diskspace for both your old and your "new"
# distfiles.
#
#######################################################################
usage () {
@ -122,6 +133,7 @@ usage () {
echo " -k suppress buildkernel"
echo " -w suppress buildworld"
echo " -p used cached packages"
echo " -P <dir> prefetch ports"
echo " -c specify config file"
) 1>&2
exit 2
@ -249,12 +261,13 @@ ports_build() (
ports_prefetch() (
(
set +x
true > /mnt/_.prefetch
echo "Building /tmp/_.plist" >> /mnt/_.prefetch
ldir=$1
true > /${ldir}/_.prefetch
echo "Building /tmp/_.plist" >> /${ldir}/_.prefetch
ports_recurse . $PORTS_WE_WANT
echo "Completed /tmp/_.plist" >> /mnt/_.prefetch
echo "Completed /tmp/_.plist" >> /${ldir}/_.prefetch
# Now checksump/fetch them
for p in `cat /tmp/_.plist`
do
@ -262,21 +275,22 @@ ports_prefetch() (
(
cd $p
if make checksum $PORTS_OPTS ; then
rm -f /mnt/_.prefetch.$b
echo "OK $p" >> /mnt/_.prefetch
rm -f /${ldir}/_.prefetch.$b
echo "OK $p" >> /${ldir}/_.prefetch
exit 0
fi
make distclean
make checksum $PORTS_OPTS || true
if make checksum $PORTS_OPTS > /dev/null 2>&1 ; then
rm -f /mnt/_.prefetch.$b
echo "OK $p" >> /mnt/_.prefetch
rm -f /${ldir}/_.prefetch.$b
echo "OK $p" >> /${ldir}/_.prefetch
else
echo "BAD $p" >> /mnt/_.prefetch
echo "BAD $p" >> /${ldir}/_.prefetch
fi
) > /mnt/_.prefetch.$b 2>&1
) > /${ldir}/_.prefetch.$b 2>&1
done
echo "Done" >> /${ldir}/_.prefetch
)
)
@ -284,11 +298,12 @@ ports_prefetch() (
do_world=true
do_kernel=true
do_prefetch=false
use_pkg=""
c_arg=""
set +e
args=`getopt bc:hkpw $*`
args=`getopt bc:hkpP:w $*`
if [ $? -ne 0 ] ; then
usage
fi
@ -325,6 +340,12 @@ do
shift;
use_pkg="-p"
;;
-P)
shift;
do_prefetch=true
distfile_cache=$1
shift;
;;
-w)
shift;
do_world=false
@ -366,6 +387,15 @@ fi
T0=`date +%s`
echo $T0 $T0 > /tmp/_sb_log
if $do_prefetch ; then
rm -rf /tmp/sysbuild/ports
mkdir -p /tmp/sysbuild/ports
ln -s ${distfile_cache} /tmp/sysbuild/ports/distfiles
export PORTS_OPTS=CD_MOUNTPTS=/tmp/sysbuild
ports_prefetch /tmp
exit 0
fi
log_it Unmount everything
(
( cleanup )
@ -446,7 +476,7 @@ log_it copy ports config files
(cd / ; find var/db/ports -print | cpio -dumpv /mnt > /dev/null 2>&1)
log_it "Start prefetch of ports distfiles"
ports_prefetch &
ports_prefetch /mnt &
if $do_world ; then
(
@ -558,13 +588,14 @@ if [ "x$SERCONS" != "xfalse" ] ; then
sed -i "" -e '/^ttyv[0-8]/s/ on/ off/' /mnt/etc/ttys
fi
log_it move config files
log_it move dist config files "(expect warnings)"
(
cd /mnt
mkdir root/configfiles_dist
find ${CONFIGFILES} -print | cpio -dumpv root/configfiles_dist
)
log_it copy live config files
(cd / && find ${CONFIGFILES} -print | cpio -dumpv /mnt)
log_it final_root