2011-10-13 17:37:21 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Update GSA Ubuntu Repositories or create a local repository
|
|
|
|
#
|
|
|
|
# Author: Leonardo Tonetto (tonetto@linux.vnet.ibm.com)
|
2012-04-10 11:00:00 +00:00
|
|
|
# Revisor: Arif Ali (aali@ocf.co.uk)
|
2011-10-13 17:37:21 +00:00
|
|
|
#
|
|
|
|
# After running this script, add the following line to
|
|
|
|
# /etc/apt/sources.list for local repository
|
|
|
|
# deb file://<core_repo_path>/xcat-core/ maverick main
|
2012-04-10 11:00:00 +00:00
|
|
|
# deb file://<dep_repo_path>/xcat-dep/ maverick main
|
2011-10-13 17:37:21 +00:00
|
|
|
#
|
|
|
|
|
2012-04-10 11:00:00 +00:00
|
|
|
# For the purpose of getting the distribution name
|
|
|
|
. /etc/lsb-release
|
|
|
|
|
2012-05-13 22:51:24 +00:00
|
|
|
# Supported distributions
|
|
|
|
dists="maverick natty oneiric precise"
|
|
|
|
|
2011-10-13 17:37:21 +00:00
|
|
|
a_flag= # automatic flag - only update if repo was updated
|
|
|
|
c_flag= # xcat-core (trunk-delvel) path
|
|
|
|
d_flag= # xcat-dep (trunk) path
|
|
|
|
u_flag= # gsa user-id
|
|
|
|
p_flag= # gsa passwd
|
|
|
|
local_flag= # build the repository localy
|
|
|
|
|
|
|
|
while getopts 'c:d:u:p:l:a' OPTION
|
|
|
|
do
|
|
|
|
case $OPTION in
|
|
|
|
c) c_flag=1
|
|
|
|
xcat_core_path="$OPTARG"
|
|
|
|
;;
|
|
|
|
d) d_flag=1
|
|
|
|
xcat_dep_path="$OPTARG"
|
|
|
|
;;
|
|
|
|
u) u_flag=1
|
|
|
|
gsa_id="$OPTARG"
|
|
|
|
;;
|
|
|
|
p) p_flag=1
|
|
|
|
gsa_passwd="$OPTARG"
|
|
|
|
;;
|
|
|
|
l) local_flag=1
|
|
|
|
local_repo_path="$OPTARG"
|
|
|
|
;;
|
|
|
|
a) a_flag=1
|
|
|
|
;;
|
|
|
|
|
|
|
|
?) printf "Usage: %s -c <core_trunk_path> [-d <dep_trunk_path>] { -l <local-repo_path> | [-u <gsa_id> -p <gsa_passwd>] } [-a]\n" $(basename $0) >&2
|
|
|
|
echo "-a Automatic: update only if there's any update on repo"
|
|
|
|
exit 2
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(($OPTIND - 1))
|
|
|
|
|
|
|
|
if [ -z "$c_flag" ]
|
|
|
|
then
|
|
|
|
printf "Usage: %s -c <core_trunk_path> [-d <dep_trunk_path>] { -l <local-repo_path> | [-u <gsa_id> -p <gsa_passwd>] } [-a]\n" $(basename $0) >&2
|
|
|
|
echo "-a Automatic: update only if there's any update on repo"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
if [ ! -d $xcat_core_path ]
|
|
|
|
then
|
|
|
|
printf "%s: No such directory\n" "$xcat_core_path" >&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$d_flag" ]
|
|
|
|
then
|
|
|
|
if [ ! -d $xcat_dep_path ]
|
|
|
|
then
|
|
|
|
printf "%s: No such directory\n" "$xcat_dep_path" >&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$local_flag" ]
|
|
|
|
then
|
|
|
|
repo_xcat_core_path=$local_repo_path"/xcat-core"
|
|
|
|
repo_xcat_dep_path=$local_repo_path"/xcat-dep"
|
|
|
|
else
|
|
|
|
if [ -z "$u_flag" ]
|
|
|
|
then
|
|
|
|
if [ "$p_flag" ]
|
|
|
|
then
|
|
|
|
printf "Usage: %s -c <core_trunk_path> [-d <dep_trunk_path>] { -l <local-repo_path> | [-u <gsa_id> -p <gsa_passwd>] } [-a]\n" $(basename $0) >&2
|
|
|
|
echo "-a Automatic: update only if there's any update on repo"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
echo -n "GSA id: "
|
|
|
|
read gsa_id
|
|
|
|
echo -n "GSA password: "
|
|
|
|
stty -echo; read gsa_passwd; stty echo;
|
|
|
|
echo ""; echo "";
|
|
|
|
fi
|
|
|
|
|
|
|
|
repo_xcat_core_path="`pwd`/gsa-repo_temp/xcat-core"
|
|
|
|
repo_xcat_dep_path="`pwd`/gsa-repo_temp/xcat-dep"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$a_flag" ]
|
|
|
|
then
|
|
|
|
touch svcupdate.trace
|
|
|
|
SVCUP='svcupdate.trace'
|
|
|
|
svn update $xcat_core_path 1> $SVCUP 2>&1
|
|
|
|
if ! grep 'Tree is up to date' $SVCUP
|
|
|
|
then
|
|
|
|
update_core=1
|
|
|
|
else
|
|
|
|
update_core=
|
|
|
|
fi
|
|
|
|
rm -f $SVCUP
|
|
|
|
else
|
|
|
|
update_core=1
|
|
|
|
fi
|
|
|
|
if [ "$update_core" ]
|
|
|
|
then
|
|
|
|
echo "###############################"
|
|
|
|
echo "# Building xcat-core packages #"
|
|
|
|
echo "###############################"
|
|
|
|
|
|
|
|
CMD_PATH=`pwd`
|
|
|
|
cd $xcat_core_path
|
|
|
|
./build-debs-all "snap" "Nightly_Builds"
|
|
|
|
|
|
|
|
echo "#################################"
|
|
|
|
echo "# Creating xcat-core repository #"
|
|
|
|
echo "#################################"
|
|
|
|
|
|
|
|
if [ -d $repo_xcat_core_path ]; then
|
2012-09-25 12:17:50 +00:00
|
|
|
rm -rf $repo_xcat_core_path
|
2011-10-13 17:37:21 +00:00
|
|
|
fi
|
|
|
|
mkdir -p $repo_xcat_core_path/conf
|
|
|
|
|
|
|
|
find . -iname '*.deb' -exec mv {} $repo_xcat_core_path \;
|
|
|
|
|
2012-09-25 12:17:50 +00:00
|
|
|
rm -rf debs/
|
2011-10-13 17:37:21 +00:00
|
|
|
cd $CMD_PATH
|
|
|
|
|
2012-05-13 22:51:24 +00:00
|
|
|
rm -rf $repo_xcat_core_path/conf/distributions
|
|
|
|
|
|
|
|
for dist in $dists; do
|
|
|
|
cat << __EOF__ >> $repo_xcat_core_path/conf/distributions
|
2011-10-13 17:37:21 +00:00
|
|
|
Origin: xCAT internal repository
|
|
|
|
Label: xcat-core bazaar repository
|
2012-05-13 22:51:24 +00:00
|
|
|
Codename: $dist
|
2012-12-18 06:10:34 +00:00
|
|
|
Architectures: amd64
|
2011-10-13 17:37:21 +00:00
|
|
|
Components: main
|
|
|
|
Description: Repository automatically genereted conf
|
2012-05-13 22:51:24 +00:00
|
|
|
|
2011-10-13 17:37:21 +00:00
|
|
|
__EOF__
|
2012-05-13 22:51:24 +00:00
|
|
|
done
|
2011-10-13 17:37:21 +00:00
|
|
|
|
|
|
|
cat << __EOF__ > $repo_xcat_core_path/conf/options
|
|
|
|
verbose
|
|
|
|
basedir .
|
|
|
|
__EOF__
|
|
|
|
|
2012-05-13 22:51:24 +00:00
|
|
|
for dist in $dists; do
|
|
|
|
for file in `ls $repo_xcat_core_path/*.deb`; do
|
|
|
|
reprepro -b $repo_xcat_core_path includedeb $dist $file;
|
|
|
|
done
|
2011-10-13 17:37:21 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
mv $xcat_core_path/latest_version $repo_xcat_core_path/xcat-core_latest-build
|
|
|
|
|
2012-04-19 22:31:05 +00:00
|
|
|
cat << '__EOF__' > $repo_xcat_core_path/mklocalrepo.sh
|
|
|
|
. /etc/lsb-release
|
|
|
|
cd `dirname $0`
|
|
|
|
echo deb file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-core.list
|
|
|
|
__EOF__
|
|
|
|
|
|
|
|
chmod 775 $repo_xcat_core_path/mklocalrepo.sh
|
2012-05-13 22:51:24 +00:00
|
|
|
rm -rf $repo_xcat_core_path/*.deb
|
2012-04-19 22:31:05 +00:00
|
|
|
|
2011-10-13 17:37:21 +00:00
|
|
|
if [ -z "$local_flag" ]
|
|
|
|
then
|
|
|
|
echo "###############################"
|
|
|
|
echo "# Updating GSA xcat-core repo #"
|
|
|
|
echo "###############################"
|
|
|
|
lftp -e "mirror -R --delete-first $repo_xcat_core_path /projects/i/ipl-xcat/ubuntu/; exit;" -u $gsa_id,$gsa_passwd -p 22 sftp://ausgsa.ibm.com
|
|
|
|
fi ### if [ -z "$local_flag" ]
|
|
|
|
fi ### if [ "$a_flag" ]
|
|
|
|
|
|
|
|
if [ "$a_flag" -a "$d_flag" ]
|
|
|
|
then
|
|
|
|
touch svcupdate.trace
|
|
|
|
SVCUP='svcupdate.trace'
|
|
|
|
svn update $xcat_dep_path 1> $SVCUP 2>&1
|
|
|
|
if ! grep 'Tree is up to date' $SVCUP
|
|
|
|
then
|
|
|
|
update_dep=1
|
|
|
|
else
|
|
|
|
update_dep=
|
|
|
|
fi
|
|
|
|
rm -f $SVCUP
|
|
|
|
else
|
|
|
|
update_dep=1
|
|
|
|
fi
|
|
|
|
if [ "$d_flag" -a "$update_dep" ]
|
|
|
|
then
|
2012-04-10 11:00:00 +00:00
|
|
|
echo "##############################"
|
|
|
|
echo "# Building xcat-dep packages #"
|
|
|
|
echo "##############################"
|
|
|
|
|
|
|
|
CMD_PATH=`pwd`
|
|
|
|
cd $xcat_dep_path
|
|
|
|
./build-debs-all "snap" "Nightly_Builds"
|
|
|
|
|
2011-10-13 17:37:21 +00:00
|
|
|
echo "################################"
|
|
|
|
echo "# Creating xcat-dep repository #"
|
|
|
|
echo "################################"
|
2012-09-25 12:17:50 +00:00
|
|
|
rm -rf $repo_xcat_dep_path
|
2011-10-13 17:37:21 +00:00
|
|
|
mkdir -p $repo_xcat_dep_path/conf
|
|
|
|
find $xcat_dep_path -iname '*.deb' -exec cp {} $repo_xcat_dep_path \;
|
2012-05-13 22:51:24 +00:00
|
|
|
|
|
|
|
rm -rf $repo_xcat_core_path/conf/distributions
|
|
|
|
|
|
|
|
for dist in $dists; do
|
|
|
|
cat << __EOF__ >> $repo_xcat_dep_path/conf/distributions
|
2011-10-13 17:37:21 +00:00
|
|
|
Origin: xCAT internal repository
|
|
|
|
Label: xcat-dep bazaar repository
|
2012-05-13 22:51:24 +00:00
|
|
|
Codename: $dist
|
2011-10-13 17:37:21 +00:00
|
|
|
Architectures: i386 amd64
|
|
|
|
Components: main
|
|
|
|
Description: Repository automatically genereted conf
|
2012-05-13 22:51:24 +00:00
|
|
|
|
2011-10-13 17:37:21 +00:00
|
|
|
__EOF__
|
2012-05-13 22:51:24 +00:00
|
|
|
done
|
2011-10-13 17:37:21 +00:00
|
|
|
|
|
|
|
cat << __EOF__ > $repo_xcat_dep_path/conf/options
|
|
|
|
verbose
|
|
|
|
basedir .
|
|
|
|
__EOF__
|
|
|
|
|
2012-05-13 22:51:24 +00:00
|
|
|
for dist in $dists; do
|
|
|
|
for file in `ls $repo_xcat_dep_path/*.deb`; do
|
|
|
|
reprepro -b $repo_xcat_dep_path includedeb $dist $file;
|
|
|
|
done
|
2011-10-13 17:37:21 +00:00
|
|
|
done
|
|
|
|
|
2012-04-19 22:31:05 +00:00
|
|
|
cat << '__EOF__' > $repo_xcat_dep_path/mklocalrepo.sh
|
|
|
|
. /etc/lsb-release
|
|
|
|
cd `dirname $0`
|
|
|
|
echo deb file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-dep.list
|
|
|
|
__EOF__
|
|
|
|
|
2012-05-13 22:51:24 +00:00
|
|
|
chmod 775 $repo_xcat_dep_path/mklocalrepo.sh
|
|
|
|
rm -rf $repo_xcat_dep_path/*.deb
|
2012-04-19 22:31:05 +00:00
|
|
|
|
2011-10-13 17:37:21 +00:00
|
|
|
if [ -z "$local_flag" ]
|
|
|
|
then
|
|
|
|
echo "##############################"
|
|
|
|
echo "# Updating GSA xcat-dep repo #"
|
|
|
|
echo "##############################"
|
|
|
|
lftp -e "mirror -R --delete-first $repo_xcat_dep_path /projects/i/ipl-xcat/ubuntu/; exit;" -u $gsa_id,$gsa_passwd -p 22 sftp://ausgsa.ibm.com
|
|
|
|
fi ### if [ -z "$local_flag" ]
|
|
|
|
fi ### if [ "$d_flag" -a "$a_flag"]
|
|
|
|
|
|
|
|
if [ -z "$local_flag" ] # delete the temp repo after upload is done
|
|
|
|
then
|
2012-09-25 12:17:50 +00:00
|
|
|
rm -rf ./gsa-repo_temp
|
2011-10-13 17:37:21 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|