POC fonctionnel
This commit is contained in:
25
hooks/prebuild/debian/add-package-version-suffix
Executable file
25
hooks/prebuild/debian/add-package-version-suffix
Executable file
@ -0,0 +1,25 @@
|
||||
#!/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_count=$(git rev-list --count HEAD)
|
||||
current_commit=$(git log -n 1 --pretty=format:"%h")
|
||||
version_suffix=tamarin${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
|
||||
|
||||
sed -i "0,/(\(.*\))/s/(\(.*\))/(\1${version_suffix})/" debian/changelog
|
7
hooks/prebuild/debian/copy-sources-to-workspace
Executable file
7
hooks/prebuild/debian/copy-sources-to-workspace
Executable file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
tamarin_info "Copying sources to workspace 'src' directory..."
|
||||
|
||||
mkdir src
|
||||
# Copying all read-only sources to the current workspace src
|
||||
cp -r /src/. ./src
|
69
hooks/prebuild/debian/create-changelog
Executable file
69
hooks/prebuild/debian/create-changelog
Executable file
@ -0,0 +1,69 @@
|
||||
#!/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 commits log as changelog
|
||||
|
||||
BUILD_TAG=$(tamarin_db get build_tag "last")
|
||||
|
||||
tamarin_debug "BUILD TAG IS ${BUILD_TAG}"
|
||||
|
||||
if [[ ${BUILD_TAG} == "last" ]]
|
||||
then
|
||||
tags=$(git tag master -l "release/*"|sort -r)
|
||||
else
|
||||
tagbranch="build-tag-${BUILD_TAG}"
|
||||
git checkout -b ${tagbranch}
|
||||
tamarin_db set "tag_branch" "${tag_branch}"
|
||||
local tags="${BUILD_TAG}"
|
||||
fi
|
||||
|
||||
if [[ -z ${tags} ]]
|
||||
then
|
||||
tamarin_warn "No release tag found, you repo must have a tag like 'release/X.X'"
|
||||
exit
|
||||
fi
|
||||
|
||||
touch debian/changelog
|
||||
|
||||
for tag in ${tags}
|
||||
do
|
||||
logs=$(git log --pretty=format:"%an - %h : %s" ${tag} | sed 's/"/\\"/g')
|
||||
|
||||
# Set the top commiter as the maintainer of the project if not defined
|
||||
top_contributor=$(git log --pretty=short | git shortlog -s -n -e | sed 's/^\s*[0-9]*\s*//g' | head -n 1)
|
||||
maintainer=$(tamarin_db get maintainer "${top_contributor}")
|
||||
|
||||
project_name=$(tamarin_db get project_name)
|
||||
version=${tag#*/} #$(get_opt version 0.0.0)
|
||||
version=${version/_/-} #$(get_opt version 0.0.0)
|
||||
|
||||
distribution=$(tamarin_db get distribution UNRELEASED)
|
||||
urgency=$(tamarin_db get urgency low)
|
||||
|
||||
package_version=${version}
|
||||
|
||||
# Define project_version if not defined
|
||||
if [ -z "$(tamarin_db get project_version)" ]; then
|
||||
# Share computed project version
|
||||
tamarin_db set project_version "${version}"
|
||||
fi
|
||||
|
||||
echo "${project_name} (${version}) ${distribution}; urgency=${urgency}" >> debian/changelog
|
||||
|
||||
echo >> debian/changelog
|
||||
|
||||
while read -r entry; do
|
||||
echo " * ${entry}" >> debian/changelog
|
||||
done <<< "$(echo -e "${logs}" | sed 's/^"//')"
|
||||
|
||||
echo >> debian/changelog
|
||||
|
||||
echo " -- ${maintainer} $(date -R)" >> debian/changelog
|
||||
echo >> debian/changelog
|
||||
done
|
21
hooks/prebuild/debian/create-dummy-changelog
Executable file
21
hooks/prebuild/debian/create-dummy-changelog
Executable file
@ -0,0 +1,21 @@
|
||||
#!/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
|
||||
|
||||
changelog="debian/changelog"
|
||||
project_name=$(tamarin_db get project_name)
|
||||
project_version=$(tamarin_db get project_version 0.0.0)
|
||||
date=$(date -R)
|
||||
top_contributor=$(git log --pretty=short | git shortlog -s -n -e | sed 's/^\s*[0-9]*\s*//g' | head -n 1)
|
||||
current_commit=$(git log -n 1 --pretty=format:%h)
|
||||
|
||||
echo "${project_name} (${project_version}) unstable; urgency=low" > ${changelog}
|
||||
echo >> ${changelog}
|
||||
echo " * Package built with Tamarin. Based on commit ${current_commit}." >> ${changelog}
|
||||
echo >> ${changelog}
|
||||
echo " -- ${top_contributor} ${date}" >> ${changelog}
|
9
hooks/prebuild/debian/install-build-depends
Executable file
9
hooks/prebuild/debian/install-build-depends
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd src
|
||||
|
||||
if [ -f debian/control ]; then
|
||||
echo "Installing build dependencies..."
|
||||
apt-get update
|
||||
mk-build-deps -r -t "apt-get --force-yes -y --no-install-recommends" --install debian/control
|
||||
fi
|
3
hooks/prebuild/debian/load-project-db
Executable file
3
hooks/prebuild/debian/load-project-db
Executable file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
tamarin_db load
|
Reference in New Issue
Block a user