summaryrefslogtreecommitdiffstats
path: root/usr.sbin/portsnap
diff options
context:
space:
mode:
authorcperciva <cperciva@FreeBSD.org>2005-09-06 19:28:37 +0000
committercperciva <cperciva@FreeBSD.org>2005-09-06 19:28:37 +0000
commit4c165daa8dfedaee3ceb48cb97ff9fbabab36789 (patch)
treea0110cc2a46beca2d1dea305b40b4a086f1f76f5 /usr.sbin/portsnap
parenta3b63345a1492651280e290af1213bb3bd49c124 (diff)
downloadFreeBSD-src-4c165daa8dfedaee3ceb48cb97ff9fbabab36789.zip
FreeBSD-src-4c165daa8dfedaee3ceb48cb97ff9fbabab36789.tar.gz
Teach portsnap how to ignore unwanted parts of the ports tree. A line
of the form "REFUSE foo" in portsnap.conf will result in parts of the tree matching "^foo" being (a) not extracted by "portsnap extract", (b) not updated by "portsnap update", and (c) not having any patches or new ports downloaded by "portsnap fetch" or "portsnap cron". The example shown in portsnap.conf demonstrates ignoring all the language categories. As mentioned in portsnap.conf.5, the use of an imcomplete ports tree is not officially supported; but this is something which many users have requested, so I'm adding it anyway. PR: bin/85619 (but not the patch provided therein) MFC after: 1 month
Diffstat (limited to 'usr.sbin/portsnap')
-rw-r--r--usr.sbin/portsnap/portsnap/portsnap.sh72
1 files changed, 66 insertions, 6 deletions
diff --git a/usr.sbin/portsnap/portsnap/portsnap.sh b/usr.sbin/portsnap/portsnap/portsnap.sh
index 38098e7..de263f0 100644
--- a/usr.sbin/portsnap/portsnap/portsnap.sh
+++ b/usr.sbin/portsnap/portsnap/portsnap.sh
@@ -81,6 +81,7 @@ init_params() {
DDSTATS=""
INDEXONLY=""
SERVERNAME=""
+ REFUSE=""
}
# Parse the command line
@@ -173,6 +174,8 @@ default_conffile() {
# Read {KEYPRINT, SERVERNAME, WORKDIR, PORTSDIR} from the configuration
# file if they haven't already been set. If the configuration
# file doesn't exist, do nothing.
+# Also read REFUSE (which cannot be set via the command line) if it is
+# present in the configuration file.
parse_conffile() {
if [ -r "${CONFFILE}" ]; then
for X in KEYPRINT WORKDIR PORTSDIR SERVERNAME; do
@@ -182,6 +185,13 @@ parse_conffile() {
cut -f 2- -d '=' | tail -1`
fi
done
+
+ if grep -qE "^REFUSE[[:space:]]" ${CONFFILE}; then
+ REFUSE="^(`
+ grep -E "^REFUSE[[:space:]]" "${CONFFILE}" |
+ cut -c 7- | xargs echo | tr ' ' '|'
+ `)"
+ fi
fi
}
@@ -668,6 +678,21 @@ fetch_update() {
cut -f 2 -d '|'`.gz > INDEX.new
fetch_index_sanity || return 1
+# If we have decided to refuse certain updates, construct a hybrid index which
+# is equal to the old index for parts of the tree which we don't want to
+# update, and equal to the new index for parts of the tree which gets updates.
+# This means that we should always have a "complete snapshot" of the ports
+# tree -- with the caveat that it isn't actually a snapshot.
+ if [ ! -z "${REFUSE}" ]; then
+ echo "Refusing to download updates for ${REFUSE}" \
+ >${QUIETREDIR}
+
+ grep -Ev "${REFUSE}" INDEX.new > INDEX.tmp
+ grep -E "${REFUSE}" INDEX |
+ sort -m -k 1,1 -t '|' - INDEX.tmp > INDEX.new
+ rm -f INDEX.tmp
+ fi
+
# Generate a list of wanted ports patches
join -t '|' -o 1.2,2.2 INDEX INDEX.new |
fetch_make_patchlist > patchlist
@@ -761,14 +786,34 @@ extract_indices() {
echo "done."
}
-# Create .portsnap.INDEX
+# Create .portsnap.INDEX; if we are REFUSEing to touch certain directories,
+# merge the values from any exiting .portsnap.INDEX file.
extract_metadata() {
- sort ${WORKDIR}/INDEX > ${PORTSDIR}/.portsnap.INDEX
+ if [ -z "${REFUSE}" ]; then
+ sort ${WORKDIR}/INDEX > ${PORTDIR}/.portsnap.INDEX
+ elif [ -f ${PORTSDIR}/.portsnap.INDEX ]; then
+ grep -E "${REFUSE}" ${PORTSDIR}/.portsnap.INDEX \
+ > ${PORTSDIR}/.portsnap.INDEX.tmp
+ grep -vE "${REFUSE}" ${WORKDIR}/INDEX | sort |
+ sort -m - ${PORTSDIR}/.portsnap.INDEX.tmp \
+ > ${PORTSDIR}/.portsnap.INDEX
+ rm -f ${PORTSDIR}/.portsnap.INDEX.tmp
+ else
+ grep -vE "${REFUSE}" ${WORKDIR}/INDEX | sort \
+ > ${PORTSDIR}/.portsnap.INDEX
+ fi
}
# Do the actual work involved in "extract"
extract_run() {
- if ! grep "^${EXTRACTPATH}" ${WORKDIR}/INDEX | while read LINE; do
+ if !
+ if ! [ -z "${EXTRACTPATH}" ]; then
+ grep "^${EXTRACTPATH}" ${WORKDIR}/INDEX
+ elif ! [ -z "${REFUSE}" ]; then
+ grep -vE "${REFUSE}" ${WORKDIR}/INDEX
+ else
+ cat ${WORKDIR}/INDEX
+ fi | while read LINE; do
FILE=`echo ${LINE} | cut -f 1 -d '|'`
HASH=`echo ${LINE} | cut -f 2 -d '|'`
echo ${PORTSDIR}/${FILE}
@@ -813,14 +858,29 @@ update_run() {
return 0
fi
+# If we are REFUSEing to touch certain directories, don't remove files
+# from those directories (even if they are out of date)
echo -n "Removing old files and directories... "
- sort ${WORKDIR}/INDEX | comm -23 ${PORTSDIR}/.portsnap.INDEX - |
- cut -f 1 -d '|' | lam -s "${PORTSDIR}/" - | xargs rm -rf
+ if ! [ -z "${REFUSE}" ]; then
+ sort ${WORKDIR}/INDEX |
+ comm -23 ${PORTSDIR}/.portsnap.INDEX - | cut -f 1 -d '|' |
+ grep -vE "${REFUSE}" |
+ lam -s "${PORTSDIR}/" - | xargs rm -rf
+ else
+ sort ${WORKDIR}/INDEX |
+ comm -23 ${PORTSDIR}/.portsnap.INDEX - | cut -f 1 -d '|' |
+ lam -s "${PORTSDIR}/" - | xargs rm -rf
+ fi
echo "done."
# Install new files
echo "Extracting new files:"
- if ! sort ${WORKDIR}/INDEX |
+ if !
+ if ! [ -z "${REFUSE}" ]; then
+ grep -vE "${REFUSE}" ${WORKDIR}/INDEX | sort
+ else
+ sort ${WORKDIR}/INDEX
+ fi |
comm -13 ${PORTSDIR}/.portsnap.INDEX - |
while read LINE; do
FILE=`echo ${LINE} | cut -f 1 -d '|'`
OpenPOWER on IntegriCloud