summaryrefslogtreecommitdiff
path: root/src/bin/db-init
blob: 1038167c289502f8cdb048697200d524ff4074e5 (plain)
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
#!/bin/bash
# Creates the repo structure defined in config

CONFIG_DIR="$(dirname "$(readlink -e "$0")")/etc"

source "${CONFIG_DIR}/xbs.cfg"
source "${SHARE_DIR}/db-functions"

db-init_usage() {
	msg "usage: %s [platform1 platform2 ... platformX]" "${0##*/}"
	exit 1
}

db-init_run() {
	mkdir -p -- "${PKG_MAIN_POOLS}" "${SRC_MAIN_POOLS}" "${CLEANUP_DESTDIR}" "${SOURCE_CLEANUP_DESTDIR}" "${STAGING}"
}

for 'platform' in "${PLATFORMS[@]}"; do
	if [ -n $1 ]; then
		for '_platform' in "$@"; do
			# Rename plataform name ($_platform) to easily script usage
			_platform_name="${_platform/\//+}" _platform_name="${_platform_name,,}"

			if [ "${_platform_name}" == "${platform}" ]; then
				source "${CONFIG_DIR}/xbs.d/${_platform_name}.cfg"

				db-init_run
			else
				db-init-usage
			fi
		done
	else
		source "${CONFIG_DIR}/xbs.d/${platform}.cfg"

		db-init_run
	fi
done

# "${BIN_DIR}/db-repo-add" -p "${_platform}" "${PKG_REPOS[@]}"