package_trunk revision e807d7cd75aeb0e0dd399c66aaa575e0902b32c9
#
# Auto package Hets repository
#
# c.prodescu@jacobs-university.de
# jonathan.von_schroeder@gmail.com
#
MAIN_DISTRO="oneiric"
OPTERR=0
OPT_TEST=1
cd $DISTRO_DIR
for f in *
do
DISTROS="$f ${DISTROS}"
done
cd $OLD_PWD
{
echo "Usage: $0 [<option> ...] <command>"
echo ""
echo "Create & upload hets packages from the svn trunk."
echo "This scripts needs a few additional files."
# echo "If these are not present it will try to get them from svn."
echo ""
echo "Comands:"
echo " prepare - Prepare the base.tgz files needed by pbuilder
(needed for testing, you only need to call it once -
updating takes place automatically)"
echo " create - Create source packages from svn trunk"
echo " test - Test building source packages"
echo " upload - Upload packages to launchpad hets ppa"
echo " package - Do all the above i.e. create source packages,
test them and then upload them"
echo " clean - Remove any checkouts, build files etc."
echo ""
echo "Please note:
* prepare and test need you to be either root
or to be able to call sudo"
echo ""
echo "Options:"
echo " -h Print this help"
echo " -i Try to install dependencies of this script
automatically using apt-get (note requires
you to be root are to be able to call sudo)
-a Execute commands for all available distros
-s DISTRO
Select distro for commands
-c Select current distro for commands: $CURR_DISTRO
-r REVISION
use revision REVISION instead of the latest HETS revision"
}
{
local PKG="$1"
if [ $? -eq 1 ]; then
if [ $AUTO_INSTALL -eq 0 ]; then
echo ":: Installing $PKG"
if [ $? -eq 1 ]; then
echo "Can't find apt-get ..."
echo "Giving up."
exit
fi
local CMD="apt-get install"
else
if [ $? -eq 1 ]; then
echo "Can't find sudo and you're not root ..."
echo "Giving up."
exit
fi
local CMD="sudo apt-get install"
fi
if [ $? -eq 1 ]; then
echo "Installing $PKG seems to have failed ..."
echo "Giving up."
exit
else
echo ":: Package $PKG is now installed"
fi
else
echo ":: Package $PKG not installed"
echo "Auto-install option not given ..."
echo "Please install $PKG manually or try again with -i ..."
echo "Giving up."
exit 1
fi
else
echo ":: Package $PKG installed"
fi
}
{
local SUFF="$1"
local REPO="$2"
local REPO_FOLDER="$3"
local FOLDER="$4"
local TARGET_REV="$5"
local UPTODATE=1
if [ -d $REPO_FOLDER ]; then
if [ $? -eq 0 ]; then
echo ":: Updating previous checkout of $REPO"
(cd $REPO_FOLDER && git svn rebase)
if [ $? -eq 0 ]; then
UPTODATE=0
fi
else
echo "$REPO_FOLDER exists ..."
echo "But it is not a git repository ..."
read -n1 -p " Delete it? (y/n) "
echo
fi
fi
echo ":: Checking out $REPO ..."
if [ $? -eq 1 ]; then
echo "Check out failed ..."
echo "Giving up."
exit 1
fi
fi
REVISION=`git --git-dir=$HETS_REPO_FOLDER/.git svn info | grep "Last Changed Rev: " | cut -d':' -f2 | cut -d' ' -f2`
if [ ! $? -eq 0 ]; then
echo "Couldn't detect revision ..."
echo "Giving up."
exit 1
fi
if [ ! $? -eq 0 ]; then
echo "Couldn't find revision $TARGET_REV ..."
echo "Giving up."
exit 1
fi
echo ":: Git revision for $TARGET_REV is: $GIT_TARGET_REV"
(cd $REPO_FOLDER && git checkout $GIT_TARGET_REV)
fi
fi
fi
if [ $EXPORT_UPTODATE -eq 1 ]; then
echo ":: Exporting $REPO ..."
cd $REPO_FOLDER
cd $OLD_PWD
if [ $? -eq 1 ]; then
echo "Check out failed ..."
echo "Giving up."
exit 1
fi
git --git-dir=$HETS_REPO_FOLDER/.git svn info | grep "Last Changed Rev: " | cut -d':' -f2 | cut -d' ' -f2 > $DATA_DIR/revision_$SUFF
else
echo "Export of $REPO is up to date"
fi
}
HETS_REV=""
while getopts ":hias:cr:" opt; do
\?)
echo "Invalid option: -$OPTARG" >&2
echo ""
exit 1
;;
h)
exit
;;
i)
;;
a)
;;
s)
else
echo "Distribution $OPTARG not available ..."
echo "Giving up."
exit 1
fi
;;
c)
;;
r)
;;
esac
done
echo "No Distro selected " >&2
echo ""
exit 1
fi
echo ":: Selected Distros are: $SELECTED_DISTROS"
{
export $OPTION=0
}
do
set_option "PREPARE"
;;
set_option "CREATE"
;;
test)
set_option "TEST"
;;
set_option "UPLOAD"
;;
set_option "CREATE"
set_option "TEST"
set_option "UPLOAD"
;;
set_option "CLEAN"
;;
*)
echo "Unknown command $arg ..."
echo
exit 1
esac
done
if [ ! -d $RESULTS_DIR ]; then
fi
echo "=== Preparing base.tgz"
CMD="pbuilder"
else
if [ $? -eq 1 ]; then
echo "Can't find sudo and you're not root ..."
echo "Giving up."
exit
fi
CMD="sudo pbuilder"
fi
do
echo "See $OLD_PWD/logs/pbuilder_${DIST}_base.tgz.log"
$CMD create --basetgz "$OLD_PWD/pbuilder/${DIST}_base.tgz" --distribution $DIST --othermirror "deb http://archive.ubuntu.com/ubuntu $DIST main restricted universe multiverse|deb http://ppa.launchpad.net/hets/hets/ubuntu $DIST main" > "$OLD_PWD/logs/pbuilder_${DIST}_base.tgz.log`date +%s`"
echo ":: Done"
done
fi
echo "=== Cleaning"
fi
echo "=== Creating source packages"
ensure_package_installed "git-svn"
ensure_package_installed "openjdk-6-jdk"
export_repo "hets" "$HETS_REPO" "$HETS_REPO_FOLDER" "$HETS_FOLDER" "$HETS_REV"
fi
if [ ! $? -eq 0 ]; then
echo "Couldn't detect version ..."
echo "Giving up."
exit 1
fi
echo ":: Hets version is: $HETS_VERSION"
echo ":: Revision is: $HETS_REVISION"
echo ":: Full version is: $HETS_FULL_VERSION"
export_repo "lib" "$HETS_LIB_REPO" "$HETS_LIB_REPO_FOLDER" "$HETS_FOLDER/hets-lib"
echo ":: Compiling Hets OWL Tools"
cd $HETS_FOLDER
make initialize_java 1>/dev/null || { echo Building Hets OWL Tools failed && echo Giving up. && exit 1; }
cd $OLD_PWD
cd $HETS_FOLDER/OWL2
cd $OLD_PWD
else
echo "Not necessary"
fi
echo ":: Clearing $HETS_FOLDER"
if [ ! -f $DATA_DIR/clean.done ]; then
cd $HETS_FOLDER
cd $OLD_PWD
fi
echo ":: Creating orig.tar.gz"
cd $HETS_FOLDER
cd ..
cd $OLD_PWD
else
echo ".orig.tar.gz is up to date"
fi
do
echo "::Packaging for $DIST distroseries"
cd $DATA_DIR
cd $OLD_PWD
# Creating the changelog
if [ "$DIST" = "$MAIN_DISTRO" ]; then
ADDITIONAL=""
else
ADDITIONAL="~$DIST"
fi
echo >> .changelog
echo " * Initial release, automatically generated." >> .changelog
echo >> .changelog
#merging changelogs
echo ::Done
ln -s $RESULTS_DIR/hets_$HETS_FULL_VERSION.orig.tar.gz $DATA_DIR/hets_$HETS_FULL_VERSION.orig.tar.gz
cd $HETS_FOLDER;
echo ::Done
cd $OLD_PWD
done
cd $DATA_DIR
cd $OLD_PWD
fi
echo "You need to (re-)create the packages for uploading"
exit
fi
echo "=== Uploading source packages"
do
if [ "$DIST" = "$MAIN_DISTRO" ]; then
ADDITIONAL=""
else
ADDITIONAL="~$DIST"
fi
echo "hets_$HETS_FULL_VERSION-0ubuntu1$ADDITIONAL.changes doesn't exist ..."
echo "Maybe you need to call create first ..."
echo "Giving up."
exit
fi
done
fi
echo "Testing not yet implemented ..."
echo "Giving up."
exit 1
fi