pkgsrc/mk/bulk/upload
agc 9a4f22c0ba Make these scripts useful on platforms other than NetBSD by using a BMAKE
environment variable, which contains the name of the make(1) program to
invoke - suggestion by Julien Letessier some time ago, the confusion mine,
since I thought he was referring to something else completely.

Don't rely on there being a POSIX tr(1) in the path by default - test
explicitly for both "yes" and "YES".

Set the default for PRUNEDISTFILES to "no", since we can't assume that
the user wants us to delete something which he may have been keeping
around, and there are other ways of accomplishing this aim (lintpkgsrc
-o, for example).

Clean up some superfluous white space at the end of lines.
2002-08-07 10:56:11 +00:00

123 lines
3.3 KiB
Bash

#!/bin/sh
#
# Upload non-restricted binary pkgs to ftp server
# Must be called in /usr/pkgsrc
#
opsys=`uname -s`
case "$opsys" in
NetBSD) BMAKE=make ;;
*) BMAKE=bmake ;;
esac
export BMAKE
# Pull in RSYNC_DST, RSYNC_OPTS:
if [ -f "$BULK_BUILD_CONF" ]; then
. $BULK_BUILD_CONF
else
. `dirname $0`/build.conf
fi
if [ -z "$RSYNC_DST_SPECIFIC" -o -z "$RSYNC_DST_OTHER" ]; then
echo "You must set the variables RSYNC_DST_SPECIFIC and RSYNC_DST_OTHER"
echo " "
echo "RSYNC_DST_SPECIFIC should be set to the destination for packages"
echo "which have the OSVERSION_SPECIFIC flag set. I.e., the complete OS"
echo "version number is required. For example:"
echo " user@ftp.netbsd.org:/pub/NetBSD/packages/1.5.1/alpha"
echo " "
echo "RSYNC_DST_OTHER should be set to the destination for packages"
echo "which do _not_ have the OSVERSION_SPECIFIC flag set. I.e., only"
echo "the major.minor release string is used. For example, on a 1.5.1"
echo "alpha system you would use:"
echo " user@ftp.netbsd.org:/pub/NetBSD/packages/1.5/alpha"
echo " "
exit 1
fi
#
# Some temp files
#
umask 22
TMPDIR=${TMPDIR:-/tmp}
TMP=${TMPDIR}/pkg_upload.$$
mkdir $TMP
exf=$TMP/exclude
osf=$TMP/osversion_specific
upload=$TMP/upload
upload_specific=$TMP/upload_specific
upload_others=$TMP/upload_others
# May be different than $USR_PKGSRC:
pkgsrcdir=`cd pkgtools/pkglint ; ${BMAKE} show-var VARNAME=_PKGSRCDIR`
packages=`cd pkgtools/pkglint ; ${BMAKE} show-var VARNAME=PACKAGES`
# Pull in some pkgs needed
( cd pkgtools/pkglint ; ${BMAKE} bulk-install )
( cd net/rsync ; ${BMAKE} bulk-install )
echo "Checking for restricted, out of date, and vulnerable packages:"
# -p = report old versions of packages
# -R = report restricted packages
# -V = report vulnerable packages
lintpkgsrc -P $pkgsrcdir -pRV | sed 's@'$packages'/@@' > $exf
echo "Checking for OSVERSION_SPECIFIC pkgs:"
lintpkgsrc -P $pkgsrcdir -O | sed 's@'$packages'/@@' > $osf
RSFLAGS="-vap --progress $RSYNC_OPTS"
failed=no
cd $packages
echo "#!/bin/sh" > $upload
echo "packages=$packages" >> $upload
echo "if ! cd $packages ; then" >> $upload
echo " echo \"could not cd to $packages\"" >> $upload
echo " exit 1" >> $upload
echo "fi" >> $upload
echo "Uploading OSVERSION_SPECIFIC pkgs"
cmd="rsync $RSFLAGS --include '*/' --exclude-from=$exf --include-from=$osf \
--exclude '*' . $RSYNC_DST_SPECIFIC"
cp -f $upload $upload_specific
echo $cmd >> $upload_specific
chmod 755 $upload_specific
echo $cmd
. $upload_specific
if [ $? != 0 ]; then
echo "--------------------------------------------------"
echo " "
echo "WARNING rsync failed. To retry later, you can run"
echo " $upload_specific"
echo " "
echo "--------------------------------------------------"
failed=yes
fi
echo "Uploading non-OSVERSION_SPECIFIC pkgs"
cmd="rsync $RSFLAGS --exclude-from=$exf --exclude-from=$osf . $RSYNC_DST_OTHER"
cp -f $upload $upload_others
echo $cmd >> $upload_others
chmod 755 $upload_others
echo $cmd
. $upload_others
if [ $? != 0 ]; then
echo "--------------------------------------------------"
echo " "
echo "WARNING rsync failed. To retry later, you can run"
echo " $upload_others"
echo " "
echo "--------------------------------------------------"
failed=yes
fi
# clean up temp files
if [ "$failed" = "no" ]; then
rm -fr $TMP
fi