Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
DISTVIPER(1) FreeBSD General Commands Manual DISTVIPER(1)
NAME
distviper — wipe outdated files from the FreeBSD ports distdir
SYNOPSIS
distviper [−dhiqv] [mode]
DESCRIPTION
The distviper script removes outdated files in %%DISTDIR%%. To achieve
this it reads all files named distinfo from %%PORTSDIR%% and creates a
list of files to keep if they should be encountered. Every file not in
this list is deleted.
The creation of the list of files to keep can take very long, if the
ports tree is not cached in memory. Because of this there is a fast mode
that will only use distinfo files from installed ports.
OPTIONS
The following options are available:
−d −−demo
The program is run in demo mode. The program acts as if it would
operate normally, but does not remove any files.
−h −−help
Displays the available options.
−i −−interactvie
This option prompts for confirmation before deleting a file. It
is ignored in demo mode.
−q −−quiet
Supresses delete messages.
−v −−verbose
Makes the script talkative about what is currently going on.
mode There are currently two modes available. By default the thorough
mode is selected, which scans all distinfo files. The fast mode
only scans distinfo files for installed ports.
NOTES
The fast mode is often sufficient. There are two cases when this does not
apply.
If one intends to keep distfiles for ports that are not currently
installed, like on a dedicated build machine, the (default) thorough mode
is the mode of choice.
The other case is, when a port fetches its files by having a dependency
on the fetch target of another port and this other port is not installed.
This is a very rare case, though.
EXAMPLES
To run the script in thorough mode use the following command line.
distviper
The demo mode can be used to check which files would be removed in fast
mode.
distviper ‐d fast
To be prompted for confirmation and using fast mode the following line
can be used.
distviper ‐i fast
EXIT CODES
1 An unknown parameter has been supplied.
2 An unknown mode command has been supplied.
3 More than one mode commands have been supplied.
COMPATIBILITY
The script has been tested on FreeBSD 7.1‐STABLE
SEE ALSO
bsdadminscripts(1)
HISTORY
The distviper script first appeared in the bsdadminscripts‐5.0 collec‐
tion.
AUTHOR
Dominic Fandrey <kamikaze@bsdforen.de>
FreeBSD 7.1 January 27, 2009 FreeBSD 7.1
#!/bin/sh
#
# Copyright (c) 2009
# Dominic Fandrey <kamikaze@bsdforen.de>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
version=0.99
name=distviper
verbose=
demo=
quiet=
interactive=
# Determine portsdir
portsdir=$(make -V PORTSDIR -f /usr/share/mk/bsd.port.mk)
if [ ! -d $portsdir ]; then
echo "The PORTSDIR '$portsdir' is missing."
exit 1
fi
# Determine distdir
distdir=$(make -V DISTDIR -f /usr/share/mk/bsd.port.mk)
if [ ! -d $portsdir ]; then
echo "The DISTDIR '$distdir' is missing."
exit 2
fi
# Extract file from distinfo.
extractFileCmd="sed -E -e 's/^[^(]*\(//1' -e 's/\)[^)]*$//1'"
# Display help.
printHelp() {
echo "$name v$version
usage: $name [-d] [-h] [-i] [-q] [-v] [fast|thorough]"
}
#
# Handle parameters.
#
# @param $1
# The parameter to handle.
# @param $verbose
# Is set to create verbose output.
# @param $demo
# Is set to only print the output that would occur.
# @param $quiet
# Is set to act without creating any output.
# @return
# Returns 0 if the processed parameter was a valid parameter,
# returns 1 if not.
#
readParams() {
case "$1" in
"-d" | "--demo")
demo=1
return 0
;;
"-h" | "--help")
printHelp
return 0
;;
"-i" | "--interactive")
interactive=-i
return 0
;;
"-q" | "--quiet")
quiet=1
return 0
;;
"-v" | "--verbose")
verbose=1
return 0
;;
-? | --*)
return 1
;;
-*)
# Split parameters.
# first parameter
readParams "${1%${1#-?}}" || return $?
# remaining parameters
readParams "-${1#-?}" || return $?
;;
*)
return 1
;;
esac
}
#
# This algorithm outputs the distfiles of installed ports. If a port downloads
# a distfile through depending on the fetch target of another port, it
# is missed, in case that other port is not installed as well.
#
# @param $portsdir
# The direcotry holding the ports tree.
#
getDistFiles_fast() {
for port in $(pkg_info -qoa); {
if [ -e "$portsdir/$port/distinfo" ]; then
eval "$extractFileCmd '$portsdir/$port/distinfo'" | uniq
fi
}
}
#
# This algorithm outputs the distfiles of all ports.
#
# @param $portsdir
# The direcotry holding the ports tree.
#
getDistFiles_thorough() {
find "$portsdir" -type f -name distinfo | \
eval "xargs $extractFileCmd" | uniq
}
# The current parameter processing stage.
stage=params
# The selected algorithm for finding distfiles to keep.
algorithm=thorough
# Parse the command line parameters.
for command; {
# Read parameters until an unknown one is encountered.
# In that case switch into command stage.
if [ "$stage" = "params" ]; then
if ! readParams "$command"; then
stage=command
fi
fi
# All parameters have been read, now either nothing or a mode
# command should occur.
if [ "$stage" = "command" ]; then
stage=end
case "$command" in
thorough | fast)
algorithm="$command"
;;
-*)
echo "$name: Unknown parameter '$command'" \
"encountered, exiting." 1>&2
return 1
;;
*)
echo "$name: Unknown command '$command'" \
"encountered, exiting." 1>&2
return 2
;;
esac
# Skip everything following and continue with the next
# argument.
continue
fi
# Still being in the loop at this stage means unexpected parameters
# have been encountered.
if [ "$stage" = "end" ]; then
echo "$name: The command '$command' is not allowed here, only" \
"one command at a time is permitted." 1>&2
return 3
fi
}
# Check for inprobable options.
if [ -n "$interactive" -a -n "$demo" ]; then
echo "$name: Interactive mode is ignored in demo mode." 1>&2
fi
test -n "$verbose" && echo "Create a list of up to distfiles to keep using a" \
"$algorithm algorithm:"
# Create the list of files to keep, using the selected algorithm.
keepFiles="$(eval "getDistFiles_$algorithm")"
if [ -n "$verbose" ]; then
echo "$(($(echo "$keepFiles" | wc -l))) files recorded for keeping."
echo "Search and delete outdated distfiles:"
fi
# A counter for deleted files.
deleted=0
# Seek and destroy files not in the $keepFiles list.
for file in $(find "$distdir" -type f); {
file="${file#$distdir/}"
if (echo "$keepFiles" | grep -qx "$file"); then
test -n "$verbose" && echo "keep $file"
else
test -z "$quiet" && echo "delete $file"
test -z "$demo" && rm $interactive "$distdir/$file"
deleted=$(($deleted + 1))
fi
}
test -z "$demo" && find -d "$distdir" -type d -exec rmdir \{} \; 2> /dev/null
test -n "$verbose" && echo "$deleted files have been removed."
Ich habe mich jetzt auf distviper festgelegt, das hat's mir einfach angetan.
So, jetzt ist Beta-Zeit. Wer das Ding testen will weiß hoffentlich was damit anzufangen ist:
pit@syo ~/bsd7:-> sh distviper fast
delete xorg/lib/libXfont-1.3.1.tar.bz2
override rw-r--r-- root/wheel for /usr/ports/distfiles/xorg/lib/libXfont-1.3.1.tar.bz2?
#"are we root?"
whoami=$(whoami)
if [ $whoami != "root" ]
then
echo "we are not root!"
exit 0
fi
test -n "$verbose" && echo "$(($(echo "$keepFiles" | wc -l))) files recorded for keeping."
Irgendwie fehlt mir folgende Funktion:
Von allen installierten Ports das neuste Distfile behalten, den Rest löschen. Oder anders formuliert: Alte Versionen von Distfiles und Distfiles von nicht installierten Ports löschen.
# distviper fastIrgendwie fehlt mir folgende Funktion:
Von allen installierten Ports das neuste Distfile behalten, den Rest löschen. Oder anders formuliert: Alte Versionen von Distfiles und Distfiles von nicht installierten Ports löschen.
Dies würde aber Distfiles von nicht installierten Ports nicht löschen, oder?# distviper fast
Mindestens verstehe ich obige Aussage so.Because of this there is a fast mode that will only use distinfo files from installed ports.
Stimmt, das wäre eine Variante. Es ging mir aber primär um eine Rückfrage/Feedback zu distviper.#portsclean -DP
Du reißt die Aussage aus dem Kontext. distviper erstellt eine Liste von Dateien die es behält. Im fast Modus wird dazu nur die distinfo installierter Ports verwendet, also werden die distfiles von nicht installierten Ports gelöscht.Dies würde aber Distfiles von nicht installierten Ports nicht löschen, oder?
Kann es zur Zeit nicht ausprobieren.
# Determine portsdir
portsdir=$(make -V PORTSDIR -f /usr/share/mk/bsd.port.mk)
if [ ! -d $portsdir ]; then
echo "The PORTSDIR '$portsdir' is missing."
exit 1
fi
# Determine distdir
[COLOR="Red"]distdir[/COLOR]=$(make -V DISTDIR -f /usr/share/mk/bsd.port.mk)
if [ ! -d [COLOR="Red"]$portsdir[/COLOR] ]; then
echo "The DISTDIR '$distdir' is missing."
exit 2
fi
extractFileCmd="sed -E -e 's/^[^(]*\(//1' -e 's/\)[^)]*$//1'"
# Determine distdir
[COLOR="SeaGreen"]distdir[/COLOR]=$(make -V DISTDIR -f /usr/share/mk/bsd.port.mk)
if [ ! -d [COLOR="#2e8b57"]$distdir[/COLOR] ]; then
echo "The DISTDIR '$distdir' is missing."
exit 2
fi
sed -E -e 's/^[^(]*\(//1' -e 's/\)[^)]*$//1'
Wir verwenden essentielle Cookies, damit diese Website funktioniert, und optionale Cookies, um den Komfort bei der Nutzung zu verbessern.
Siehe weitere Informationen und konfiguriere deine Einstellungen