Base default opts

This commit is contained in:
wpetit 2015-11-18 10:45:20 +01:00
parent 1ba20bc279
commit 0cb534116d
4 changed files with 23 additions and 28 deletions

View File

@ -47,16 +47,7 @@ do
distribution=$(get_opt distribution UNRELEASED)
urgency=$(get_opt urgency low)
commit_count=$(git rev-list --count --first-parent HEAD)
current_commit=$(git log -n 1 --pretty=format:"%h")
version_suffix=tamarin${commit_count}~${current_commit}
package_version=${version}-${version_suffix}
# Define package_version opt if not defined
if [ -z "$(get_opt package_version)" ]; then
# Share computed package version
set_opt package_version "${package_version}"
fi
package_version=${version}
# Define project_version opt if not defined
if [ -z "$(get_opt project_version)" ]; then
@ -64,7 +55,7 @@ do
set_opt project_version "${version}"
fi
echo "${project_name} (${package_version}) ${distribution}; urgency=${urgency}" >> debian/changelog
echo "${project_name} (${version}) ${distribution}; urgency=${urgency}" >> debian/changelog
echo >> debian/changelog

View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
source "${TAMARIN_UTIL}"
if [ ! -f debian/changelog ]; then
info "No changelog. Skipping..."
exit
fi
if [ -d .git ]; then
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
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

View File

@ -1,15 +0,0 @@
#!/usr/bin/env bash
source "${TAMARIN_UTIL}"
if [ ! -f debian/changelog ] || [ ! -d .git ]; then
info "To auto calculate the package version suffix, we need a git environment and a existing changelog !"
exit
fi
commit_count=$(git rev-list --count --first-parent HEAD)
current_commit=$(git log -n 1 --pretty=format:"%h")
version_suffix=tamarin${commit_count}~${current_commit}
sed "0,/(\(.*\))/s/(\(.*\))/(\1-${version_suffix})/" debian/changelog
exit 1

View File

@ -58,8 +58,6 @@ function create_container {
VOLUME /src
VOLUME /dist
CMD /root/.tamarin/lib/build.sh ${projectName} ${BUILD_BRANCH} /tmp ${BUILD_TAG}
EOF
# Add default opts file if defined
@ -70,6 +68,8 @@ EOF
exec_hooks "containerbuild" "$temp_dir"
echo "CMD /root/.tamarin/lib/build.sh ${projectName} ${BUILD_BRANCH} /tmp ${BUILD_TAG}" >> "$temp_dir/Dockerfile"
# Build image
tar -C "$temp_dir" -czh . | docker build -t "$container_tag" - 2> >(stderr) 1> >(stdout)