Commit 4461644a authored by Ophélie Gagnard's avatar Ophélie Gagnard

obs/generic/: Improve and simplify the build scripts and Makefile.

Makefile: Add a target no-obs and its clean_no-obs counterpart.

build-scripts/*:
- Simplify the scripts and add a variable for the path of the current tarball.
- Add new variables and improve the genericization.
build-scripts/obs.sh: Delete .install.cfg in the directory where builtout is run.

templates/*: Improve the templates system: it is no longer needed to modify the templates to build another SR.
templates/Makefile.in: Improve the target management.
parent 116cfdd9
all: build_tree template_stage bootstrap_buildout obs
clean: clean_build_tree clean_template_stage clean_bootstrap_buildout clean_obs
all: no_obs obs
clean: clean_no_obs clean_obs
no_obs: build_tree template_stage bootstrap_buildout
clean_no_obs: clean_build_tree clean_template_stage clean_bootstrap_buildout
build_tree:
build-scripts/build_tree.sh
......@@ -22,4 +25,4 @@ obs:
clean_obs:
build-scripts/clean_obs.sh
.PHONY: all clean build_tree clean_build_tree template_stage clean_template_stage bootstrap_buildout clean_bootstrap_buildout obs clean_obs
.PHONY: all clean no_obs clean_no_obs build_tree clean_build_tree template_stage clean_template_stage bootstrap_buildout clean_bootstrap_buildout obs clean_obs
......@@ -5,12 +5,14 @@ source build-scripts/configuration_information.sh
cd $INITIAL_DIR
# Download the bootstrap script
mkdir -p $RUN_BUILDOUT_DIR
cd $RUN_BUILDOUT_DIR
wget https://bootstrap.pypa.io/bootstrap-buildout.py
cd $INITIAL_DIR
# Create a build/bin/buildout (bootstraping) and run it (actual compilation).
# Note: it creates a lot of things in build/eggs/ and uses software_release/ at some point
mkdir -p $RUN_BUILDOUT_DIR
cd $RUN_BUILDOUT_DIR
# should be with gcc here and without in OBS
cp $TEMPLATE_DIR/tmp/buildout_without_gcc.cfg buildout.cfg
......
......@@ -4,13 +4,12 @@ set -e
source build-scripts/configuration_information.sh
cd $INITIAL_DIR
mkdir -p tarballs/$SOFTWARE/
mkdir -p $TARBALL_DIR
# Re-downloading the software release to pack
cd tarballs/$SOFTWARE/
git clone https://lab.nexedi.com/Francois/slapos
mv slapos software_release
cd software_release
git checkout fluent-bit
#cp -r /home/test/other-projects/model/1wip_simplify-fluentbit_my-slapos .
cp -r /home/test/other-projects/new_slapos.package/sid.fluentbit.my-slapos $TARBALL_DIR
#mv 1wip_simplify-fluentbit_my-slapos software_release
mv $TARBALL_DIR/sid.fluentbit.my-slapos $TARBALL_DIR/software_release
cd $INITIAL_DIR
# Peparing the build directories
......
......@@ -5,17 +5,8 @@ source build-scripts/configuration_information.sh
cd $INITIAL_DIR
# Remove the bootstrap script and associated files
if [[ -d $RUN_BUILDOUT_DIR ]]; then
cd $RUN_BUILDOUT_DIR
rm -f bootstrap.py # LEGACY
rm -f bootstrap-buildout.py*
rm -f buildout.cfg
fi
rm -f $RUN_BUILDOUT_DIR/{bootstrap.py,bootstrap-buildout.py,buildout.cfg}
cd $INITIAL_DIR
# Clean the material created by the bootstrap script
if [[ -d $RUN_BUILDOUT_DIR ]]; then
cd $RUN_BUILDOUT_DIR
rm -rf bin/
rm -rf eggs/
fi
rm -rf $RUN_BUILDOUT_DIR/{bin/,egg/}
......@@ -4,16 +4,13 @@ set -e
source build-scripts/configuration_information.sh
cd $INITIAL_DIR
rm -rf tarballs/$SOFTWARE/
rm -rf $TARBALL_DIR
exit # TODO: separate the tree building from the software release retrieving
cd $INITIAL_DIR
# Clean the software release to pack
if [[ -d tarballs/$SOFTWARE/ ]]; then
cd tarballs/$SOFTWARE/
rm -rf software_release
else echo tarballs/$SOFTWARE/ does not exist.
rm -rf $TARBALL_DIR/software_release
cd $INITIAL_DIR
# Clean the build tree
......
......@@ -5,5 +5,4 @@ source build-scripts/configuration_information.sh
cd $INITIAL_DIR
# Clean temporary directory for templates
cd $TEMPLATE_DIR
rm -rf tmp/
rm -rf $TEMPLATE_DIR/tmp/
......@@ -3,43 +3,54 @@
####################################################
INITIAL_DIR="$(pwd)"/
# Modify the following variables accordingly
# RELEASE INFORMATION
VERSION=1
RECIPE_VERSION=1
# Modify the following variables accordingly
VERSION=0
#RECIPE_VERSION=1
RELEASE=1
SOFTWARE=mca
SOFTWARE_NAME=fluent-bit
COMPOUND_VERSION=${VERSION}-${RELEASE}
VERSION_NAME=${SOFTWARE_NAME}_${COMPOUND_VERSION}
ARCHIVE_EXT=.tar.gz
# INSTALL INFORMATION
TARGET_DIR=/opt/${SOFTWARE}_software_release
TARGET_DIR=/opt/$VERSION_NAME # only used for the templates
# OBS AND DISTRIBUTIONS INFORMATION
OBS_DIR=$INITIAL_DIR/home:oph.nxd/$SOFTWARE_NAME/
DIST_DIR=$INITIAL_DIR/distribution-specifics/$SOFTWARE_NAME/
TARBALL_DIR=$INITIAL_DIR/tarballs/$VERSION_NAME
# BUILD INFORMATION
# Modify the following variables accordingly
SR_PATH=$TARBALL_DIR/software_release/component/lunzip/buildout.cfg
TEMPLATE_DIR=$INITIAL_DIR/templates
BUILD_DIR=$INITIAL_DIR/tarballs/$SOFTWARE/build/ # former BUILD_ROOT_DIRECTORY
BUILD_DIR=$TARBALL_DIR/build/ # former BUILD_ROOT_DIRECTORY
# this is where the parts/ directory will be
RUN_BUILDOUT_DIR=$BUILD_DIR/$TARGET_DIR # former BUILD_DIRECTORY
# OBS AND DISTRIBUTIONS INFORMATION
OBS_DIR=$INITIAL_DIR/home:oph.nxd/$SOFTWARE/
DIST_DIR=$INITIAL_DIR/distribution-specifics/$SOFTWARE/
# Path normalization
INITIAL_DIR=`realpath -m $INITIAL_DIR`
TARGET_DIR=`realpath -m $TARGET_DIR`
OBS_DIR=`realpath -m $OBS_DIR`
DIST_DIR=`realpath -m $DIST_DIR`
TARBALL_DIR=`realpath -m $TARBALL_DIR`
TEMPLATE_DIR=`realpath -m $TEMPLATE_DIR`
BUILD_DIR=`realpath -m $BUILD_DIR`
RUN_BUILDOUT_DIR=`realpath -m $RUN_BUILDOUT_DIR`
OBS_DIR=`realpath -m $OBS_DIR`
DIST_DIR=`realpath -m $DIST_DIR`
# Regular expressions for templates
VERSION_REGEX="s/\%RECIPE_VERSION\%/$RECIPE_VERSION/g;s/\%VERSION\%/$VERSION/g;s/\%RELEASE\%/$RELEASE/g"
# versions (not used at the moment)
VERSION_REGEX="s|\%RECIPE_VERSION\%|$RECIPE_VERSION|g;s|\%VERSION\%|$VERSION|g;s|\%RELEASE\%|$RELEASE|g;s|\%COMPOUND_VERSION\%|$COMPOUND_VERSION|g"
# Note: %PATCHES_DIRECTORY% not supported yet
# supporting new macros
DIR_REGEX="s|\%TARGET_DIR\%|$TARGET_DIR|g;s|\%BUILD_DIR\%|$BUILD_DIR|g;s|\%RUN_BUILDOUT_DIR\%|$RUN_BUILDOUT_DIR|g"
# supporting legacy macros
OLD_DIR_REGEX="s|\%TARGET_DIRECTORY\%|$TARGET_DIR|g;s|\%BUILD_ROOT_DIRECTORY\%|$BUILD_DIR|g;s|\%BUILD_DIRECTORY\%|$RUN_BUILDOUT_DIR|g"
# directories (supporting new macros)
DIR_REGEX="s|\%TARGET_DIR\%|$TARGET_DIR|g;s|\%BUILD_DIR\%|$BUILD_DIR#g;s|\%RUN_BUILDOUT_DIR\%|$RUN_BUILDOUT_DIR|g"
PATH_REGEX="s|\%SR_PATH\%|$SR_PATH|g"
# directories (supporting legacy macros, not used anymore)
#OLD_DIR_REGEX="s|\%TARGET_DIRECTORY\%|$TARGET_DIR|g;s|\%BUILD_ROOT_DIRECTORY\%|$BUILD_DIR|g;s|\%BUILD_DIRECTORY\%|$RUN_BUILDOUT_DIR|g"
# concatenate all regex using ; (quoted, not to end the command)
ALL_REGEX=$VERSION_REGEX";"$DIR_REGEX";"$OLD_DIR_REGEX
ALL_REGEX=$VERSION_REGEX";"$DIR_REGEX";"$SR_PATH #";"$OLD_DIR_REGEX
......@@ -9,21 +9,21 @@ TMP_DIR=`realpath -m $TMP_DIR`
echo TMP_DIR = $TMP_DIR
# copy the Makefile at the root of the tarball
cp $TEMPLATE_DIR/Makefile tarballs/$SOFTWARE/Makefile
#cp $TEMPLATE_DIR/tmp/Makefile $TARBALL_DIR/Makefile
# save the local BUILD_DIR to replace it with the BUILD_DIR of OBS' VM
echo $BUILDIR > tarball/$SOFTWARE/cache_creation_build_directory
echo $BUILD_DIR > $TARBALL_DIR/cache_creation_build_directory
# clean the parts directory
rm -rf $RUN_BUILDOUT_DIR/parts/
rm -rf $RUN_BUILDOUT_DIR/{.installed.cfg,parts/}
## prepare the files for OBS
mkdir -p $TMP_DIR
# -C option allows to give tar an absolute path without archiving the directory from / (i.e. home/user/[...])
tar czf $TMP_DIR/$SOFTWARE.tar.gz -C tarballs/ $SOFTWARE/
tar czf $TMP_DIR/${VERSION_NAME}${ARCHIVE_EXT} -C $INITIAL_DIR/tarballs/ $VERSION_NAME/
tar czf $TMP_DIR/debian.tar.gz -C $DIST_DIR/ debian/
cp $DIST_DIR/*.dsc $TMP_DIR/
# move the files for OBS
cp $TMP_DIR/$SOFTWARE.tar.gz $OBS_DIR
cp $TMP_DIR/${VERSION_NAME}${ARCHIVE_EXT} $OBS_DIR
cp $TMP_DIR/debian.tar.gz $OBS_DIR
cp $TMP_DIR/*.dsc $OBS_DIR
......
......@@ -5,8 +5,7 @@ source build-scripts/configuration_information.sh
cd $INITIAL_DIR
# Prepare the templates in $TEMPLATE_DIR/tmp/
cd $TEMPLATE_DIR
mkdir -p tmp/
sed $ALL_REGEX buildout_with_gcc.cfg.in > tmp/buildout_with_gcc.cfg
sed $ALL_REGEX buildout_without_gcc.cfg.in > tmp/buildout_without_gcc.cfg
sed $ALL_REGEX Makefile.in > tmp/Makefile
mkdir -p $TEMPLATE_DIR/tmp/
sed $ALL_REGEX $TEMPLATE_DIR/buildout_with_gcc.cfg.in > $TEMPLATE_DIR/tmp/buildout_with_gcc.cfg
sed $ALL_REGEX $TEMPLATE_DIR/buildout_without_gcc.cfg.in > $TEMPLATE_DIR/tmp/buildout_without_gcc.cfg
sed $ALL_REGEX $TEMPLATE_DIR/Makefile.in > $TEMPLATE_DIR/tmp/Makefile
VERSION = 1
RECIPE_VERSION = 1
PY = $(PYTHON)
#INSTALL_DIRECTORY = $(DESTDIR)/opt/test
#TARGET_DIRECTORY = /opt/slapos
#INSTALL_DIR = $(DESTDIR)/opt/test
#TARGET_DIR = /opt/slapos
# This templates are replaced by build-scripts/template_stage.sh
# according to the values and regular expressions defined in
# build-scripts/configuration_information.sh
TARGET_DIRECTORY = %TARGET_DIR%
TARGET_DIR = %TARGET_DIR% # this variable is pretty useless atm
BUILD_DIR = $(shell pwd)/build
RUN_BUILDOUT_DIR = $(BUILD_DIR)$(TARGET_DIRECTORY)
#PATCHES_DIRECTORY := $(shell pwd)/patches
INSTALL_DIR = $(BUILD_DIR)$(TARGET_DIR)
RUN_BUILDOUT_DIR = $(BUILD_DIR)$(TARGET_DIR)
#PATCHES_DIR := $(shell pwd)/patches
# get the path of the BUILD_DIR of the first build (performed to prepare the cache for OBS)
OLD_BUILD_DIR := $(shell cat cache_creation_build_directory)
......@@ -42,18 +40,16 @@ clean:
install: all
#cd slapos; make install
mkdir -p $(DESTDIR)/usr/bin/
mkdir -p $(DESTDIR)/usr/sbin/
mkdir -p $(DESTDIR)/usr/etc/
mkdir -p $(DESTDIR)/usr/lib/
mkdir -p $(DESTDIR)/usr/share/
mkdir -p $(DESTDIR)/opt
mkdir -p $(INSTALL_DIR)/bin
mkdir -p $(INSTALL_DIR)/sbin/
mkdir -p $(INSTALL_DIR)/etc/
mkdir -p $(INSTALL_DIR)/lib/
mkdir -p $(INSTALL_DIR)/share/
#cp `find $(RUN_BUILDOUT_DIR) | grep -e "^$(RUN_BUILDOUT_DIR)/[^/][^/]*/bin/*` $(DESTDIR)/usr/bin/
-cp -r $(RUN_BUILDOUT_DIR)/parts/*/bin/* $(DESTDIR)/usr/bin/
-cp -r $(RUN_BUILDOUT_DIR)/parts/*/sbin/* $(DESTDIR)/usr/sbin/
-cp -r $(RUN_BUILDOUT_DIR)/parts/*/etc/* $(DESTDIR)/usr/etc/
-cp -r $(RUN_BUILDOUT_DIR)/parts/*/lib/* $(DESTDIR)/usr/lib/
-cp -r $(RUN_BUILDOUT_DIR)/parts/*/share/* $(DESTDIR)/usr/share/
-cp -r $(RUN_BUILDOUT_DIR)/parts/*/opt/* $(DESTDIR)/opt
-cp -r $(RUN_BUILDOUT_DIR)/parts/*/bin/* $(INSTALL_DIR)/bin/
-cp -r $(RUN_BUILDOUT_DIR)/parts/*/sbin/* $(INSTALL_DIR)/sbin/
-cp -r $(RUN_BUILDOUT_DIR)/parts/*/etc/* $(INSTALL_DIR)/etc/
-cp -r $(RUN_BUILDOUT_DIR)/parts/*/lib/* $(INSTALL_DIR)/lib/
-cp -r $(RUN_BUILDOUT_DIR)/parts/*/share/* $(INSTALL_DIR)/share/
.PHONY: build all clean install
[buildout]
rootdir = %TARGET_DIR%
destdir = %BUILD_DIR%
builddir = %PARTS_DIR%
destdir = %BUILD_DIR%
builddir = %RUN_BUILDOUT_DIR%
extends =
%SR_PATH%
# %BUILD_DIR%/../software_release/software/fluent-bit/software.cfg
%BUILD_DIR%/../software_release/component/fluent-bit/buildout.cfg
# %TARBALL_DIR%/software_release/software/fluent-bit/software.cfg
# %TARBALL_DIR%/software_release/component/fluent-bit/buildout.cfg
# %BUILD_DIR%/../software_release/component/fluent-bit/buildout.cfg
versions = versions
extends-cache = extends-cache
download-cache = download-cache
......
[buildout]
rootdir = %TARGET_DIR%
destdir = %BUILD_DIR%
builddir = %PARTS_DIRY%
builddir = %RUN_BUILDOUT_DIR%
extends =
%SR_PATH%
# %BUILD_DIR%/../software_release/software/fluent-bit/software.cfg
%BUILD_DIR%/../software_release/component/fluent-bit/buildout.cfg
# %TARBALL_DIR%/software_release/software/fluent-bit/software.cfg
# %TARBALL_DIR%/software_release/component/fluent-bit/buildout.cfg
# %BUILD_DIR%/../software_release/component/fluent-bit/buildout.cfg
versions = versions
extends-cache = extends-cache
download-cache = download-cache
......
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