-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathalibuild_build_default
executable file
·53 lines (39 loc) · 2.74 KB
/
alibuild_build_default
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
[[ -z "${ALIBUILD_WORK_DIR}" ]] && { echo "ALIBUILD_WORK_DIR not defined"; exit 1; }
help () { echo "${0} initDir packageName defaultName [any other aliBuild build args]"; }
INITDIR="${1}"
shift
PACKAGE="${1}"
shift
DEFAULT="${1}"
shift
## INIT DIR
tags="$(ls --hide=sw ${ALIBUILD_WORK_DIR}/../)"
[[ -z "${INITDIR}" ]] && { help; echo -e "List of found init dirs:\n$(echo ${tags} | xargs -n 6 | column -t)" ; exit 1; }
NAME_VALID=$(echo "${tags}" | grep "${INITDIR}")
[[ -z "${NAME_VALID}" ]] && { echo -e "Name not found in init dirs list:\n$(echo ${tags} | xargs -n 6 | column -t)" ; exit 1; }
[[ ! -d "${ALIBUILD_WORK_DIR}/../${INITDIR}" ]] && { echo -e "${INITDIR} is not a directory"; exit 1; }
pushd ${ALIBUILD_WORK_DIR}/../${INITDIR} &>/dev/null || { echo "Could not cd to: ${ALIBUILD_WORK_DIR}/../${INITDIR}"; exit 1; }
mkdir -p "${ALIBUILD_WORK_DIR}/../${INITDIR}/tmp"
export TMPDIR="${ALIBUILD_WORK_DIR}/../${INITDIR}/tmp"
export TMP="${TMPDIR}"
## PACKAGES
alidist_dir="${ALIBUILD_WORK_DIR}/../${INITDIR}/alidist"
[[ ! -d "${alidist_dir}" ]] && { echo -e "no alidist directory in ${INITDIR} !!!"; exit 1; }
packages_file_list="$(ls -1 -f ${ALIBUILD_WORK_DIR}/../${INITDIR}/alidist/*.sh | grep -v 'defaults-.*.sh')"
package_list=$(for f in ${packages_file_list}; do grep "package: " $f | sed 's/package: //g'; done)
[[ -z "${PACKAGE}" ]] && { help; echo -e "Packages list (mind the caps):\n$(echo ${package_list} | sort |xargs -n 4 | column -t)" ; exit 1; }
PACKAGE_VALID=$(echo "${package_list}" | grep "${PACKAGE}")
[[ -z "${PACKAGE_VALID}" ]] && { echo -e "Package not found in list (mind the caps):\n$(echo ${package_list} | grep -v '^defaults-' | sort |xargs -n 4 | column -t)" ; exit 1; }
## DEFAULTS
defaults_list=$(find ${ALIBUILD_WORK_DIR}/../${INITDIR}/alidist/ -type f -name "defaults-*" -printf "%P\n" | sed 's/defaults-//g;s/.sh$//g')
[[ -z "${DEFAULT}" ]] && { help; echo -e "Default list (mind the caps):\n$(echo ${defaults_list} | sort | xargs -n 3 | column -t)" ; exit 1; }
DEFAULT_VALID=$(echo "${defaults_list}" | grep "${DEFAULT}")
[[ -z "${DEFAULT_VALID}" ]] && { echo -e "Default not found in list (mind the caps):\n$(echo ${defaults_list} | sort | xargs -n 3 | column -t)" ; exit 1; }
## Architecture
ARCH_ARG=""
local_arch="$(aliBuild architecture)"
[[ "${local_arch}" != "slc9_x86-64" || "${local_arch}" != "slc8_x86-64" || "${local_arch}" != "slc7_x86-64" ]] && ARCH_ARG="--force-unknown-architecture"
echo aliBuild -d build ${ALIBUILD_NOSYSTEM:+--no-system} ${ARCH_ARG} --work-dir "${ALIBUILD_WORK_DIR}" --defaults ${DEFAULT} -z "${INITDIR}" "${@}" ${PACKAGE}
aliBuild -d build ${ALIBUILD_NOSYSTEM:+--no-system} ${ARCH_ARG} --work-dir "${ALIBUILD_WORK_DIR}" --defaults ${DEFAULT} -z "${INITDIR}" "${@}" ${PACKAGE}
popd &>/dev/null