#!/bin/sh
# ============================================================================ #
# managepkg #
# Version 1.1 (27.6.03) #
# erweiterte Version des Skripts mit Unterstützung für FreeBSD 5.1 #
# ============================================================================ #
# Hinweis:
# --------
# Bei FreeBSD 5 wurde das Portsverzeichnis dahingehend geändert, daß jetzt
# einige (interne) Hinweisdateien entfallen bzw. umbenannt wurden. Es entfällt
# die Datei pkg-comment, die einzeiligen Kommentare zu den Ports befinden sich,
# wie bereits in NetBSD, in der Make-Datei im Feld COMMENT.
# Diese Version des Skripts trägt dem Rechnung.
#
#
if [ -z ${PORTSDIR} ] ; then
PORTSDIR=/usr/ports
fi
Help() {
echo ""
echo "Help on `basename ${0} version 1.1:`"
echo "Parameters:"
echo " (without params) : Runs \"make\" in all directories."
echo " command : runs \"make command\" in all directories."
echo " command dir : run \"make command\ in the sub tree \"dir\"."
echo " -h[elp]|-HELP : Shows this help screen."
echo " package-recursive: Packages all already build ports."
echo ""
echo -n "Press Enter to continue ..."
read dummy
echo ""
echo "Help on `basename ${0} version 1.1:`"
echo ""
echo "This script runs though the complete ports tree without stopping after a make"
echo "error occured."
echo "If you call make with any parameter in one of the directories of the ports tree"
echo "in FreeBSD the run will stop if make returns with a code bigger than zero. That"
echo "means, that it is (in opposite to NetBSD or OpenBSD) impossible to run a "
echo "complete build with \"make\" in FreeBSD."
echo "This script works in a different way. It calls make for all found subdirectories"
echo "with a file \"Makefile\". That means, it only will stop when the job is done or"
echo "you pressed ^C while the script runs."
echo "Warning: The run of the script may last days (but you may stop it any time)."
echo "Call the script with the parameter you want to give to make, for instance fetch,"
echo "build, install, or package."
echo "It is not possible to tell the script further environment parameters, for"
echo "instance NO_CHECKSUM=YES or A4=YES".
echo "Define these parameters in the environment before running the script. Use"
echo "\"export=VARIABLE=value\" if you use ksh*, sh or bash or use"
echo "\"setenv VARIABLE value\" if you use csh or tcsh."
echo ""
echo "And feel free to modify this script if you need additional features."
echo ""
}
ReadComment() {
# This function is modified in Version 1.1 for FreeBSD 5.1
if [ -f pkg-comment ] ; then
# FreeBSD up to 5.0 / 4.8 or an older ports tree is used in FreeBSD 5.1
cat pkg-comment
else
# FreeBSD 5.1 and up or a newer ports tree is used in an older os version.
tstvar=`grep "COMMENT=" Makefile | cut -f 2,2`
if [ "$tstvar" = "" ] ; then
echo "No package comment available."
else
echo $tstvar
fi
fi
}
Line() {
echo "-------------------------------------------------------------------------------"
}
case ${1} in
-[Hh][Ee][Ll][pP])
Help
exit 0
;;
--[Hh][Ee][Ll][pP])
Help
exit 0
;;
[Hh][Ee][Ll][pP])
Help
exit 0
;;
--[Hh])
Help
exit 0
;;
-[Hh])
Help
exit 0
;;
esac
#
# Stop on command line errors:
#
if [ -d ${PORTSDIR}/${1} ] ; then
echo ""
echo "`basename ${0}` -- command line error!"
echo ""
echo "You must enter the make parameter FIRST, the directory name _must_ be the"
echo "second parameter (or left out if you want to run over the complete tree)."
echo "You cannot work through a part of the tree without defining the working"
echo "parameter for \"make\". If you want to run a parameter less normal \"make\""
echo "use \"make build\" which means the same."
echo ""
exit 1
fi
# --------------------------------------------------------------------------- #
# Begin working:
#
if [ "$1" = "package-recursive" ] ; then
if [ ! -d ${PORTSDIR}/packages ] ; then
mkdir ${PORTSDIR}/packages
fi
# This implements the unavailable recursive packaging of all available
# Ports.
echo ""
echo "Building all possible packages in the ports tree where working directories"
echo "exist. The completed directories will afterwards be cleaned".
echo ""
echo "Pass 1: Packaging ..."
for p in `find ${PORTSDIR} -mindepth 3 -maxdepth 3 -type d | grep /work$`
do
cd ${p}/..
echo "Found `pwd`, packaging the files for:"
ReadComment
make package
done
# We clean the directories via "rm work/". Make clean cleans the dependend
# directories, too. That's really nonsense and lasts a very long time.
# This is better solved in NetBSD. FreeBSD ports have serveral inconstencies
# this is one of them.
# I do not understand why clean works recursive and package does not!!
echo "Pass 2: Cleaning ..."
for p in `find ${PORTSDIR} -mindepth 3 -maxdepth 3 -type d | grep /work$`
do
cd ${p}/..
echo "Found `pwd` ..."
if [ -f work/.package_done.* ] ; then
echo "... cleaning it ..."
rm -r work
else
echo " ... will not be cleaned. No package was built, yet!"
fi
done
else
# No second parameter, that means, that the script runs over the whole
# ports tree. That lasts long but is very efficent for the initial run
if [ "$2" = "" ] ; then
if [ "$1" = "" ] ; then
# No parameter at all. The run a "make" throughout all. That will last
# dependend on the hardware several days or longer ....
echo "Trying to \"make\" for all ports directories ..."
else
echo "Trying to \"make ${1}\" for all ports directories ..."
fi
else
echo "Trying to \"make ${1}\" for the ${2} directories ..."
fi
if [ "$2" = "" ] ; then
# No second parameter. Run through the whole tree, processing the
# first command line parameter
for p in `find ${PORTSDIR} -mindepth 3 -maxdepth 3 -type f | grep Makefile$`
do
cd `dirname ${p}`
echo "Processing \"make ${1}\" in `pwd` for:"
ReadComment
make $1
Line
done
else
# It is possible to work only in a part of the tree. Senseful for x11 ...
# otherwise the script begins always with "archivers".
if [ ! -d ${PORTSDIR}/${2} ] ; then
echo "Error: Directory \"${2}\" does not exist! Exiting."
exit 1
else
for p in `find ${PORTSDIR}/${2} -mindepth 2 -maxdepth 2 -type f | grep Makefile$`
do
cd `dirname ${p}`
echo "Processing make ${1} in `pwd` for:"
ReadComment
make $1
Line
done
fi
fi
fi
#!/bin/sh
# ============================================================================ #
# managepkg #
# Version 1.1 (27.6.03) #
# erweiterte Version des Skripts mit Unterstützung für FreeBSD 5.1 #
# ============================================================================ #
# Hinweis:
# --------
# Bei FreeBSD 5 wurde das Portsverzeichnis dahingehend geändert, daß jetzt
# einige (interne) Hinweisdateien entfallen bzw. umbenannt wurden. Es entfällt
# die Datei pkg-comment, die einzeiligen Kommentare zu den Ports befinden sich,
# wie bereits in NetBSD, in der Make-Datei im Feld COMMENT.
# Diese Version des Skripts trägt dem Rechnung.
#
#
if [ -z ${PORTSDIR} ] ; then
PORTSDIR=/usr/ports
fi
Help() {
echo ""
echo "Help on `basename ${0} version 1.1:`"
echo "Parameters:"
echo " (without params) : Runs \"make\" in all directories."
echo " command : runs \"make command\" in all directories."
echo " command dir : run \"make command\ in the sub tree \"dir\"."
echo " -h[elp]|-HELP : Shows this help screen."
echo " package-recursive: Packages all already build ports."
echo ""
echo -n "Press Enter to continue ..."
read dummy
echo ""
echo "Help on `basename ${0} version 1.1:`"
echo ""
echo "This script runs though the complete ports tree without stopping after a make"
echo "error occured."
echo "If you call make with any parameter in one of the directories of the ports tree"
echo "in FreeBSD the run will stop if make returns with a code bigger than zero. That"
echo "means, that it is (in opposite to NetBSD or OpenBSD) impossible to run a "
echo "complete build with \"make\" in FreeBSD."
echo "This script works in a different way. It calls make for all found subdirectories"
echo "with a file \"Makefile\". That means, it only will stop when the job is done or"
echo "you pressed ^C while the script runs."
echo "Warning: The run of the script may last days (but you may stop it any time)."
echo "Call the script with the parameter you want to give to make, for instance fetch,"
echo "build, install, or package."
echo "It is not possible to tell the script further environment parameters, for"
echo "instance NO_CHECKSUM=YES or A4=YES".
echo "Define these parameters in the environment before running the script. Use"
echo "\"export=VARIABLE=value\" if you use ksh*, sh or bash or use"
echo "\"setenv VARIABLE value\" if you use csh or tcsh."
echo ""
echo "And feel free to modify this script if you need additional features."
echo ""
}
ReadComment() {
# This function is modified in Version 1.1 for FreeBSD 5.1
if [ -f pkg-comment ] ; then
# FreeBSD up to 5.0 / 4.8 or an older ports tree is used in FreeBSD 5.1
cat pkg-comment
else
# FreeBSD 5.1 and up or a newer ports tree is used in an older os version.
tstvar=`grep "COMMENT=" Makefile | cut -f 2,2`
if [ "$tstvar" = "" ] ; then
echo "No package comment available."
else
echo $tstvar
fi
fi
}
Line() {
echo "-------------------------------------------------------------------------------"
}
case ${1} in
-[Hh][Ee][Ll][pP])
Help
exit 0
;;
--[Hh][Ee][Ll][pP])
Help
exit 0
;;
[Hh][Ee][Ll][pP])
Help
exit 0
;;
--[Hh])
Help
exit 0
;;
-[Hh])
Help
exit 0
;;
esac
#
# Stop on command line errors:
#
if [ -d ${PORTSDIR}/${1} ] ; then
echo ""
echo "`basename ${0}` -- command line error!"
echo ""
echo "You must enter the make parameter FIRST, the directory name _must_ be the"
echo "second parameter (or left out if you want to run over the complete tree)."
echo "You cannot work through a part of the tree without defining the working"
echo "parameter for \"make\". If you want to run a parameter less normal \"make\""
echo "use \"make build\" which means the same."
echo ""
exit 1
fi
# --------------------------------------------------------------------------- #
# Begin working:
#
if [ "$1" = "package-recursive" ] ; then
if [ ! -d ${PORTSDIR}/packages ] ; then
mkdir ${PORTSDIR}/packages
fi
# This implements the unavailable recursive packaging of all available
# Ports.
echo ""
echo "Building all possible packages in the ports tree where working directories"
echo "exist. The completed directories will afterwards be cleaned".
echo ""
echo "Pass 1: Packaging ..."
for p in `find ${PORTSDIR} -mindepth 3 -maxdepth 3 -type d | grep /work$`
do
cd ${p}/..
echo "Found `pwd`, packaging the files for:"
ReadComment
make package
done
# We clean the directories via "rm work/". Make clean cleans the dependend
# directories, too. That's really nonsense and lasts a very long time.
# This is better solved in NetBSD. FreeBSD ports have serveral inconstencies
# this is one of them.
# I do not understand why clean works recursive and package does not!!
echo "Pass 2: Cleaning ..."
for p in `find ${PORTSDIR} -mindepth 3 -maxdepth 3 -type d | grep /work$`
do
cd ${p}/..
echo "Found `pwd` ..."
if [ -f work/.package_done.* ] ; then
echo "... cleaning it ..."
rm -r work
else
echo " ... will not be cleaned. No package was built, yet!"
fi
done
else
# No second parameter, that means, that the script runs over the whole
# ports tree. That lasts long but is very efficent for the initial run
if [ "$2" = "" ] ; then
if [ "$1" = "" ] ; then
# No parameter at all. The run a "make" throughout all. That will last
# dependend on the hardware several days or longer ....
echo "Trying to \"make\" for all ports directories ..."
else
echo "Trying to \"make ${1}\" for all ports directories ..."
fi
else
echo "Trying to \"make ${1}\" for the ${2} directories ..."
fi
if [ "$2" = "" ] ; then
# No second parameter. Run through the whole tree, processing the
# first command line parameter
for p in `find ${PORTSDIR} -mindepth 3 -maxdepth 3 -type f | grep Makefile$`
do
cd `dirname ${p}`
echo "Processing \"make ${1}\" in `pwd` for:"
ReadComment
make $1
Line
done
else
# It is possible to work only in a part of the tree. Senseful for x11 ...
# otherwise the script begins always with "archivers".
if [ ! -d ${PORTSDIR}/${2} ] ; then
echo "Error: Directory \"${2}\" does not exist! Exiting."
exit 1
else
for p in `find ${PORTSDIR}/${2} -mindepth 2 -maxdepth 2 -type f | grep Makefile$`
do
cd `dirname ${p}`
echo "Processing make ${1} in `pwd` for:"
ReadComment
make $1
Line
done
fi
fi
fi
syntax highlighted by Code2HTML, v. 0.9.1