Commit bfee1e99 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Clean up, and add options to specify a svn root path and a destination directory.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20672 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f5e000b2
#!/bin/bash #! /bin/bash
#
# Usage: build_bt5_from_svn.sh [-p path] [-d dir]
#
# The path is the last part of the svn root, for example, tag/5.0 or trunk.
# By default, the path is "trunk".
#
# The dir is the destination directory where the repository is made.
# By default, the dir is the current directory.
# TODO: BT5 version support (stable/unstable) set -e
path=trunk
repository=$(pwd)
while getopts "p:d:" opt; do
case $opt in
p) path="$OPTARG" ;;
d) repository="$OPTARG" ;;
esac
done
# Lock file name # Lock file name
LOCKFILE="/tmp/`basename $0`.lock" LOCKFILE="/tmp/$(basename $0).lock"
# SVN paths # SVN paths
SVNROOT="https://svn.erp5.org/repos/public/erp5/trunk/" SVNROOT="https://svn.erp5.org/repos/public/erp5/$path"
# Relative svn paths to fetch # Relative svn paths to fetch
MODULES="bt5 products/ERP5/bootstrap" MODULES="bt5 products/ERP5/bootstrap"
# Script generating the business template repository index # Script generating the business template repository index
GENBTLIST="products/ERP5/bin" GENBTLIST="products/ERP5/bin"
# Local directory to receive CVS copy # Local directory to receive SVN copies
BASELOCALDIR="/tmp" BASELOCALDIR="/tmp"
LOCALDIR="$BASELOCALDIR/$$"
# Local directory to receive butiness templates # Local directory to receive butiness templates
BT5DIR="/var/lib/zope/static/reposit/erp5/upload_module" BT5DIR="$repostiry"
function cleanup () {
rm -f $LOCKFILE function cleanup {
exit 1 rm -f "$LOCKFILE"
rm -rf "$LOCALDIR"
} }
if [ -e "$LOCKFILE" ]; then if [ -e "$LOCKFILE" ]; then
...@@ -25,37 +45,37 @@ if [ -e "$LOCKFILE" ]; then ...@@ -25,37 +45,37 @@ if [ -e "$LOCKFILE" ]; then
exit 1 exit 1
fi fi
touch "$LOCKFILE" || exit 1 trap "cleanup" ERR
LOCALDIR="$BASELOCALDIR/$$"
mkdir "$LOCALDIR" || cleanup touch "$LOCKFILE"
mkdir "$LOCALDIR"
for MODULE in $MODULES; do for MODULE in $MODULES; do
# Checkout the source code from cvs # Checkout the source code from svn
cd "$LOCALDIR" || cleanup cd "$LOCALDIR"
svn co "$SVNROOT$MODULE" > /dev/null || cleanup svn co "$SVNROOT/$MODULE" > /dev/null
BMODULE=`basename "$MODULE"` BMODULE=`basename "$MODULE"`
# Create one archive for each Business Template # Create one archive for each Business Template
cd "$LOCALDIR/$BMODULE" cd "$LOCALDIR/$BMODULE"
for BT5 in `ls "$LOCALDIR/$BMODULE"`; do for BT5 in `ls "$LOCALDIR/$BMODULE"`; do
if [ -d "$LOCALDIR/$BMODULE/$BT5" ]; then if [ -d "$LOCALDIR/$BMODULE/$BT5" ]; then
tar -zcf "$LOCALDIR/$BT5.bt5" --exclude .svn "$BT5" || cleanup tar -zcf "$LOCALDIR/$BT5.bt5" --exclude .svn "$BT5"
fi fi
done done
done done
# Get the latest version of the genbt5list and generate the index # Get the latest version of the genbt5list and generate the index
cd "$LOCALDIR" || cleanup cd "$LOCALDIR"
svn co "$SVNROOT$GENBTLIST" > /dev/null || cleanup svn co "$SVNROOT/$GENBTLIST" > /dev/null
# Publish the repository # Publish the repository
mv -f "$LOCALDIR/"*.bt5 "$BT5DIR" mv -f "$LOCALDIR/"*.bt5 "$BT5DIR"
# Generate the index from repository directory, in case there are BT5 manually added there # Generate the index from repository directory, in case there are BT5 manually added there
cd "$BT5DIR" || cleanup cd "$BT5DIR"
/usr/bin/python "$LOCALDIR/`basename $GENBTLIST`/genbt5list" > /dev/null /usr/bin/python "$LOCALDIR/`basename $GENBTLIST`/genbt5list" > /dev/null
chmod go+r bt5list chmod go+r bt5list
# Clean up # Clean up
rm -rf $LOCALDIR cleanup
rm -f $LOCKFILE
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment