Merge branch 'release/0.0.1'
This commit is contained in:
commit
7d05f84598
|
@ -6,6 +6,11 @@ if [ ! -f debian/changelog ]; then
|
|||
exit
|
||||
fi
|
||||
|
||||
if [ $(get_opt no_version_suffix 'no') == 'yes' ]; then
|
||||
info "Not adding version suffix."
|
||||
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)
|
||||
|
|
|
@ -16,8 +16,7 @@ function build_project()
|
|||
|
||||
info "Building project '${PROJECT_NAME}' for ${TARGET_ARCH} architecture..."
|
||||
|
||||
load_default_opts
|
||||
|
||||
# Initalize opts
|
||||
set_opt project_name "${PROJECT_NAME}"
|
||||
set_opt build_branch "${BUILD_BRANCH}"
|
||||
set_opt build_tag "${BUILD_TAG}"
|
||||
|
@ -30,9 +29,10 @@ function build_project()
|
|||
cd ${SRC_DIR}
|
||||
cp -r ${SRC_DIR}/. "${workspace}"
|
||||
|
||||
exec_hooks "prebuild" "${workspace}"
|
||||
cd "$workspace"
|
||||
|
||||
cd "${workspace}"
|
||||
load_local_opts
|
||||
exec_hooks "prebuild" "${workspace}"
|
||||
|
||||
dpkg-buildpackage -b -a"${TARGET_ARCH}" 2> >(stderr) 1> >(stdout)
|
||||
|
||||
|
|
20
lib/util.sh
20
lib/util.sh
|
@ -4,6 +4,7 @@ HOOKS_DIR="${BASE_DIR}/hooks"
|
|||
DEFAULT_OPTS_FILE="${BASE_DIR}/tmp/default_opts"
|
||||
OPT_FILE="${BASE_DIR}/tmp/tamarin/opts"
|
||||
OPT_PREFIX="tamarin_opt_"
|
||||
LOCAL_OPTS_FILE=".tamarinrc"
|
||||
|
||||
# Colors
|
||||
|
||||
|
@ -96,11 +97,18 @@ function remove_ansi {
|
|||
echo "$@" | sed 's,\x1B\[[0-9;]*[a-zA-Z],,g'
|
||||
}
|
||||
|
||||
function load_default_opts {
|
||||
if [[ -e "${DEFAULT_OPTS_FILE}" ]]; then
|
||||
info "Loading default opts..."
|
||||
else
|
||||
info "No default opts found."
|
||||
function load_local_opts {
|
||||
if [ -e "${LOCAL_OPTS_FILE}" ]; then
|
||||
info "Loading local opts..."
|
||||
while read line; do
|
||||
if [[ ! "${line}" =~ ^\s*# ]]; then
|
||||
set -- $(echo $line | tr '=' ' ')
|
||||
local key=$1
|
||||
local value=$2
|
||||
debug "Load opt $key=$value"
|
||||
set_opt $key $value
|
||||
fi
|
||||
done < "${LOCAL_OPTS_FILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -118,7 +126,7 @@ function set_opt {
|
|||
mkdir -p "$(dirname ${OPT_FILE})"
|
||||
touch "${OPT_FILE}"
|
||||
sed -i "s/^${OPT_PREFIX}${opt_name}*$//" "${OPT_FILE}"
|
||||
echo "${OPT_PREFIX}${opt_name}=\"${opt_value}\"" >> "${OPT_FILE}"
|
||||
echo "local ${OPT_PREFIX}${opt_name}=\"${opt_value}\"" >> "${OPT_FILE}"
|
||||
}
|
||||
|
||||
function exec_hooks {
|
||||
|
|
18
package
18
package
|
@ -2,6 +2,7 @@
|
|||
|
||||
set -e
|
||||
|
||||
TAMARIN_VERSION=0.0.1
|
||||
TAMARIN_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
|
||||
BASE_DIR="$TAMARIN_DIR" source "$TAMARIN_DIR/lib/util.sh"
|
||||
|
@ -15,8 +16,8 @@ function show_usage {
|
|||
echo "Parameters: "
|
||||
echo
|
||||
echo " -p Path to the project to build"
|
||||
echo " -v Optional : Show Tamarin version"
|
||||
echo " -a Optional : Target architecture (default amd64)"
|
||||
echo " -o Optional : Default options file to load (default none)"
|
||||
echo " -d Optional : Destination of the builed packages (default ./packages)"
|
||||
echo " -i Optional : Name of the Docker image to use for build (default: debian:jessie)"
|
||||
echo " -k Optional : Keep the Docker container after build "
|
||||
|
@ -62,12 +63,6 @@ function create_container {
|
|||
|
||||
EOF
|
||||
|
||||
# Add default opts file if defined
|
||||
if [[ -e "${DEFAULT_OPTS}" ]]; then
|
||||
ln -s "${DEFAULT_OPTS}" "$temp_dir/default_opts"
|
||||
echo "ADD ./default_ops /tmp/tamarin/default_opts" >> "$temp_dir/Dockerfile"
|
||||
fi
|
||||
|
||||
exec_hooks "containerbuild" "$temp_dir"
|
||||
|
||||
echo "CMD /root/.tamarin/lib/build.sh ${projectName} ${BUILD_BRANCH} /tmp ${BUILD_TAG}" >> "$temp_dir/Dockerfile"
|
||||
|
@ -114,7 +109,7 @@ function main {
|
|||
docker_opt="${docker_opt}"
|
||||
fi
|
||||
|
||||
docker_opt="${docker_opt} -v=\"$PROJECT_PATH:/src:ro\" -v=\"$PROJECT_DEST:/dist:rw\" $container_tag"
|
||||
docker_opt="${docker_opt} -v $PROJECT_PATH:/src:ro -v $PROJECT_DEST:/dist:rw $container_tag"
|
||||
|
||||
info "Switching to container..."
|
||||
debug "docker ${docker_opt}"
|
||||
|
@ -128,7 +123,7 @@ function main {
|
|||
#
|
||||
# Parsing options
|
||||
#
|
||||
while getopts "kp:d:i:B:t:a:o:" option
|
||||
while getopts "vkp:d:i:B:t:a:o:" option
|
||||
do
|
||||
case $option in
|
||||
k)
|
||||
|
@ -152,8 +147,9 @@ do
|
|||
a)
|
||||
TARGET_ARCH=${OPTARG}
|
||||
;;
|
||||
o)
|
||||
DEFAULT_OPTS=$(readlink -f ${OPTARG})
|
||||
v)
|
||||
echo "Tamarin v${TAMARIN_VERSION}"
|
||||
exit
|
||||
;;
|
||||
*)
|
||||
show_usage
|
||||
|
|
Loading…
Reference in New Issue