Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

87 lines (74 sloc) 2.74 kB
#!/bin/bash
# #
# prune.lunar - Lunar prune code #
# #
############################################################
# #
# Copyright 2003 by Auke Kok under GPLv2under GPLv2 #
# #
############################################################
# function : prune
# usage : prune
# purpose : prune all old logs, source copy's, install caches
prune() {
local TMP_SPOOL_KEEP TMP_CACHE_KEEP MODULE SOURCE VERSION FILE LOGS
debug_msg "prune ($@)"
if [ -z "$BUILD" ] ; then
eval $(grep BUILD= /etc/lunar/local/optimizations)
fi
TMP_SPOOL_KEEP=$(temp_create "spool-keep")
TMP_CACHE_KEEP=$(temp_create "cache-keep")
message "${MESSAGE_COLOR}Generating keep lists...${DEFAULT_COLOR}"
for MODULE in $(list_installed) ; do
# spool:
if [ ! "$MODULE" == "moonbase" ]; then
for SOURCE in $(sources $MODULE) ; do
echo $SOURCE >> $TMP_SPOOL_KEEP
done
# cache:
VERSION=$(installed_version $MODULE)
echo "$MODULE-$VERSION-$BUILD.tar.bz2" >> $TMP_CACHE_KEEP
fi
done
echo "README" >> $TMP_SPOOL_KEEP
echo "cpan" >> $TMP_SPOOL_KEEP
verbose_msg "finding stale source files"
for FILE in $(ls -1 $SOURCE_CACHE); do
if ! grep -q "$FILE" "$TMP_SPOOL_KEEP" ; then
message "Removing stale source: $SOURCE_CACHE/$FILE"
rm -f $SOURCE_CACHE/$FILE
fi
done
temp_destroy $TMP_SPOOL_KEEP
verbose_msg "finding stale install caches"
for FILE in $(ls -1 $INSTALL_CACHE); do
if ! grep -q "$FILE" "$TMP_CACHE_KEEP" ; then
message "Removing stale install cache: $INSTALL_CACHE/$FILE"
rm -f $INSTALL_CACHE/$FILE
fi
done
temp_destroy $TMP_CACHE_KEEP
# the log files are easy:
LOGS=$(cat "$MODULE_STATUS" | cut -d: -f1,4 --output-delimiter="-")
verbose_msg "finding stale install logs"
for FILE in $(ls -1 $INSTALL_LOGS) ; do
if ! echo -e "$LOGS" | grep -q $FILE ; then
message "Removing stale log: $INSTALL_LOGS/$FILE"
rm $INSTALL_LOGS/$FILE
fi
done
verbose_msg "finding stale compile logs"
for FILE in $(ls -1 $COMPILE_LOGS | sed "s/\.bz2//") ; do
if ! echo -e "$LOGS" | grep -q $FILE ; then
message "Removing stale log: $COMPILE_LOGS/$FILE.bz2"
rm $COMPILE_LOGS/$FILE.bz2
fi
done
verbose_msg "finding stale md5sum logs"
for FILE in $(ls -1 $MD5SUM_LOGS) ; do
if ! echo -e "$LOGS" | grep -q $FILE ; then
message "Removing stale log: $MD5SUM_LOGS/$FILE"
rm $MD5SUM_LOGS/$FILE
fi
done
}
Jump to Line
Something went wrong with that request. Please try again.