Merge branch 'release/0.0.1'
This commit is contained in:
commit
7d05f84598
|
@ -6,6 +6,11 @@ if [ ! -f debian/changelog ]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ $(get_opt no_version_suffix 'no') == 'yes' ]; then
|
||||||
|
info "Not adding version suffix."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -d .git ]; then
|
if [ -d .git ]; then
|
||||||
info "It seems to be a Git repository. Generating version suffix based on Git history..."
|
info "It seems to be a Git repository. Generating version suffix based on Git history..."
|
||||||
commit_count=$(git rev-list --count HEAD)
|
commit_count=$(git rev-list --count HEAD)
|
||||||
|
|
|
@ -16,8 +16,7 @@ function build_project()
|
||||||
|
|
||||||
info "Building project '${PROJECT_NAME}' for ${TARGET_ARCH} architecture..."
|
info "Building project '${PROJECT_NAME}' for ${TARGET_ARCH} architecture..."
|
||||||
|
|
||||||
load_default_opts
|
# Initalize opts
|
||||||
|
|
||||||
set_opt project_name "${PROJECT_NAME}"
|
set_opt project_name "${PROJECT_NAME}"
|
||||||
set_opt build_branch "${BUILD_BRANCH}"
|
set_opt build_branch "${BUILD_BRANCH}"
|
||||||
set_opt build_tag "${BUILD_TAG}"
|
set_opt build_tag "${BUILD_TAG}"
|
||||||
|
@ -30,9 +29,10 @@ function build_project()
|
||||||
cd ${SRC_DIR}
|
cd ${SRC_DIR}
|
||||||
cp -r ${SRC_DIR}/. "${workspace}"
|
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)
|
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"
|
DEFAULT_OPTS_FILE="${BASE_DIR}/tmp/default_opts"
|
||||||
OPT_FILE="${BASE_DIR}/tmp/tamarin/opts"
|
OPT_FILE="${BASE_DIR}/tmp/tamarin/opts"
|
||||||
OPT_PREFIX="tamarin_opt_"
|
OPT_PREFIX="tamarin_opt_"
|
||||||
|
LOCAL_OPTS_FILE=".tamarinrc"
|
||||||
|
|
||||||
# Colors
|
# Colors
|
||||||
|
|
||||||
|
@ -96,11 +97,18 @@ function remove_ansi {
|
||||||
echo "$@" | sed 's,\x1B\[[0-9;]*[a-zA-Z],,g'
|
echo "$@" | sed 's,\x1B\[[0-9;]*[a-zA-Z],,g'
|
||||||
}
|
}
|
||||||
|
|
||||||
function load_default_opts {
|
function load_local_opts {
|
||||||
if [[ -e "${DEFAULT_OPTS_FILE}" ]]; then
|
if [ -e "${LOCAL_OPTS_FILE}" ]; then
|
||||||
info "Loading default opts..."
|
info "Loading local opts..."
|
||||||
else
|
while read line; do
|
||||||
info "No default opts found."
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +126,7 @@ function set_opt {
|
||||||
mkdir -p "$(dirname ${OPT_FILE})"
|
mkdir -p "$(dirname ${OPT_FILE})"
|
||||||
touch "${OPT_FILE}"
|
touch "${OPT_FILE}"
|
||||||
sed -i "s/^${OPT_PREFIX}${opt_name}*$//" "${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 {
|
function exec_hooks {
|
||||||
|
|
20
package
20
package
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
TAMARIN_VERSION=0.0.1
|
||||||
TAMARIN_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
TAMARIN_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||||
|
|
||||||
BASE_DIR="$TAMARIN_DIR" source "$TAMARIN_DIR/lib/util.sh"
|
BASE_DIR="$TAMARIN_DIR" source "$TAMARIN_DIR/lib/util.sh"
|
||||||
|
@ -15,8 +16,8 @@ function show_usage {
|
||||||
echo "Parameters: "
|
echo "Parameters: "
|
||||||
echo
|
echo
|
||||||
echo " -p Path to the project to build"
|
echo " -p Path to the project to build"
|
||||||
|
echo " -v Optional : Show Tamarin version"
|
||||||
echo " -a Optional : Target architecture (default amd64)"
|
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 " -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 " -i Optional : Name of the Docker image to use for build (default: debian:jessie)"
|
||||||
echo " -k Optional : Keep the Docker container after build "
|
echo " -k Optional : Keep the Docker container after build "
|
||||||
|
@ -62,12 +63,6 @@ function create_container {
|
||||||
|
|
||||||
EOF
|
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"
|
exec_hooks "containerbuild" "$temp_dir"
|
||||||
|
|
||||||
echo "CMD /root/.tamarin/lib/build.sh ${projectName} ${BUILD_BRANCH} /tmp ${BUILD_TAG}" >> "$temp_dir/Dockerfile"
|
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}"
|
docker_opt="${docker_opt}"
|
||||||
fi
|
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..."
|
info "Switching to container..."
|
||||||
debug "docker ${docker_opt}"
|
debug "docker ${docker_opt}"
|
||||||
|
@ -128,7 +123,7 @@ function main {
|
||||||
#
|
#
|
||||||
# Parsing options
|
# Parsing options
|
||||||
#
|
#
|
||||||
while getopts "kp:d:i:B:t:a:o:" option
|
while getopts "vkp:d:i:B:t:a:o:" option
|
||||||
do
|
do
|
||||||
case $option in
|
case $option in
|
||||||
k)
|
k)
|
||||||
|
@ -152,8 +147,9 @@ do
|
||||||
a)
|
a)
|
||||||
TARGET_ARCH=${OPTARG}
|
TARGET_ARCH=${OPTARG}
|
||||||
;;
|
;;
|
||||||
o)
|
v)
|
||||||
DEFAULT_OPTS=$(readlink -f ${OPTARG})
|
echo "Tamarin v${TAMARIN_VERSION}"
|
||||||
|
exit
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
show_usage
|
show_usage
|
||||||
|
@ -172,7 +168,7 @@ if [[ "${TARGET_ARCH}" =~ ^i[0-9]86$ ]] && [ -z "${BASE_IMAGE}" ]; then
|
||||||
BASE_IMAGE=${DEFAULT_32_IMAGE}
|
BASE_IMAGE=${DEFAULT_32_IMAGE}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -z ${BASE_IMAGE} ]] && BASE_IMAGE=${DEFAULT_64_IMAGE}
|
[[ -z ${BASE_IMAGE} ]] && BASE_IMAGE=${DEFAULT_64_IMAGE}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Warn user about "proxy"
|
# Warn user about "proxy"
|
||||||
|
|
Loading…
Reference in New Issue