Commit 6e9230cd authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

Generic improvements

See merge request !169
parents a0b4bdb1 85563803
Pipeline #23617 failed with stage
in 0 seconds
......@@ -63,12 +63,12 @@ BUILDOUT_ENTRY_POINT=$(realpath -m "$BUILDOUT_ENTRY_POINT")
OBS_DIR="$INITIAL_DIR/$OBS_PROJECT/$OBS_PACKAGE"
## Regular expressions for templates
NAME_REGEX="s|%SOFTWARE_NAME%|$SOFTWARE_NAME|g;s|%SOFTWARE_AND_VERSION%|$SOFTWARE_AND_VERSION|g"
VERSION_REGEX="s|%SOFTWARE_VERSION%|$SOFTWARE_VERSION|g;s|%DEBIAN_REVISION%|$DEBIAN_REVISION|g;s|%COMPOUND_VERSION%|$COMPOUND_VERSION|g"
BUILDOUT_REGEX="s|%SETUPTOOLS_VERSION%|$SETUPTOOLS_VERSION|g;s|%ZC_BUILDOUT_VERSION%|$ZC_BUILDOUT_VERSION|g;s|%ZC_RECIPE_EGG_VERSION%|$ZC_RECIPE_EGG_VERSION|g"
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|%BUILDOUT_ENTRY_POINT%|$BUILDOUT_ENTRY_POINT|g"
DISTRIB_REGEX="s|%MAINTAINER_NAME%|$MAINTAINER_NAME|g;s|%MAINTAINER_EMAIL%|$MAINTAINER_EMAIL|g;s|%CURRENT_DATE%|$CURRENT_DATE|g;s|%PACKAGE_SECTION%|$PACKAGE_SECTION|g;s|%PACKAGE_PRIORITY%|$PACKAGE_PRIORITY|g;s|%PACKAGE_BUILD_DEPENDENCIES%|$PACKAGE_BUILD_DEPENDENCIES|g;s|%PACKAGE_ARCHITECTURE%|$PACKAGE_ARCHITECTURE|g;s|%PACKAGE_DEPENDENCIES%|$PACKAGE_DEPENDENCIES|g;s|%PACKAGE_CONFLICTS%|$PACKAGE_CONFLICTS|g;s|%PACKAGE_SHORT_DESCRIPTION%|$PACKAGE_SHORT_DESCRIPTION|g;s|%PACKAGE_DISTRIBUTION_VALUE%|$PACKAGE_DISTRIBUTION_VALUE|g;s|%PACKAGE_URGENCY%|$PACKAGE_URGENCY|g;s|%PACKAGE_CHANGE_DETAILS%|$PACKAGE_CHANGE_DETAILS|g;s|%PACKAGE_DIRECTORIES%|$PACKAGE_DIRECTORIES|g"
NAME_REGEX="s§%SOFTWARE_NAME%§$SOFTWARE_NAME§g;s§%SOFTWARE_AND_VERSION%§$SOFTWARE_AND_VERSION§g"
VERSION_REGEX="s§%SOFTWARE_VERSION%§$SOFTWARE_VERSION§g;s§%DEBIAN_REVISION%§$DEBIAN_REVISION§g;s§%COMPOUND_VERSION%§$COMPOUND_VERSION§g"
BUILDOUT_REGEX="s§%SETUPTOOLS_VERSION%§$SETUPTOOLS_VERSION§g;s§%ZC_BUILDOUT_VERSION%§$ZC_BUILDOUT_VERSION§g;s§%ZC_RECIPE_EGG_VERSION%§$ZC_RECIPE_EGG_VERSION§g"
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§%BUILDOUT_ENTRY_POINT%§$BUILDOUT_ENTRY_POINT§g"
DISTRIB_REGEX="s§%MAINTAINER_NAME%§$MAINTAINER_NAME§g;s§%MAINTAINER_EMAIL%§$MAINTAINER_EMAIL§g;s§%CURRENT_DATE%§$CURRENT_DATE§g;s§%PACKAGE_SECTION%§$PACKAGE_SECTION§g;s§%PACKAGE_PRIORITY%§$PACKAGE_PRIORITY§g;s§%PACKAGE_BUILD_DEPENDENCIES%§$PACKAGE_BUILD_DEPENDENCIES§g;s§%PACKAGE_ARCHITECTURE%§$PACKAGE_ARCHITECTURE§g;s§%PACKAGE_DEPENDENCIES%§$PACKAGE_DEPENDENCIES§g;s§%PACKAGE_CONFLICTS%§$PACKAGE_CONFLICTS§g;s§%PACKAGE_SHORT_DESCRIPTION%§$PACKAGE_SHORT_DESCRIPTION§g;s§%PACKAGE_DISTRIBUTION_VALUE%§$PACKAGE_DISTRIBUTION_VALUE§g;s§%PACKAGE_URGENCY%§$PACKAGE_URGENCY§g;s§%PACKAGE_CHANGE_DETAILS%§$PACKAGE_CHANGE_DETAILS§g;s§%PACKAGE_DIRECTORIES%§$PACKAGE_DIRECTORIES§g"
ALL_REGEX=$NAME_REGEX";"$VERSION_REGEX";"$BUILDOUT_REGEX";"$DIR_REGEX";"$PATH_REGEX";"$DISTRIB_REGEX
copy_and_solve_templates () {
......
......@@ -43,8 +43,6 @@ python2.7 -S bootstrap-buildout.py \
--buildout-version "$ZC_BUILDOUT_VERSION" \
--setuptools-version "$SETUPTOOLS_VERSION" \
--setuptools-to-dir eggs -f http://www.nexedi.org/static/packages/source/slapos.buildout/
# backup $RUN_BUILDOUT_DIR/bin/buildout (to be restored for OBS)
cp bin/buildout bin/backup.buildout
# run $RUN_BUILDOUT_DIR/bin/buildout (note that it modifies itself via rebootstrapping when compiling python)
./bin/buildout -v
......
......@@ -9,7 +9,7 @@ source _generic/build-scripts/00env.sh
osc checkout "$OBS_PROJECT" "$OBS_PACKAGE" || true
cd "$OBS_DIR"
osc update
osc rm -f "$SOFTWARE_AND_VERSION$ARCHIVE_EXT" "$SOFTWARE_AND_VERSION".dsc
osc rm "$SOFTWARE_AND_VERSION$ARCHIVE_EXT" "$SOFTWARE_AND_VERSION".dsc || true
cd "$INITIAL_DIR"
# copy compilation files and override the files from _generic
......@@ -22,19 +22,13 @@ copy_and_solve_templates "$DISTRIB_FILES_SOFTWARE_DIR" "$OBS_DIR"
### Finalize the tarball directory preparation
# switch to the buildout wrapper for OBS
mv "$TARBALL_DIR/obs_buildout.cfg" "$RUN_BUILDOUT_DIR/buildout.cfg"
cp "$TARBALL_DIR/obs_buildout.cfg" "$RUN_BUILDOUT_DIR/buildout.cfg"
# save the local $TARBALL_DIR path so that it is replaced by the $TARBALL_DIR path from OBS' VM
echo "$TARBALL_DIR" > "$TARBALL_DIR"/local_tarball_directory_path
# add a stamp so that OBS does not clean the local preparation before compiling
touch "$TARBALL_DIR/clean-stamp"
# restore bin/buildout
# note: when installing python, buildout "rebootstraps" itself to use the installed python:
# it modifies its own shebang, which would fail on OBS' VM (no such file or directory)
if [ -f "$RUN_BUILDOUT_DIR"/bin/backup.buildout ]; then
mv "$RUN_BUILDOUT_DIR"/bin/backup.buildout "$RUN_BUILDOUT_DIR"/bin/buildout
fi
# clean the compilation related files
rm -rf "$RUN_BUILDOUT_DIR"/{.installed.cfg,parts}
rm -rf "$RUN_BUILDOUT_DIR"/{.installed.cfg,downloads,parts,eggs,develop-eggs,bin,rebootstrap}
### Prepare the archives for OBS
# -C option allows to give tar an absolute path without archiving the directory from / (i.e. home/user/[...])
......@@ -44,7 +38,7 @@ tar czf "$OBS_DIR/debian$ARCHIVE_EXT" -C "$OBS_DIR" debian
# OBS COMMIT
cd "$OBS_DIR"
osc add *.dsc *"$ARCHIVE_EXT"
osc add *.spec *.dsc *"$ARCHIVE_EXT"
if [ -n "$OBS_COMMIT_MSG" ]; then
osc commit -m "$OBS_COMMIT_MSG"
else
......
#!/usr/bin/python3 -S
import glob, os, shutil, sys, tarfile, tempfile, zipfile
dist = "download-cache/dist"
tmp = tempfile.mkdtemp()
try:
setuptools, = glob.glob(dist + "/setuptools-*")
if setuptools.endswith(".zip"):
zipfile.ZipFile(setuptools).extractall(tmp)
else:
tarfile.TarFile.open(setuptools, "r:*").extractall(tmp)
x, = os.listdir(tmp)
sys.path.insert(0, os.path.join(tmp, x))
from setuptools.command.easy_install import main
for x in "bin", "eggs":
try:
os.mkdir(x)
except OSError:
pass
main(["-f", dist, "-mxd", x, setuptools, "zc.buildout"])
finally:
shutil.rmtree(tmp)
with os.fdopen(os.open("bin/buildout", os.O_CREAT|os.O_WRONLY|os.O_TRUNC, 0o777), 'w') as f:
f.write("""\
#!%s -S
import os, sys
d = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
d = os.path.dirname(d) + %r
sys.path[:0] = (%s)
from zc.buildout.buildout import main
sys.exit(main())
""" % (
sys.executable,
"/%s/" % x,
", ".join(map("d + %r".__mod__, os.listdir(x))),
))
......@@ -6,7 +6,8 @@ source makefile-scripts/compilation-env.sh
echo "Fixing buildout path to "$TARBALL_DIR" rather than "$OLD_TARBALL_DIR" for buildout"
cd "$RUN_BUILDOUT_DIR"
sed -i "s#$OLD_TARBALL_DIR#$TARBALL_DIR#g" buildout.cfg bin/*
bin/buildout -v
sed -i "s#$OLD_TARBALL_DIR#$TARBALL_DIR#g" buildout.cfg
$SLAPOS_BOOTSTRAP_SYSTEM_PYTHON $TARBALL_DIR/makefile-scripts/bootstrap
$SLAPOS_BOOTSTRAP_SYSTEM_PYTHON bin/buildout -v
touch clean-stamp
......@@ -8,9 +8,4 @@ INSTALL_DIR="$DESTDIR""$TARGET_DIR"
RUN_BUILDOUT_DIR="$BUILD_DIR""$TARGET_DIR"
# get the path of the BUILD_DIR of the first build (performed to prepare the cache for OBS)
OLD_TARBALL_DIR="$(cat local_tarball_directory_path)"
TARBALL_DIR=$(realpath -m "$TARBALL_DIR")
BUILD_DIR=$(realpath -m "$BUILD_DIR")
INSTALL_DIR=$(realpath -m "$INSTALL_DIR")
RUN_BUILDOUT_DIR=$(realpath -m "$RUN_BUILDOUT_DIR")
OLD_TARBALL_DIR=$(realpath -m "$OLD_TARBALL_DIR")
SLAPOS_BOOTSTRAP_SYSTEM_PYTHON=$(which python2.7 2> /dev/null || echo python3)
##############################################################################
#
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
# Turn off the brp-python-bytecompile script
%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')
%define compound_version 1.1
%define slapos_directory %SOFTWARE_AND_VERSION%
Summary:Client-side to deploy applications with SlapOS
Name: slapos-node
Version:%{compound_version}
Release:%{compound_version}
License:GPL
Group: Application/Network
Source0: %{slapos_directory}.tar.gz
URL: http://community.slapos.org/
Vendor: Vifib
Packager: Thomas Gambier <thomas.gambier@nexedi.com>
BuildRequires: gcc-c++
BuildRequires: make
BuildRequires: patch
BuildRequires: wget
BuildRequires: chrpath
BuildRequires: openssl-devel
%if 0%{?centos_version} <= 700 || 0%{?rhel_version} <= 700 || 0%{?suse_version} < 1300 || 0%{?sle_version} < 130000
BuildRequires: python
BuildRequires: python-devel
%else
BuildRequires: python3
BuildRequires: python3-devel
%endif
Requires: gcc-c++, make, patch, wget
AutoReqProv: no
%description
Special compilation of fluent-bit
%prep
rm -rf $RPM_BUILD_DIR/%{slapos_directory}
zcat $RPM_SOURCE_DIR/%{slapos_directory}.tar.gz | tar -xvf -
%build
cd $RPM_BUILD_DIR/%{slapos_directory}
make
%install
cd $RPM_BUILD_DIR/%{slapos_directory}
%files
%defattr(-,root,root)
%pre
%post
%preun
%postun
# packahge containing fluent-bit
# package containing fluent-bit
export SOFTWARE_NAME=fluent-bit
export MAINTAINER_NAME="Ophélie Gagnard"
export MAINTAINER_EMAIL=ophelie.gagnard@nexedi.com
export PACKAGE_BUILD_DEPENDENCIES="debhelper (>= 4.1.16), chrpath, wget, python (>= 2.7), python3 (>= 3.7), python3-dev (>= 3.7), cmake (>= 3.18)"
export PACKAGE_BUILD_DEPENDENCIES="debhelper, chrpath, python3 (>=3.7) | python, python3-dev (>= 3.7) | python-dev"
export SETUPTOOLS_VERSION=44.1.1
export ZC_BUILDOUT_VERSION=2.7.1+slapos016
export ZC_BUILDOUT_VERSION=2.7.1+slapos019
#!/usr/bin/python3 -S
import glob, os, shutil, sys, tarfile, tempfile, zipfile
dist = "download-cache/dist"
tmp = tempfile.mkdtemp()
try:
setuptools, = glob.glob(dist + "/setuptools-*")
if setuptools.endswith(".zip"):
zipfile.ZipFile(setuptools).extractall(tmp)
else:
tarfile.TarFile.open(setuptools, "r:*").extractall(tmp)
x, = os.listdir(tmp)
sys.path.insert(0, os.path.join(tmp, x))
from setuptools.command.easy_install import main
for x in "bin", "eggs":
try:
os.mkdir(x)
except OSError:
pass
main(["-f", dist, "-mxd", x, setuptools, "zc.buildout"])
finally:
shutil.rmtree(tmp)
with os.fdopen(os.open("bin/buildout", os.O_CREAT|os.O_WRONLY|os.O_TRUNC, 0o777), 'w') as f:
f.write("""\
#!%s -S
import os, sys
d = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
d = os.path.dirname(d) + %r
sys.path[:0] = (%s)
from zc.buildout.buildout import main
sys.exit(main())
""" % (
sys.executable,
"/%s/" % x,
", ".join(map("d + %r".__mod__, os.listdir(x))),
))
../_generic/compilation/makefile-scripts/bootstrap
\ No newline at end of file
......@@ -84,7 +84,7 @@ find . -regextype posix-extended -type f \
# prepare compilation inside OBS #
##################################
# we need the very first bootstrap script
cp $CURRENT_DIRECTORY/../re6st/bootstrap $BUILD_DIRECTORY
cp $CURRENT_DIRECTORY/../_generic/compilation/makefile-scripts/bootstrap $BUILD_DIRECTORY
# we need the original directory to do a sed inside OBS
# TODO remove this and properly use extends-cache instead
......
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