Récupération et chargement de variables locales via fichier .tamarinrc
This commit is contained in:
parent
c1073a210e
commit
b4ce2b696b
|
@ -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 {
|
||||||
|
|
12
package
12
package
|
@ -16,7 +16,6 @@ function show_usage {
|
||||||
echo
|
echo
|
||||||
echo " -p Path to the project to build"
|
echo " -p Path to the project to build"
|
||||||
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 +61,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"
|
||||||
|
@ -152,9 +145,6 @@ do
|
||||||
a)
|
a)
|
||||||
TARGET_ARCH=${OPTARG}
|
TARGET_ARCH=${OPTARG}
|
||||||
;;
|
;;
|
||||||
o)
|
|
||||||
DEFAULT_OPTS=$(readlink -f ${OPTARG})
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
show_usage
|
show_usage
|
||||||
;;
|
;;
|
||||||
|
@ -172,7 +162,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