Commit 5f26a014 authored by Ophélie Gagnard's avatar Ophélie Gagnard

build-scripts/: Add " " around variables.

parent 9d300524
......@@ -15,13 +15,13 @@ SOFTWARE_NAME=dep--mca--static
# here, in <foo>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
# VersionNumber is SOFTWARE_VERSION, DebianRevisionNumber is DEBIAN_REVISION
# note: the architecture is added when building the package (here: in OBS)
COMPOUND_VERSION=${SOFTWARE_VERSION}-${DEBIAN_REVISION}
SOFTWARE_AND_VERSION=${SOFTWARE_NAME}_${COMPOUND_VERSION}
COMPOUND_VERSION="${SOFTWARE_VERSION}-${DEBIAN_REVISION}"
SOFTWARE_AND_VERSION="${SOFTWARE_NAME}_${COMPOUND_VERSION}"
ARCHIVE_EXT=.tar.gz
### INSTALL INFORMATION ###
# TARGET_DIR is only used in the templates via sed regexps
TARGET_DIR=/opt/$SOFTWARE_AND_VERSION
TARGET_DIR=/opt/"$SOFTWARE_AND_VERSION"
### OBS AND DISTRIBUTIONS INFORMATION ###
# get the user from osc configuration file
......
......@@ -3,16 +3,16 @@ set -e
source build-scripts/00env.sh
cd $INITIAL_DIR
cd "$INITIAL_DIR"
### Retrieve the buildout directory.
# Note: This is usually a slapos git repository but it can be otherwise.
# There needs to be at least one buildout file to point to (the entry point) which can extend other build files. See the buildout documentation if this is unclear.
mkdir -p $TARBALL_DIR
#cp -r /home/test/other-projects/model/mca.my-slapos $TARBALL_DIR/software_release
git clone https://lab.nexedi.com/Ophelie/slapos $BUILDOUT_DIR
cd $BUILDOUT_DIR
mkdir -p "$TARBALL_DIR"
#cp -r /home/test/other-projects/model/mca.my-slapos "$TARBALL_DIR/software_release"
git clone https://lab.nexedi.com/Ophelie/slapos "$BUILDOUT_DIR"
cd "$BUILDOUT_DIR"
git checkout metadata-collect-agent
cd $INITIAL_DIR
cd "$INITIAL_DIR"
### Peparing the build directories
mkdir -p $RUN_BUILDOUT_DIR/{eggs,extends-cache,download-cache/dist}
mkdir -p "$RUN_BUILDOUT_DIR"/{eggs,extends-cache,download-cache/dist}
......@@ -3,16 +3,16 @@ set -e
source build-scripts/00env.sh
cd $INITIAL_DIR
cd "$INITIAL_DIR"
# Prepare the templates in $COMPILATION_TEMPLATES_DIR/tmp/$SOFTWARE_NAME
mkdir -p $COMPILATION_TEMPLATES_DIR/tmp/$SOFTWARE_NAME
mkdir -p "$COMPILATION_TEMPLATES_DIR"/tmp/"$SOFTWARE_NAME"
# if a custom directory exist for compilation templates, choose it
# otherwise, default to .../_generic
ACTUAL_TEMPLATES_DIR=$COMPILATION_TEMPLATES_DIR/$SOFTWARE_NAME
if [ ! -d $ACTUAL_TEMPLATES_DIR ]; then
ACTUAL_TEMPLATES_DIR=$COMPILATION_TEMPLATES_DIR/_generic
ACTUAL_TEMPLATES_DIR="$COMPILATION_TEMPLATES_DIR"/"$SOFTWARE_NAME"
if [ ! -d "$ACTUAL_TEMPLATES_DIR" ]; then
ACTUAL_TEMPLATES_DIR="$COMPILATION_TEMPLATES_DIR"/_generic
fi
sed $ALL_REGEX $ACTUAL_TEMPLATES_DIR/local_buildout.cfg.in > $COMPILATION_TEMPLATES_DIR/tmp/$SOFTWARE_NAME/local_buildout.cfg
sed $ALL_REGEX $ACTUAL_TEMPLATES_DIR/Makefile.in > $COMPILATION_TEMPLATES_DIR/tmp/$SOFTWARE_NAME/Makefile
sed "$ALL_REGEX" "$ACTUAL_TEMPLATES_DIR"/local_buildout.cfg.in > "$COMPILATION_TEMPLATES_DIR"/tmp/"$SOFTWARE_NAME"/local_buildout.cfg
sed $"ALL_REGEX" "$ACTUAL_TEMPLATES_DIR"/Makefile.in > "$COMPILATION_TEMPLATES_DIR"/tmp/"$SOFTWARE_NAME"/Makefile
......@@ -3,19 +3,19 @@ set -e
source build-scripts/00env.sh
cd $INITIAL_DIR
cd "$INITIAL_DIR"
### Download the bootstrap script
mkdir -p $RUN_BUILDOUT_DIR
cd $RUN_BUILDOUT_DIR
mkdir -p "$RUN_BUILDOUT_DIR"
cd "$RUN_BUILDOUT_DIR"
wget https://bootstrap.pypa.io/bootstrap-buildout.py
cd $INITIAL_DIR
cd "$INITIAL_DIR"
### Create a $RUN_BUILDOUT_DIR/bin/buildout (bootstraping) and run it (actual compilation).
# Note: it creates a lot of things in $RUN_BUILDOUT_DIR/eggs/ and uses software_release/ at some point
mkdir -p $RUN_BUILDOUT_DIR
cd $RUN_BUILDOUT_DIR
mkdir -p "$RUN_BUILDOUT_DIR"
cd "$RUN_BUILDOUT_DIR"
# should be with gcc here and without in OBS
cp $COMPILATION_TEMPLATES_DIR/tmp/$SOFTWARE_NAME/local_buildout.cfg buildout.cfg
cp "$COMPILATION_TEMPLATES_DIR"/tmp/"$SOFTWARE_NAME"/local_buildout.cfg buildout.cfg
## next line explained
# 1st cmd: bootstrap buildout (creates bin/buildout)
# 2nd cmd: backup $RUN_BUILDOUT_DIR/bin/buildout (to be restored for OBS)
......
......@@ -3,7 +3,7 @@ set -e
source build-scripts/00env.sh
cd $INITIAL_DIR
cd "$INITIAL_DIR"
### Fix the go/ directory.
# For some reason the user does not have the "write" permission on some directories within $RUN_BUILDOUT_DIR/go/. As it is
......@@ -11,16 +11,16 @@ cd $INITIAL_DIR
# directories in go/.
# This is performed before copying the directory tree elsewhere so that every copy is fixed.
# It also allows the cleaning script to delete the result of the current script.
if [ -d $RUN_BUILDOUT_DIR/go ]; then
find $RUN_BUILDOUT_DIR/go -name "*" -type d -exec chmod u+xw {} +
if [ -d "$RUN_BUILDOUT_DIR"/go ]; then
find "$RUN_BUILDOUT_DIR"/go -name "*" -type d -exec chmod u+xw {} +
fi
cd $INITIAL_DIR
cd "$INITIAL_DIR"
### Backup $TARBALL_DIR for debugging or other purpose
# add "backup." before the directory name pointed to by $TARBALL_DIR
BACKUP_DIR=$TARBALL_DIR/../backup.$SOFTWARE_AND_VERSION
BACKUP_DIR=`realpath -m $BACKUP_DIR`
BACKUP_DIR="$TARBALL_DIR"/../backup."$SOFTWARE_AND_VERSION"
BACKUP_DIR=$(realpath -m "$BACKUP_DIR")
# Delete the potential previous backup and backup the newly created build tree instead.
rm -rf $BACKUP_DIR
cp -r $TARBALL_DIR $BACKUP_DIR
rm -rf "$BACKUP_DIR"
cp -r "$TARBALL_DIR" "$BACKUP_DIR"
......@@ -3,28 +3,28 @@ set -e
source build-scripts/00env.sh
cd $INITIAL_DIR
cd "$INITIAL_DIR"
# Prepare the templates in $DISTRIB_TEMPLATES_DIR/tmp/
TMP_TARGET=$DISTRIB_TEMPLATES_DIR/tmp/$SOFTWARE_NAME/
mkdir -p $TMP_TARGET
sed $ALL_REGEX $DISTRIB_TEMPLATES_DIR/default.dsc.in > $TMP_TARGET/$SOFTWARE_AND_VERSION.dsc
TMP_TARGET="$DISTRIB_TEMPLATES_DIR"/tmp/"$SOFTWARE_NAME"/
mkdir -p "$TMP_TARGET"
sed "$ALL_REGEX" "$DISTRIB_TEMPLATES_DIR"/default.dsc.in > "$TMP_TARGET"/"$SOFTWARE_AND_VERSION".dsc
# debian directory
mkdir -p $TMP_TARGET/debian/
sed $ALL_REGEX $DISTRIB_TEMPLATES_DIR/debian_default/changelog.in > $TMP_TARGET/debian/changelog
sed $ALL_REGEX $DISTRIB_TEMPLATES_DIR/debian_default/control.in > $TMP_TARGET/debian/control
sed $ALL_REGEX $DISTRIB_TEMPLATES_DIR/debian_default/dirs.in > $TMP_TARGET/debian/dirs
cp -r $DISTRIB_TEMPLATES_DIR/debian_default/{compat,copyright,rules,source} $TMP_TARGET/debian/
mkdir -p "$TMP_TARGET"/debian/
sed "$ALL_REGEX" "$DISTRIB_TEMPLATES_DIR"/debian_default/changelog.in > "$TMP_TARGET"/debian/changelog
sed "$ALL_REGEX" "$DISTRIB_TEMPLATES_DIR"/debian_default/control.in > "$TMP_TARGET"/debian/control
sed "$ALL_REGEX" "$DISTRIB_TEMPLATES_DIR"/debian_default/dirs.in > "$TMP_TARGET"/debian/dirs
cp -r "$DISTRIB_TEMPLATES_DIR"/debian_default/{compat,copyright,rules,source} "$TMP_TARGET"/debian/
# TODO: do it with "find" instead?
#find $DISTRIB_TEMPLATES_DIR/debian_defaults/ -type f -name * -exec sed $ALL_REGEX {} + > $TMP_TARGET/debian/
#find "$DISTRIB_TEMPLATES_DIR"/debian_defaults/ -type f -name * -exec sed "$ALL_REGEX" {} + > "$TMP_TARGET"/debian/
# If a directory for the current software does not already exist in distrubion-specifics:
# create it and copy the product of the templates in it,
# otherwise do nothing.
# The files created form the templates are still available in $TMP_TARGET
if [ ! -d $DISTRIB_FILES_DIR ]; then
mkdir -p $DISTRIB_FILES_DIR
cp -r $TMP_TARGET/* $DISTRIB_FILES_DIR/
if [ ! -d "$DISTRIB_FILES_DIR" ]; then
mkdir -p "$DISTRIB_FILES_DIR"
cp -r "$TMP_TARGET"/* "$DISTRIB_FILES_DIR"/
# A file is created so that the cleaning script can reverse the action of the current script.
echo -e "This file's only purpose is to tell the cleaning script to delete this directory.\nThere should not be such file in a manually crafted directory.\n" >> $DISTRIB_FILES_DIR/.toclean-stamp
echo -e "This file's only purpose is to tell the cleaning script to delete this directory.\nThere should not be such file in a manually crafted directory.\n" >> "$DISTRIB_FILES_DIR"/.toclean-stamp
fi
......@@ -4,32 +4,32 @@ set -e
source build-scripts/00env.sh
# temporary directory for the files needed by OBS
TMP_TARGET=$INITIAL_DIR/obs-tmp/$SOFTWARE_NAME
TMP_TARGET=`realpath -m $TMP_TARGET`
echo TMP_TARGET = $TMP_TARGET
TMP_TARGET="$INITIAL_DIR"/obs-tmp/"$SOFTWARE_NAME"
TMP_TARGET=$(realpath -m "$TMP_TARGET")
echo TMP_TARGET = "$TMP_TARGET"
# copy the generated Makefile at the root of the tarball
cp $COMPILATION_TEMPLATES_DIR/tmp/$SOFTWARE_NAME/Makefile $TARBALL_DIR/Makefile
cp "$COMPILATION_TEMPLATES_DIR"/tmp/"$SOFTWARE_NAME"/Makefile "$TARBALL_DIR"/Makefile
# save the local TARBALL_DIR to replace it with the TARBALL_DIR of OBS' VM
echo $TARBALL_DIR > $TARBALL_DIR/local_build_directory
echo "$TARBALL_DIR" > "$TARBALL_DIR"/local_build_directory
# restore bin/buildout
# note: when installing python, buildout "rebootstrap" itself to use the installed python: it would fail on OBS' VM
mv $RUN_BUILDOUT_DIR/bin/backup.buildout $RUN_BUILDOUT_DIR/bin/buildout
mv "$RUN_BUILDOUT_DIR"/bin/backup.buildout "$RUN_BUILDOUT_DIR"/bin/buildout
# clean the parts directory
rm -rf $RUN_BUILDOUT_DIR/{.installed.cfg,parts/}
rm -rf "$RUN_BUILDOUT_DIR"/{.installed.cfg,parts/}
## prepare the files for OBS
mkdir -p $TMP_TARGET
mkdir -p "$TMP_TARGET"
# -C option allows to give tar an absolute path without archiving the directory from / (i.e. home/user/[...])
tar czf $TMP_TARGET/${SOFTWARE_AND_VERSION}${ARCHIVE_EXT} -C $INITIAL_DIR/tarballs/ $SOFTWARE_AND_VERSION/
tar czf $TMP_TARGET/debian.tar.gz -C $DIST_DIR/ debian/
cp $DIST_DIR/*.dsc $TMP_TARGET/
tar czf "$TMP_TARGET"/"${SOFTWARE_AND_VERSION}""${ARCHIVE_EXT}" -C "$INITIAL_DIR"/tarballs/ "$SOFTWARE_AND_VERSION"/
tar czf "$TMP_TARGET"/debian.tar.gz -C "$DIST_DIR"/ debian/
cp "$DIST_DIR"/*.dsc "$TMP_TARGET"/
# move the files for OBS
cp $TMP_TARGET/${SOFTWARE_AND_VERSION}${ARCHIVE_EXT} $OBS_DIR
cp $TMP_TARGET/debian.tar.gz $OBS_DIR
cp $TMP_TARGET/*.dsc $OBS_DIR
cp "$TMP_TARGET"/"${SOFTWARE_AND_VERSION}""${ARCHIVE_EXT}" "$OBS_DIR"
cp "$TMP_TARGET/debian.tar.gz "$OBS_DIR"
cp "$TMP_TARGET/*.dsc "$OBS_DIR"
cd $OBS_DIR
cd "$OBS_DIR"
osc add *.dsc *.tar.gz
osc commit
......@@ -3,21 +3,21 @@ set -e
source build-scripts/00env.sh
cd $INITIAL_DIR
cd "$INITIAL_DIR"
# For some reason the user does not have the "write" permission on some directories of go/. As it is
# needed on a directory to delete a file in it, the if block add the permissions to every
# directories in go/.
if [ -d $RUN_BUILDOUT_DIR/go ]; then
find $RUN_BUILDOUT_DIR/go -name "*" -type d -exec chmod u+xw {} +
if [ -d "$RUN_BUILDOUT_DIR"/go ]; then
find "$RUN_BUILDOUT_DIR"/go -name "*" -type d -exec chmod u+xw {} +
fi
rm -rf $TARBALL_DIR
rm -rf "$TARBALL_DIR"
exit # TODO: separate the tree building from the software release retrieving
cd $INITIAL_DIR
cd "$INITIAL_DIR"
# Clean the software release to pack
rm -rf $TARBALL_DIR/software_release
rm -rf "$TARBALL_DIR"/software_release
cd $INITIAL_DIR
cd "$INITIAL_DIR"
# Clean the build tree
rm -rf $RUN_BUILDOUT_DIR/{eggs,extends-cache,download-cache}
rm -rf "$RUN_BUILDOUT_DIR"/{eggs,extends-cache,download-cache}
......@@ -3,6 +3,6 @@ set -e
source build-scripts/00env.sh
cd $INITIAL_DIR
cd "$INITIAL_DIR"
# Clean temporary directory for templates
rm -rf $COMPILATION_TEMPLATES_DIR/tmp/$SOFTWARE_NAME
rm -rf "$COMPILATION_TEMPLATES_DIR"/tmp/"$SOFTWARE_NAME"
......@@ -3,11 +3,11 @@ set -e
source build-scripts/00env.sh
cd $INITIAL_DIR
cd "$INITIAL_DIR"
# Remove the products of the script bootstrap_buildout.sh
# remove the bootstrap script and associated files
rm -f $RUN_BUILDOUT_DIR/{bootstrap.py,bootstrap-buildout.py,buildout.cfg}
rm -f "$RUN_BUILDOUT_DIR"/{bootstrap.py,bootstrap-buildout.py,buildout.cfg}
# remove the material created by the bootstrap script
rm -rf $RUN_BUILDOUT_DIR/{bin/,egg/}
rm -rf "$RUN_BUILDOUT_DIR"/{bin/,egg/}
# remove the material created by buildout itself
rm -rf $RUN_BUILDOUT_DIR/go/
rm -rf "$RUN_BUILDOUT_DIR"/go/
......@@ -3,5 +3,5 @@ set -e
source build-scripts/00env.sh
cd $INITIAL_DIR
# Nothing is done here, as 04backup_tarball.sh only modifies permissions in $RUN_BUILDOUT_DIR/go/ and backs up the $TARBALL_DIR (one do not want to delete the backup if it's not to create a new one).
cd "$INITIAL_DIR"
# Nothing is done here, as 04backup_tarball.sh only modifies permissions in "$RUN_BUILDOUT_DIR"/go/ and backs up the "$TARBALL_DIR" (one do not want to delete the backup if it's not to create a new one).
......@@ -3,11 +3,11 @@ set -e
source build-scripts/00env.sh
cd $INITIAL_DIR
# Clean the temporary directory of distribution files for $SOFTWARE_NAME
rm -rf $DISTRIB_TEMPLATES_DIR/tmp/$SOFTWARE_NAME
cd "$INITIAL_DIR"
# Clean the temporary directory of distribution files for "$SOFTWARE_NAME"
rm -rf "$DISTRIB_TEMPLATES_DIR"/tmp/"$SOFTWARE_NAME"
# Only delete the directory is the file .toclean-stam is present in it. It should only be created
# when the directory is automatically generated so that the cleaning script can reverse the action.
if [ -e $DISTRIB_FILES_DIR/.toclean-stamp ]; then
rm -rf $DISTRIB_FILES_DIR
if [ -e "$DISTRIB_FILES_DIR"/.toclean-stamp ]; then
rm -rf "$DISTRIB_FILES_DIR"
fi
......@@ -4,15 +4,15 @@ set -e
source build-scripts/00env.sh
# reverse the action of obsoleting the potentially altered buildout and restoring the backed up one
if [ ! -e $RUN_BUILDOUT_DIR/bin/backup.buildout ]; then
if [ -e $RUN_BUILDOUT_DIR/bin/buildout ]; then
cp $RUN_BUILDOUT_DIR/bin/buildout $RUN_BUILDOUT_DIR/bin/backup.buildout
if [ ! -e "$RUN_BUILDOUT_DIR"/bin/backup.buildout ]; then
if [ -e "$RUN_BUILDOUT_DIR"/bin/buildout ]; then
cp "$RUN_BUILDOUT_DIR"/bin/buildout "$RUN_BUILDOUT_DIR"/bin/backup.buildout
fi
fi
if [ -e $RUN_BUILDOUT_DIR/bin/old.buildout ]; then
mv $RUN_BUILDOUT_DIR/bin/old.buildout $RUN_BUILDOUT_DIR/bin/buildout
if [ -e "$RUN_BUILDOUT_DIR"/bin/old.buildout ]; then
mv "$RUN_BUILDOUT_DIR"/bin/old.buildout "$RUN_BUILDOUT_DIR"/bin/buildout
fi
TMP_TARGET=$INITIAL_DIR/obs-tmp/$SOFTWARE_NAME
TMP_TARGET=`realpath -m $TMP_TARGET`
rm -rf $TMP_TARGET
TMP_TARGET="$INITIAL_DIR"/obs-tmp/"$SOFTWARE_NAME"
TMP_TARGET=$(realpath -m "$TMP_TARGET")
rm -rf "$TMP_TARGET"
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