diff --git a/hooks/prebuild/eole/add-package-version-suffix b/hooks/prebuild/eole/add-package-version-suffix new file mode 100755 index 0000000..2f44498 --- /dev/null +++ b/hooks/prebuild/eole/add-package-version-suffix @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +cd src + +if [ ! -f debian/changelog ]; then + tamarin_info "No changelog. Skipping..." + exit +fi + +if [ $(tamarin_db get no_version_suffix 'no') == 'yes' ]; then + tamarin_info "Not adding version suffix." + exit +fi + +if [ -d .git ]; then + tamarin_info "It seems to be a Git repository. Generating version suffix based on Git history..." + commit_tag=$(git describe --match "pkg/*") + pkg_tag=$(git describe --match "pkg/*" --abbrev=0) + + commit_count=$(git rev-list --count ${pkg_tag}..HEAD) + current_commit=$(git log -n1 --pretty=format:%h) + tamarin_info $pkg_tag + tamarin_info $commit_count + tamarin_info $current_commit + version_suffix=~${commit_count}.${current_commit} +else + tamarin_info "Not a Git project. Fallback to timestamp for suffix generation..." + version_suffix=tamarin$(date +%Y%m%d%H%M) +fi + +tamarin_info $version_suffix +sed -i "0,/(\(.*\))/s/(\(.*\))/(\1${version_suffix})/" debian/changelog diff --git a/hooks/prebuild/eole/create-changelog b/hooks/prebuild/eole/create-changelog new file mode 100755 index 0000000..68277d0 --- /dev/null +++ b/hooks/prebuild/eole/create-changelog @@ -0,0 +1,122 @@ +#!/usr/bin/env bash + +cd src + +if [ -f debian/changelog ] || [ ! -d .git ]; then + tamarin_info "Not a Git repository or Debian changelog already exists !" + exit +fi + +# Get pkg tags as tie points in commit history +pkg_tags="$(git for-each-ref --format '%(refname)' refs/tags | tac)" + +# Set starting commit +start_commit='HEAD' + +# Get commits log as changelog + +current_release=$(git describe --match "release/*" --abbrev=0) + +if [[ -z ${current_release} ]] +then + tamarin_warn "No release tag found, you repo must have a tag like 'release/*'" + exit 1 +fi + +touch debian/changelog + +project_name=$(tamarin_db get project_name) +distribution=$(tamarin_db get distribution UNRELEASED) +urgency=$(tamarin_db get urgency low) + +function gen_changelog_entry { + start_commit=$1 + previous_pkg="$(git describe --long --always --match='pkg/*' $start_commit)" + if [[ "${previous_pkg}" =~ "pkg/" ]] + then + tamarin_info "dernier paquet trouvé : ${previous_pkg}" + extended_version=$(echo $previous_pkg | cut -d "/" -f4) + exploded_version="$(echo $extended_version | sed "s/\([a-z0-9.]\+\)-\([0-9]\+\)\(-\([0-9]\+\)-\(g[a-z0-9]\+\)\)\?$/\1 \2 \4 \5/")" + upstream_version=$(echo $exploded_version | cut -d " " -f1) + package_version=$(echo $exploded_version | cut -d " " -f2) + distance_to_pkg=$(echo $exploded_version | cut -d " " -f3) + if [[ "${distance_to_pkg}" > 0 ]] + then + tamarin_info "${distance_to_pkg} commit depuis le dernier paquet" + stop_commit="$(git describe --abbrev=0 --always --match='pkg/*' $start_commit)" + version=$(expr $package_version + 1) + else + stop_commit="$(git describe --abbrev=0 --always --match='pkg/*' ${start_commit}^1)" + version=$package_version + tamarin_info "version ${tamarin}" + fi + if [[ "${start_commit}" = "${stop_commit}" ]] + then + return 1 + fi + elif [[ "${start_commit}" = "${stop_commit}" ]] + then + return 1 + else + tamarin_info "Pas encore de paquet pour ce dépôt" + version="1" + upstream_version="${current_release#release/}" + stop_commit="${current_release}" + fi + + # Set the top commiter as the maintainer of the project if not defined + # If commit is tagged with pkg/, use tagger name as maintainer + # Else if commit is not tagged with pkg/, use commiter name as maintainer + current_release="$(git describe --abbrev=0 --always --match='release/*' $start_commit)" + tamarin_info "Création de l’entrée de changelog entre ${start_commit} et ${stop_commit}" + if [[ "$current_release" = "$start_commit" ]] # No package yet, git describe --always returned commit itself + then + echo "on passe bien là" + current_release='UNRELEASED' + return 1 + fi + if [ "${start_commit}" == "HEAD" ] + then + maintainer="$(git log -n1 --format='%cn <%ce>')" + maintainer=$(tamarin_db get maintainer "${maintainer}") + else + maintainer_commit="$(git describe --abbrev=0 --always --match='pkg/*' $start_commit)" + maintainer="$(git tag -l --format='%(creator)' ${maintainer_commit})" + fi + maintainer=$(tamarin_db get maintainer "${maintainer}") + + version=${upstream_version}-${version} + version=${version/_/-} + tamarin_warn "traitement de la version $version" + changelog_entry="${project_name} (${version}) ${distribution}; urgency=${urgency}" + echo "$changelog_entry" >> debian/changelog + echo >> debian/changelog + for commit in "$(git log --format='%H' ${stop_commit}..${start_commit})" + do + subject="$(git log -n1 --format=%s ${commit})" + tamarin_info "${subject}" + echo " * ${subject}" >> debian/changelog + start_commit="$(git log -n1 --format='%H' ${commit}^1)" + done + echo >> debian/changelog + changelog_sign=" -- ${maintainer} $(date --rfc-2822)" + echo "$changelog_sign" >> debian/changelog + echo >> debian/changelog + start_commit=${stop_commit} +} + +function gen_changelog() { +# while [[ $current_release != 'UNRELEASED' ]] +# do +# echo $start_commit +# echo $current_release +# gen_changelog_entry $start_commit +# done + while gen_changelog_entry $start_commit + do + echo $changelog_entry + done +} + +gen_changelog +cp debian/changelog /dist/changelog diff --git a/profiles/eole-2.7.1.conf b/profiles/eole-2.7.1.conf new file mode 100644 index 0000000..b14b753 --- /dev/null +++ b/profiles/eole-2.7.1.conf @@ -0,0 +1,31 @@ +# 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/eole/add-package-version-suffix, + 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