makedist/obsoleted/update.sh

163 lines
4.9 KiB
Bash
Raw Permalink Normal View History

2011-05-04 02:30:35 +02:00
#
# update.sh - Updates QiLinux sources
#
# Copyright (c) 2005-2007 by Silvan Calarco <silvan.calarco@mambasoft.it>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
. ./VERSION
. ./functions.inc.sh
. ./defs.inc.sh
tmpfile=`mktemp -q -t ${0##*/}.XXXXXXXX` ||
{ echo "${0##*/}: error: cannot create temporary files." >&2
{ (exit 1); exit 1; }; }
trap "rm -f $tmpfile" 0 1 2 5 15
copyleft="\
makedist boot CD creator (version $makedist_version)
Copyright (c) 2003-2007 by Silvan Calarco <silvan.calarco@mambasoft.it>
Copyright (c) 2003-2005 by Davide Madrisan <davide.madrisan@qilinux.it>
"
unset branch # can be 'stable', 'unstable', or 'devel'
makedist_me="${0##*/}"
function usage() {
echo "\
usage: $makedist_me [-y] [-u[=<opts>]] [-t target] branch
-u : download setup scripts and files and QiLinux packages
<opts> can be:
setup download the setup scripts and db files
rpms download only the RPM packages
srpms download only the SRPM packages
lists create packages lists for each media
all download setup scripts, db files, RPM, SRPM
i.e. $makedist_me -u stable
$makedist_me -u=setup,rpms stable
$makedist_me -u=setup devel
" >&2
}
#
# Main
#
while test -n "$1" ; do
case $1 in
-u) UPDATE=all ;;
-u=*) UPDATE="`echo $1 | sed s/.*=//`" ;;
-h) usage; exit ;;
-f) force_update=1 ;;
-F) force_noupdate=1 ;;
-v) echo "$copyleft"; exit ;;
*) if test -z $branch ; then branch=$1
fi ;;
esac
shift
done
#MAKEDIST_TARGET=distrocd
#echo $MAKEDIST_TARGET
#TARGETDIR=$TOPDIR/targets/$MAKEDIST_TARGET
#. $TARGETDIR/settings.inc
echo "Updating packages..."
echo " - download from : repository <$qilinux_ftp>"
unset update_dirs; update=$UPDATE
test -n "`echo $update | sed '/setup\|all/!d'`" &&
{ update_dirs="$UTILSDIR";
echo " - update setup files";
update=`echo $update | sed s/setup/@/`; }
test -n "`echo $update | sed 's/srpms//g;/rpms\|all/!d'`" &&
{ update_dirs="$update_dirs ${RPMDIR}${arch}";
update_content=true;
echo " - update RPM packages";
update=`echo $update | sed /[^s]*rpms/s/rpms/@/`; }
test -n "`echo $update | sed 's/[^s]rpms//g;/srpms\|all/!d'`" &&
{ update_dirs="$update_dirs $SRPMSDIR";
echo " - update SRPM packages";
update=`echo $update | sed s/srpms/@/`; }
test -n "`echo $update | sed '/lists\|all/!d'`" &&
{ update_lists="true";
echo " - update packages lists";
update=`echo $update | sed s/lists/@/`; }
# exit if an unknown option is found
test -n "`echo $update | sed 's/all//g;s/@//g;s/,//g'`" &&
{ echo "$makedist_me: syntax error in -u options" >&2
{ (exit 1); exit 1; }; }
case "$branch" in
stable) branch_dir="stable/current" ;;
unstable) branch_dir="unstable/current" ;;
devel) branch_dir="devel" ;;
*) echo "unknown branch ($branch)"
echo "valid choices are: 'stable', 'unstable', 'devel'"
exit 1 ;;
esac
#
# rsync_repository
#
# $1: source remote resource
# $2: destination dir
function rsync_repository() {
rsync -av --delete $1 $2 ||
{ echo "$makedist_me: rsync error $? downloading files from $1" >&2
{ (exit 1); exit 1; }; }
#$qilinux_ftp::ftpqilinux/$branch_dir/$rsync_suffix $local_dest/.. ||
}
# download the user required files from QiLinux repository
if test -n "$update_dirs"; then
echo "Downloading packages from the ftp repository ($branch_dir)..."
for local_dest in $update_dirs; do
mkdir -p $local_dest
unset mkcd_updates mkcd_private
case $local_dest in
*$arch*) rsync_suffix="RPMS/$arch"
[ "$branch" = "stable" ] && mkcd_updates="updates/$rsync_suffix"
;;
*noarch*) rsync_suffix="RPMS/noarch" ;;
*SRPMS*) rsync_suffix="SRPMS" ;;
*utils*) rsync_suffix="utils" ;;
esac
[ "$qilinux_ftp" ] &&
{
rsync_repository $qilinux_ftp::$qilinux_ftp_dir/$branch_dir/$rsync_suffix $local_dest/..
[ "$mkcd_updates" ] &&
{
[ -e $UPDATES_RPMDIR ] || mkdir -p $UPDATES_RPMDIR
echo "*** Syncing updates branch"
rsync_repository $qilinux_ftp::$qilinux_ftp_dir/$branch_dir/$mkcd_updates/.. $UPDATES_RPMDIR
}
}
[ "$qilinux_private_ftp_dir" ] &&
{
[ -e $PRIVATE_RPMDIR ] || mkdir -p $PRIVATE_RPMDIR
echo "*** Syncing private branch"
rsync_repository $qilinux_private_ftp::$qilinux_private_ftp_dir/$rsync_suffix/.. $PRIVATE_RPMDIR
}
done
fi
echo
exit 0