2013-02-09 06:12:35 +00:00
|
|
|
#!/bin/bash
|
2011-10-13 17:37:21 +00:00
|
|
|
# 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
|
|
|
#
|
|
|
|
#
|
2013-02-09 06:12:35 +00:00
|
|
|
# Getting Started:
|
|
|
|
# - Check out the xcat-core svn repository (either the trunk or a branch) into
|
|
|
|
# a dir called <rel>/src/xcat-core, where <rel> is the same as the release dir it will be
|
|
|
|
# uploaded to in sourceforge (e.g. devel, or 2.3).
|
|
|
|
# - You probably also want to put root's pub key from the build machine onto sourceforge for
|
|
|
|
# the upload user listed below, so you don't have to keep entering pw's. You can do this
|
|
|
|
# at https://sourceforge.net/account/ssh
|
|
|
|
# - make sure reprepro is installed on the build machine
|
|
|
|
# - Run this script from the local svn repository you just created. It will create the other directories that are needed.
|
|
|
|
|
|
|
|
# Usage: attr=value attr=value ... ./build-ubunturepo { -c | -d }
|
|
|
|
# PROMOTE=1 - if the attribute "PROMOTE" is specified, means an official dot release. This does not
|
|
|
|
# actually build xcat, just uploads the most recent snap build to https://sourceforge.net/projects/xcat/files/xcat/ .
|
|
|
|
# If not specified, a snap build is assumed, which uploads to https://sourceforge.net/projects/xcat/files/yum/
|
|
|
|
# or https://sourceforge.net/projects/xcat/files/aix/.
|
|
|
|
# PREGA=1 - use this option with PROMOTE=1 on a branch that already has a released dot release, but this build is
|
|
|
|
# a GA candidate build, not to be released yet. This will result in the tarball being uploaded to
|
|
|
|
# https://sourceforge.net/projects/xcat/files/yum/ or https://sourceforge.net/projects/xcat/files/aix/
|
|
|
|
# (but the tarball file name will be like a released tarball, not a snap build). When you are ready to
|
|
|
|
# release this build, use PROMOTE=1 without PREGA
|
|
|
|
# BUILDALL=1 - build all rpms, whether they changed or not. Should be used for snap builds that are in prep for a release.
|
|
|
|
# UP=0 or UP=1 - override the default upload behavior
|
|
|
|
#
|
|
|
|
# For the dependency packages 1. please run the build-debs-all in xcat-dep svn first( there is usage detail in that script)
|
|
|
|
# 2. run ./build-ubunturepo -d
|
|
|
|
#
|
|
|
|
############################
|
|
|
|
printusage()
|
|
|
|
{
|
|
|
|
printf "Usage: %s {-c | -d} \n" $(basename $0) >&2
|
|
|
|
echo " -c : Build the xcat core packages and create the repo"
|
|
|
|
echo " -d : Create the xcat dep repo. Building the xcat dep packages can refer \"build-debs-all\" from svn"
|
|
|
|
}
|
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
|
2013-02-09 06:12:35 +00:00
|
|
|
dists="maverick natty oneiric precise"
|
2012-05-13 22:51:24 +00:00
|
|
|
|
2011-10-13 17:37:21 +00:00
|
|
|
c_flag= # xcat-core (trunk-delvel) path
|
|
|
|
d_flag= # xcat-dep (trunk) path
|
2013-02-09 06:12:35 +00:00
|
|
|
r_flag= #genesis base rpm package path
|
2011-10-13 17:37:21 +00:00
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
while getopts 'cdr:' OPTION
|
2011-10-13 17:37:21 +00:00
|
|
|
do
|
|
|
|
case $OPTION in
|
|
|
|
c) c_flag=1
|
|
|
|
;;
|
|
|
|
d) d_flag=1
|
|
|
|
;;
|
2013-02-09 06:12:35 +00:00
|
|
|
r) r_flag=1
|
|
|
|
genesis_rpm_path="$OPTARG"
|
|
|
|
;;
|
|
|
|
?) printusage
|
2011-10-13 17:37:21 +00:00
|
|
|
exit 2
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(($OPTIND - 1))
|
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
if [ -z "$c_flag" -a -z "$d_flag" ];then
|
|
|
|
printusage
|
2011-10-13 17:37:21 +00:00
|
|
|
exit 2
|
|
|
|
fi
|
2013-02-09 06:12:35 +00:00
|
|
|
|
|
|
|
if [ "$c_flag" -a "$d_flag" ];then
|
|
|
|
printusage
|
2011-10-13 17:37:21 +00:00
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
uploader="bp-sawyers"
|
|
|
|
# Find where this script is located to set some build variables
|
|
|
|
old_pwd=`pwd`
|
|
|
|
cd `dirname $0`
|
|
|
|
curdir=`pwd`
|
|
|
|
|
|
|
|
#define the dep source code path, core build target path and dep build target path
|
|
|
|
local_core_repo_path="$curdir/../../xcat-core"
|
|
|
|
xcat_dep_path="$curdir/../../../xcat-dep/src/xcat-dep"
|
|
|
|
local_dep_repo_path="$curdir/../../../xcat-dep/xcat-dep"
|
|
|
|
|
|
|
|
#define the url used for creating the source list file
|
|
|
|
#define the upload dir used for uploading packages
|
|
|
|
sf_repo_url="https://sourceforge.net/projects/xcat/files/ubuntu"
|
|
|
|
sf_dir="/home/frs/project/x/xc/xcat"
|
|
|
|
|
|
|
|
if [ "$PROMOTE" = 1 ]; then
|
|
|
|
upload_dir="xcat-core"
|
|
|
|
tar_name="xcat-core-$ver.tar.bz2"
|
|
|
|
else
|
|
|
|
upload_dir="core-snap"
|
|
|
|
tar_name="core-debs-snap.tar.bz2"
|
2011-10-13 17:37:21 +00:00
|
|
|
fi
|
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
if [ "$c_flag" ]
|
2011-10-13 17:37:21 +00:00
|
|
|
then
|
2013-02-09 06:12:35 +00:00
|
|
|
# strip the /src/xcat-core from the end of the dir to get the next dir up and use as the release
|
|
|
|
if [ -z "$REL" ]; then
|
|
|
|
t=${curdir%/src/xcat-core}
|
|
|
|
REL=`basename $t`
|
2011-10-13 17:37:21 +00:00
|
|
|
fi
|
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
#get the version
|
|
|
|
echo "svn --quiet update Version"
|
|
|
|
svn --quiet up Version
|
|
|
|
ver=`cat Version`
|
|
|
|
short_ver=`cat Version|cut -d. -f 1,2`
|
|
|
|
short_short_ver=`cat Version|cut -d. -f 1`
|
|
|
|
|
|
|
|
#TODO: define the core path and tarball name
|
|
|
|
tarball_name="core-debs-snap.tar.bz2"
|
|
|
|
|
|
|
|
#update the code from svn
|
|
|
|
svn_up_log="../coresvnup"
|
|
|
|
echo "svn update > $svn_up_log"
|
|
|
|
svn update > $svn_up_log
|
|
|
|
|
|
|
|
#makesure the code change status
|
|
|
|
code_change=0
|
|
|
|
if ! grep -q 'At revision' $svn_up_log;then
|
|
|
|
code_change=1
|
|
|
|
fi
|
2011-10-13 17:37:21 +00:00
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
if [ $code_change == 0 -a "$UP" != 1 ]; then
|
|
|
|
echo "Nothing new detected"
|
|
|
|
exit 0
|
2011-10-13 17:37:21 +00:00
|
|
|
fi
|
|
|
|
echo "###############################"
|
|
|
|
echo "# Building xcat-core packages #"
|
|
|
|
echo "###############################"
|
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
#the package type: local | snap | alpha
|
|
|
|
#the build introduce stirng
|
|
|
|
pkg_type="snap"
|
|
|
|
build_string="Snap_Build"
|
|
|
|
cur_date=`date +%Y%m%d`
|
|
|
|
pkg_version="${short_ver}-${pkg_type}${cur_date}"
|
|
|
|
|
|
|
|
if [ ! -d ../../debs ];then
|
|
|
|
mkdir -p "../../debs"
|
|
|
|
fi
|
|
|
|
packages="xCAT-client xCAT-genesis-scripts perl-xCAT xCAT-server xCAT-UI xCAT xCATsn xCAT-test"
|
|
|
|
|
|
|
|
for file in `echo $packages`
|
|
|
|
do
|
|
|
|
file_low=`echo $file | tr '[A-Z]' '[a-z]'`
|
|
|
|
if grep -q $file $svn_up_log || [ "$BUILDALL" == 1 ]; then
|
|
|
|
rm -f ../../debs/${file_low}_*.deb
|
|
|
|
#only for genesis package
|
|
|
|
rm -f ../../debs/${file_low}-amd64_*.deb
|
|
|
|
cd $file
|
|
|
|
dch -v $pkg_version -b -c debian/changelog $build_string
|
|
|
|
dpkg-buildpackage
|
|
|
|
rc=$?
|
|
|
|
if [ $rc -gt 0 ]; then
|
|
|
|
echo "Error: $file build package failed exit code $rc"
|
|
|
|
fi
|
|
|
|
cd -
|
|
|
|
find $file -maxdepth 3 -type d -name "${file_low}*" | grep debian | xargs rm -rf
|
|
|
|
find $file -maxdepth 3 -type f -name "files" | grep debian | xargs rm -rf
|
|
|
|
mv ${file_low}* ../../debs/
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
find ../../debs/* ! -name *.deb | xargs rm -f
|
2011-10-13 17:37:21 +00:00
|
|
|
|
|
|
|
echo "#################################"
|
|
|
|
echo "# Creating xcat-core repository #"
|
|
|
|
echo "#################################"
|
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
#clean the repo directory
|
|
|
|
if [ -e $local_core_repo_path ]; then
|
|
|
|
rm -rf $local_core_repo_path
|
2011-10-13 17:37:21 +00:00
|
|
|
fi
|
2013-02-09 06:12:35 +00:00
|
|
|
mkdir -p $local_core_repo_path
|
|
|
|
cd $local_core_repo_path
|
|
|
|
mkdir conf
|
2012-05-13 22:51:24 +00:00
|
|
|
|
|
|
|
for dist in $dists; do
|
2013-02-09 06:12:35 +00:00
|
|
|
cat << __EOF__ >> 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
|
2013-01-25 13:25:26 +00:00
|
|
|
Architectures: amd64 i386
|
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
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
cat << __EOF__ > conf/options
|
2011-10-13 17:37:21 +00:00
|
|
|
verbose
|
|
|
|
basedir .
|
|
|
|
__EOF__
|
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
#import the deb packages into the repo
|
2012-05-13 22:51:24 +00:00
|
|
|
for dist in $dists; do
|
2013-02-09 06:12:35 +00:00
|
|
|
for file in `ls ../debs/*.deb`; do
|
|
|
|
reprepro -b ./ includedeb $dist $file;
|
2012-05-13 22:51:24 +00:00
|
|
|
done
|
2011-10-13 17:37:21 +00:00
|
|
|
done
|
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
#create the mklocalrepo script
|
|
|
|
cat << __EOF__ > mklocalrepo.sh
|
2012-04-19 22:31:05 +00:00
|
|
|
. /etc/lsb-release
|
|
|
|
cd `dirname $0`
|
|
|
|
echo deb file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-core.list
|
|
|
|
__EOF__
|
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
chmod 775 mklocalrepo.sh
|
2012-04-19 22:31:05 +00:00
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
#create the xcat-core.list file
|
|
|
|
echo "deb ${sf_repo_url}/${REL}/${upload_dir}/ precise main" > xcat-core.list
|
2011-10-13 17:37:21 +00:00
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
cd ../
|
|
|
|
if ! grep xcat /etc/group ; then
|
|
|
|
groupadd xcat
|
|
|
|
fi
|
|
|
|
|
|
|
|
chgrp -R xcat xcat-core
|
|
|
|
chmod -R g+w xcat-core
|
|
|
|
|
|
|
|
#build the tar ball
|
|
|
|
tar -hjcf $tar_name xcat-core
|
|
|
|
chgrp xcat $tar_name
|
|
|
|
chmod g+w $tar_name
|
|
|
|
|
|
|
|
if [ ! -e core-snap ]; then
|
|
|
|
ln -s xcat-core core-snap
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Decide whether to upload or not
|
|
|
|
if [ "$UP" != 1 ]; then
|
|
|
|
echo "No need to upload"
|
|
|
|
cd $old_pwd
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
#upload the deb packages
|
|
|
|
if [ "$REL" = "devel" -o "$PREGA" != 1 ]; then
|
|
|
|
i=0
|
|
|
|
echo "Uploading RPMs from $upload_dir to ${sf_dir}/ubuntu/${REL}/ ..."
|
|
|
|
while [ $((i+=1)) -le 5 ] && ! rsync -urLv --delete $upload_dir ${uploader},xcat@web.sourceforge.net:${sf_dir}/ubuntu/${REL}/
|
|
|
|
do : ; done
|
|
|
|
fi
|
|
|
|
|
|
|
|
#upload the tar ball
|
|
|
|
if [ "$PROMOTE" = 1 -a "$REL" != "devel" -a "$PREGA" != 1 ]; then
|
|
|
|
echo "";
|
2011-10-13 17:37:21 +00:00
|
|
|
else
|
2013-02-09 06:12:35 +00:00
|
|
|
i=0
|
|
|
|
echo "Uploading $tar_name to ${sf_dir}/ubuntu/${REL}/ ..."
|
|
|
|
while [ $((i+=1)) -le 5 ] && ! rsync -v $tar_name ${uploader},xcat@web.sourceforge.net:${sf_dir}/ubuntu/${REL}/
|
|
|
|
do : ; done
|
2011-10-13 17:37:21 +00:00
|
|
|
fi
|
2013-02-09 06:12:35 +00:00
|
|
|
|
|
|
|
cd $old_pwd
|
2011-10-13 17:37:21 +00:00
|
|
|
fi
|
2012-04-10 11:00:00 +00:00
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
if [ "$d_flag" ]
|
|
|
|
then
|
2011-10-13 17:37:21 +00:00
|
|
|
echo "################################"
|
|
|
|
echo "# Creating xcat-dep repository #"
|
|
|
|
echo "################################"
|
2012-05-13 22:51:24 +00:00
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
#clean all old files
|
|
|
|
if [ -e $local_dep_repo_path ];then
|
|
|
|
rm -rf $local_dep_repo_path
|
|
|
|
fi
|
|
|
|
mkdir -p $local_dep_repo_path
|
|
|
|
cd $local_dep_repo_path
|
|
|
|
mkdir conf
|
2012-05-13 22:51:24 +00:00
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
#create the conf/distributions file
|
2012-05-13 22:51:24 +00:00
|
|
|
for dist in $dists; do
|
2013-02-09 06:12:35 +00:00
|
|
|
cat << __EOF__ >> 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__
|
2013-02-09 06:12:35 +00:00
|
|
|
done
|
2011-10-13 17:37:21 +00:00
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
cat << __EOF__ > conf/options
|
2011-10-13 17:37:21 +00:00
|
|
|
verbose
|
|
|
|
basedir .
|
|
|
|
__EOF__
|
|
|
|
|
2012-05-13 22:51:24 +00:00
|
|
|
for dist in $dists; do
|
2013-02-09 06:12:35 +00:00
|
|
|
for file in `ls ../debs/*.deb`; do
|
|
|
|
reprepro -b ./ includedeb $dist $file;
|
2012-05-13 22:51:24 +00:00
|
|
|
done
|
2011-10-13 17:37:21 +00:00
|
|
|
done
|
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
cat << '__EOF__' > mklocalrepo.sh
|
2012-04-19 22:31:05 +00:00
|
|
|
. /etc/lsb-release
|
|
|
|
cd `dirname $0`
|
|
|
|
echo deb file://"`pwd`" $DISTRIB_CODENAME main > /etc/apt/sources.list.d/xcat-dep.list
|
|
|
|
__EOF__
|
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
chmod 775 mklocalrepo.sh
|
2012-04-19 22:31:05 +00:00
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
echo ""deb ${sf_repo_url}/xcat-dep/ precise main"" > xcat-dep.list
|
2011-10-13 17:37:21 +00:00
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
cd ..
|
|
|
|
if ! grep xcat /etc/group ; then
|
|
|
|
groupadd xcat
|
|
|
|
fi
|
|
|
|
|
|
|
|
chgrp -R xcat xcat-dep
|
|
|
|
chmod -R g+w xcat-dep
|
|
|
|
|
|
|
|
#create the tar ball
|
|
|
|
dep_tar_name=xcat-dep-ubuntu.tar.bz
|
|
|
|
tar -hjcf $dep_tar_name xcat-dep
|
|
|
|
chgrp xcat $dep_tar_name
|
|
|
|
chmod g+w $dep_tar_name
|
2011-10-13 17:37:21 +00:00
|
|
|
|
2013-02-09 06:12:35 +00:00
|
|
|
if [ "$UP" != 1 ];then
|
|
|
|
echo "No need to upload the dep packages"
|
|
|
|
cd $old_pwd
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
#upload the dep packages
|
|
|
|
i=0
|
|
|
|
echo "Uploading debs from xcat-dep to ${sf_dir}/ubuntu/xcat-dep/ ..."
|
|
|
|
while [ $((i+=1)) -le 5 ] && ! rsync -urLv --delete xcat-dep ${uploader},xcat@web.sourceforge.net:${sf_dir}/ubuntu/
|
|
|
|
do : ; done
|
|
|
|
#upload the tarball
|
|
|
|
cd $old_pwd
|
|
|
|
fi
|
2011-10-13 17:37:21 +00:00
|
|
|
exit 0
|