Compare commits
11 Commits
be739a965c
...
feature/st
Author | SHA1 | Date | |
---|---|---|---|
56013daed0 | |||
4c4fd6d42c | |||
546e62e077 | |||
4b61e5dafc | |||
c83e6190c4 | |||
cad163ffd0 | |||
97fd00a3c7 | |||
fdba555beb | |||
253c77489b | |||
9a46f34f73 | |||
5a4c17a959 |
15
hooks/build/stdeb/build
Executable file
15
hooks/build/stdeb/build
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
cd src
|
||||||
|
for archive in *.tar.gz
|
||||||
|
do
|
||||||
|
py2dsc $archive
|
||||||
|
folder="$(find deb_dist/* -maxdepth 0 -type d)"
|
||||||
|
pushd $folder
|
||||||
|
dpkg-buildpackage -b -a"${TAMARIN_TARGET_ARCH}"
|
||||||
|
find ../ -maxdepth 1 -name "*.deb" -type f -print0 | xargs -0r mv -t /dist/
|
||||||
|
popd
|
||||||
|
rm -rf $folder
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
28
hooks/containerbuild/debian/install-letsencrypt-ca
Executable file
28
hooks/containerbuild/debian/install-letsencrypt-ca
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DESTDIR=/usr/local/share/ca-certificates
|
||||||
|
UPDATE_CERTS_CMD=update-ca-certificates
|
||||||
|
CERTS="$(cat <<EOF
|
||||||
|
https://letsencrypt.org/certs/isrgrootx1.pem
|
||||||
|
https://letsencrypt.org/certs/isrg-root-x2.pem
|
||||||
|
https://letsencrypt.org/certs/lets-encrypt-r3.pem
|
||||||
|
https://letsencrypt.org/certs/lets-encrypt-e1.pem
|
||||||
|
https://letsencrypt.org/certs/lets-encrypt-r4.pem
|
||||||
|
https://letsencrypt.org/certs/lets-encrypt-e2.pem
|
||||||
|
EOF
|
||||||
|
)"
|
||||||
|
|
||||||
|
|
||||||
|
echo "ENV DEBIAN_FRONTEND=noninteractive" >> Dockerfile
|
||||||
|
echo "RUN apt-get update && apt-get install --yes --no-install-recommends openssl ca-certificates" >> Dockerfile
|
||||||
|
|
||||||
|
for cert in $CERTS; do
|
||||||
|
filename=$(basename "$cert")
|
||||||
|
echo "ADD $cert $DESTDIR/$filename" >> Dockerfile
|
||||||
|
echo "RUN openssl x509 -in '$DESTDIR/$filename' -inform PEM -out '$DESTDIR/$filename.crt'" >> Dockerfile
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "RUN $UPDATE_CERTS_CMD" >> Dockerfile
|
||||||
|
echo "ENV DEBIAN_FRONTEND=" >> Dockerfile
|
9
hooks/containerbuild/ubuntu/install-stdeb
Executable file
9
hooks/containerbuild/ubuntu/install-stdeb
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo 'ENV DEBIAN_FRONTEND=noninteractive' >> Dockerfile
|
||||||
|
echo 'RUN apt-get update && apt-get install --yes --no-install-recommends python3-all dh-python python3-pip' >> Dockerfile
|
||||||
|
echo 'RUN pip3 install stdeb' >> Dockerfile
|
||||||
|
echo 'ENV DEBIAN_FRONTEND=' >> Dockerfile
|
||||||
|
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
cd src
|
cd src
|
||||||
if [ -f debian/changelog ] || [ ! -d .git ]; then
|
if [ -f debian/changelog ] || [ ! -d .git ]; then
|
||||||
tamarin_info "Not a Git repository or Debian changelog already exists !"
|
tamarin_info "Not a Git repository or Debian changelog already exists !"
|
||||||
@ -13,11 +12,11 @@ pkg_tags="$(git for-each-ref --format '%(refname)' refs/tags | tac)"
|
|||||||
|
|
||||||
# Set starting commit
|
# Set starting commit
|
||||||
ceiling_commit=$(git describe --match "build/*" --abbrev=0 2>/dev/null)
|
ceiling_commit=$(git describe --match "build/*" --abbrev=0 2>/dev/null)
|
||||||
if [ -n "ceiling_commit" ]
|
if [ -z "$ceiling_commit" ]
|
||||||
then
|
then
|
||||||
ceiling_commit="HEAD"
|
ceiling_commit="HEAD"
|
||||||
fi
|
fi
|
||||||
first_commit=$(git rev-list --max-parents=0 master)
|
first_commit=$(git rev-list --max-parents=0 HEAD)
|
||||||
|
|
||||||
# Get commits log as changelog
|
# Get commits log as changelog
|
||||||
|
|
||||||
@ -55,7 +54,7 @@ function get_short_hash {
|
|||||||
function get_previous_pkg_tag {
|
function get_previous_pkg_tag {
|
||||||
# Return previous pkg/* tag or current tag if no previous pkg/* exists.
|
# Return previous pkg/* tag or current tag if no previous pkg/* exists.
|
||||||
commit="$1"
|
commit="$1"
|
||||||
echo "$(git describe --abbrev=0 --always --match='pkg/*' $commit)"
|
echo "$(git describe --abbrev=0 --match='pkg/*' $commit 2>/dev/null)"
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse_tag {
|
function parse_tag {
|
||||||
@ -103,6 +102,16 @@ function get_package_version_from_tag {
|
|||||||
echo "$package"
|
echo "$package"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_distribution_from_tag {
|
||||||
|
# tag pkg like pkg/<level>/<distrib>/<version>
|
||||||
|
# <distrib> may be composed
|
||||||
|
tag="$1"
|
||||||
|
distribution="${tag#pkg/*/}"
|
||||||
|
distribution="${distribution%/*}"
|
||||||
|
distribution="${distribution/\//-}"
|
||||||
|
echo $distribution
|
||||||
|
}
|
||||||
|
|
||||||
function get_previous_release_tag {
|
function get_previous_release_tag {
|
||||||
# Return previous pkg/* tag or current tag if no previous pkg/* exists.
|
# Return previous pkg/* tag or current tag if no previous pkg/* exists.
|
||||||
commit="$1"
|
commit="$1"
|
||||||
@ -113,7 +122,7 @@ function on_pkg_tag {
|
|||||||
# Return 1 if current commit is tagged with pkg/* tag.
|
# Return 1 if current commit is tagged with pkg/* tag.
|
||||||
commit="$1"
|
commit="$1"
|
||||||
nearest_old_pkg_tag="$(get_previous_pkg_tag $commit)"
|
nearest_old_pkg_tag="$(get_previous_pkg_tag $commit)"
|
||||||
if [ "$(get_hash ${commit})" = "$(get_hash ${nearest_old_pkg_tag})" ]
|
if [ -n "${nearest_old_pkg_tag}" ] && [ "$(get_hash ${commit})" = "$(get_hash ${nearest_old_pkg_tag})" ]
|
||||||
then
|
then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
@ -159,13 +168,13 @@ function date_from_commit {
|
|||||||
function packager_from_commit {
|
function packager_from_commit {
|
||||||
# Return Name <mail> id format, suitable for changelog entry signature
|
# Return Name <mail> id format, suitable for changelog entry signature
|
||||||
commit="$1"
|
commit="$1"
|
||||||
if [ "${commit}" = "HEAD" ]
|
if on_pkg_tag "${commit}"
|
||||||
then
|
then
|
||||||
maintainer="$(git log -n1 --format='%cn <%ce>')"
|
|
||||||
else
|
|
||||||
maintainer_commit="$(get_previous_pkg_tag $commit)"
|
maintainer_commit="$(get_previous_pkg_tag $commit)"
|
||||||
maintainer="$(git tag -l --format='%(creator)' ${maintainer_commit})"
|
maintainer="$(git tag -l --format='%(creator)' ${maintainer_commit})"
|
||||||
maintainer="${maintainer%>*}>"
|
maintainer="${maintainer%>*}>"
|
||||||
|
else
|
||||||
|
maintainer="$(git log -n1 --format='%cn <%ce>')"
|
||||||
fi
|
fi
|
||||||
maintainer=$(tamarin_db get maintainer "${maintainer}")
|
maintainer=$(tamarin_db get maintainer "${maintainer}")
|
||||||
echo "$maintainer"
|
echo "$maintainer"
|
||||||
@ -190,6 +199,7 @@ function next_version {
|
|||||||
fi
|
fi
|
||||||
elif [ -n "$previous_release" ]
|
elif [ -n "$previous_release" ]
|
||||||
then
|
then
|
||||||
|
distance_from_release=$(get_distance_from_tag "$previous_release" "$commit")
|
||||||
distance=$distance_from_release
|
distance=$distance_from_release
|
||||||
version="$(get_upstream_version_from_tag $previous_release)-1"
|
version="$(get_upstream_version_from_tag $previous_release)-1"
|
||||||
elif [ -n "$previous_pkg" ]
|
elif [ -n "$previous_pkg" ]
|
||||||
@ -210,26 +220,25 @@ function next_version {
|
|||||||
function gen_changelog_entry {
|
function gen_changelog_entry {
|
||||||
ceiling_commit=$1
|
ceiling_commit=$1
|
||||||
floor_commit="$(next_step "${ceiling_commit}")"
|
floor_commit="$(next_step "${ceiling_commit}")"
|
||||||
|
|
||||||
if [ "$(get_hash ${ceiling_commit})" = "$(get_hash ${floor_commit})" ]
|
if [ "$(get_hash ${ceiling_commit})" = "$(get_hash ${floor_commit})" ]
|
||||||
then
|
then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if on_pkg_tag $ceiling_commit
|
if on_pkg_tag $ceiling_commit
|
||||||
then
|
then
|
||||||
|
ceiling_commit="$(get_previous_pkg_tag $ceiling_commit)"
|
||||||
version="$(get_upstream_version_from_tag $ceiling_commit)-$(get_package_version_from_tag $ceiling_commit)"
|
version="$(get_upstream_version_from_tag $ceiling_commit)-$(get_package_version_from_tag $ceiling_commit)"
|
||||||
|
distribution="$(get_distribution_from_tag $ceiling_commit)"
|
||||||
else
|
else
|
||||||
tamarin_info "current commit $ceiling_commit"
|
tamarin_info "current commit $ceiling_commit"
|
||||||
version=$(next_version $ceiling_commit)
|
version=$(next_version $ceiling_commit)
|
||||||
|
distribution="UNRELEASED"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#current_release="$(git describe --abbrev=0 --always --match='release/*' $ceiling_commit)"
|
#current_release="$(git describe --abbrev=0 --always --match='release/*' $ceiling_commit)"
|
||||||
tamarin_info "Création de l’entrée de changelog entre ${ceiling_commit} et ${floor_commit}"
|
tamarin_info "Création de l’entrée de changelog entre ${ceiling_commit} et ${floor_commit}"
|
||||||
|
|
||||||
maintainer="$(packager_from_commit ${ceiling_commit})"
|
maintainer="$(packager_from_commit ${ceiling_commit})"
|
||||||
package_date="$(date_from_commit ${ceiling_commit})"
|
package_date="$(date_from_commit ${ceiling_commit})"
|
||||||
|
|
||||||
version=${version/_/-}
|
version=${version/_/-}
|
||||||
changelog_entry="${project_name} (${version}) ${distribution}; urgency=${urgency}"
|
changelog_entry="${project_name} (${version}) ${distribution}; urgency=${urgency}"
|
||||||
echo "$changelog_entry" >> debian/changelog
|
echo "$changelog_entry" >> debian/changelog
|
||||||
|
@ -12,12 +12,18 @@ def run_profile_hooks(profile, step, **kwargs):
|
|||||||
hook_path = os.path.join(hooks_dir, trimmed_hook_name)
|
hook_path = os.path.join(hooks_dir, trimmed_hook_name)
|
||||||
run([hook_path], **kwargs)
|
run([hook_path], **kwargs)
|
||||||
|
|
||||||
|
def get_base_dir():
|
||||||
|
return os.path.realpath(os.path.dirname(os.path.abspath(__file__)) + "/..")
|
||||||
|
|
||||||
def get_hooks_dir():
|
def get_hooks_dir():
|
||||||
return os.path.realpath(os.path.dirname(os.path.abspath(__file__)) + "/../hooks")
|
return os.path.realpath(os.path.dirname(os.path.abspath(__file__)) + "/../hooks")
|
||||||
|
|
||||||
def get_lib_dir():
|
def get_lib_dir():
|
||||||
return os.path.realpath(os.path.dirname(os.path.abspath(__file__)) + "/../lib")
|
return os.path.realpath(os.path.dirname(os.path.abspath(__file__)) + "/../lib")
|
||||||
|
|
||||||
|
def get_utils_dir():
|
||||||
|
return os.path.realpath(os.path.dirname(os.path.abspath(__file__)) + "/../utils")
|
||||||
|
|
||||||
def load_profile(profile_name, debug=False):
|
def load_profile(profile_name, debug=False):
|
||||||
profile_filename = profile_name+".conf"
|
profile_filename = profile_name+".conf"
|
||||||
for profile_file in get_available_profiles():
|
for profile_file in get_available_profiles():
|
||||||
|
16
package
16
package
@ -23,13 +23,16 @@ def create_args_parser():
|
|||||||
parser.add_argument("--cleanup", help="Clear the workspace and remove obsolete Docker images before build", action="store_true", default=False)
|
parser.add_argument("--cleanup", help="Clear the workspace and remove obsolete Docker images before build", action="store_true", default=False)
|
||||||
parser.add_argument("--override-docker-args", help="Override all 'docker run' arguments. Use '[IMAGE_TAG]', '[PROFILE]' and '[ARCH]' to insert the corresponding values into your command.", default="")
|
parser.add_argument("--override-docker-args", help="Override all 'docker run' arguments. Use '[IMAGE_TAG]', '[PROFILE]' and '[ARCH]' to insert the corresponding values into your command.", default="")
|
||||||
parser.add_argument("--prepare-only", help="Only prepare build environment for the given profile", action="store_true", default=False)
|
parser.add_argument("--prepare-only", help="Only prepare build environment for the given profile", action="store_true", default=False)
|
||||||
|
parser.add_argument("--no-lib-mounts", help="Disable Tamarin library volumes mount", action="store_true", default=False)
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def build_image(build_workspace, base_image, profile_name, profile, debug=False, rebuild=False):
|
def build_image(build_workspace, base_image, profile_name, profile, debug=False, rebuild=False):
|
||||||
|
shutil.copytree(tamarin.get_base_dir(), os.path.join(build_workspace, '.tamarin'))
|
||||||
|
|
||||||
with open("{:s}/Dockerfile".format(build_workspace), 'w') as dockerfile:
|
with open("{:s}/Dockerfile".format(build_workspace), 'w') as dockerfile:
|
||||||
dockerfile.write("FROM {:s}\n".format(base_image))
|
dockerfile.write("FROM {:s}\n".format(base_image))
|
||||||
|
dockerfile.write("COPY .tamarin /tamarin\n")
|
||||||
|
|
||||||
# Configure "containerbuild" hooks environment
|
# Configure "containerbuild" hooks environment
|
||||||
hooks_env = os.environ.copy()
|
hooks_env = os.environ.copy()
|
||||||
@ -80,6 +83,8 @@ if __name__ == "__main__":
|
|||||||
pid = os.getpid()
|
pid = os.getpid()
|
||||||
build_workspace = tamarin.get_workspace_subdir('tmp/build_{:d}'.format(pid))
|
build_workspace = tamarin.get_workspace_subdir('tmp/build_{:d}'.format(pid))
|
||||||
|
|
||||||
|
shutil.copytree(tamarin.get_utils_dir(), os.path.join(build_workspace, 'utils'))
|
||||||
|
|
||||||
base_image = args.base if args.base != '' else profile['profile']['default_image']
|
base_image = args.base if args.base != '' else profile['profile']['default_image']
|
||||||
|
|
||||||
image_tag = build_image(build_workspace, base_image, args.profile, profile, debug=args.debug, rebuild=args.rebuild)
|
image_tag = build_image(build_workspace, base_image, args.profile, profile, debug=args.debug, rebuild=args.rebuild)
|
||||||
@ -105,11 +110,16 @@ if __name__ == "__main__":
|
|||||||
docker_args += [
|
docker_args += [
|
||||||
"-v", "{:s}:/src:ro".format(project_dir),
|
"-v", "{:s}:/src:ro".format(project_dir),
|
||||||
"-v", "{:s}:/dist".format(output_dir),
|
"-v", "{:s}:/dist".format(output_dir),
|
||||||
"-v", "{:s}:/tamarin/hooks:ro".format(tamarin.get_hooks_dir()),
|
|
||||||
"-v", "{:s}:/tamarin/lib:ro".format(tamarin.get_lib_dir()),
|
|
||||||
"-v", "{:s}:/tamarin/profiles:ro".format(tamarin.get_profiles_dir())
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if not args.no_lib_mounts:
|
||||||
|
docker_args += [
|
||||||
|
"-v", "{:s}:/tamarin/hooks:ro".format(tamarin.get_hooks_dir()),
|
||||||
|
"-v", "{:s}:/tamarin/lib:ro".format(tamarin.get_lib_dir()),
|
||||||
|
"-v", "{:s}:/tamarin/profiles:ro".format(tamarin.get_profiles_dir()),
|
||||||
|
"-v", "{:s}:/tamarin/utils:ro".format(tamarin.get_utils_dir())
|
||||||
|
]
|
||||||
|
|
||||||
# Use environment proxy if defined
|
# Use environment proxy if defined
|
||||||
for proxy_var in ['HTTP_PROXY', 'HTTPS_PROXY', 'http_proxy', 'https_proxy']:
|
for proxy_var in ['HTTP_PROXY', 'HTTPS_PROXY', 'http_proxy', 'https_proxy']:
|
||||||
if proxy_var in os.environ:
|
if proxy_var in os.environ:
|
||||||
|
@ -7,7 +7,8 @@ default_image=debian:stretch
|
|||||||
[containerbuild]
|
[containerbuild]
|
||||||
hooks=
|
hooks=
|
||||||
containerbuild/debian/install-build-essential,
|
containerbuild/debian/install-build-essential,
|
||||||
containerbuild/debian/install-git
|
containerbuild/debian/install-git,
|
||||||
|
containerbuild/debian/install-letsencrypt-ca
|
||||||
|
|
||||||
# Configuration de l'étape de pré-construction du paquet
|
# Configuration de l'étape de pré-construction du paquet
|
||||||
[prebuild]
|
[prebuild]
|
||||||
|
30
profiles/eole-2.7.2.conf
Normal file
30
profiles/eole-2.7.2.conf
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Configuration générale du profil
|
||||||
|
[profile]
|
||||||
|
# Image Docker par défaut
|
||||||
|
default_image=ubuntu:bionic
|
||||||
|
|
||||||
|
# Configuration de l'étape de pré-construction du conteneur
|
||||||
|
[containerbuild]
|
||||||
|
hooks=
|
||||||
|
containerbuild/debian/install-build-essential,
|
||||||
|
containerbuild/debian/install-git,
|
||||||
|
|
||||||
|
# Configuration de l'étape de pré-construction du paquet
|
||||||
|
[prebuild]
|
||||||
|
hooks=
|
||||||
|
prebuild/debian/copy-sources-to-workspace,
|
||||||
|
prebuild/debian/run-project-hooks,
|
||||||
|
prebuild/debian/load-project-db,
|
||||||
|
prebuild/debian/complete-project-db,
|
||||||
|
prebuild/eole/create-changelog,
|
||||||
|
prebuild/debian/install-build-depends
|
||||||
|
|
||||||
|
# Configuration de l'étape de construction du paquet
|
||||||
|
[build]
|
||||||
|
hooks=build/debian/build
|
||||||
|
|
||||||
|
# Configuration de l'étape de post-construction du paquet
|
||||||
|
[postbuild]
|
||||||
|
hooks=
|
||||||
|
postbuild/debian/run-project-hooks,
|
||||||
|
postbuild/debian/export-dist
|
28
profiles/pypi-2.8.1.conf
Normal file
28
profiles/pypi-2.8.1.conf
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# Configuration générale du profil
|
||||||
|
[profile]
|
||||||
|
# Image Docker par défaut
|
||||||
|
default_image=ubuntu:focal
|
||||||
|
|
||||||
|
# Configuration de l'étape de pré-construction du conteneur
|
||||||
|
[containerbuild]
|
||||||
|
hooks=
|
||||||
|
containerbuild/debian/install-build-essential,
|
||||||
|
containerbuild/ubuntu/install-stdeb,
|
||||||
|
|
||||||
|
# Configuration de l'étape de pré-construction du paquet
|
||||||
|
[prebuild]
|
||||||
|
hooks=
|
||||||
|
prebuild/debian/copy-sources-to-workspace,
|
||||||
|
prebuild/debian/run-project-hooks,
|
||||||
|
prebuild/debian/load-project-db,
|
||||||
|
|
||||||
|
# Configuration de l'étape de construction du paquet
|
||||||
|
[build]
|
||||||
|
hooks=build/stdeb/build
|
||||||
|
|
||||||
|
# Configuration de l'étape de post-construction du paquet
|
||||||
|
[postbuild]
|
||||||
|
hooks=
|
||||||
|
postbuild/debian/run-project-hooks,
|
||||||
|
postbuild/debian/export-dist
|
||||||
|
|
2
utils/sshForJenkins.sh
Normal file
2
utils/sshForJenkins.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
exec ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "$@"
|
Reference in New Issue
Block a user