summaryrefslogtreecommitdiff
path: root/src/bin/db-init
blob: 42574a4c33d386bf89b572acbd1ac9cdc05df067 (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
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# Creates the repository structure defined in config
# Copyright (C) 2012-2015  Parabola Hackers <https://www.parabola.nu>

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

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

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

platforms=("${@:1}")

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

for '_platform' in "${PLATFORMS[@]}"; do
	if [ "${#}" -eq '0' ]; then
		source "${CONFIG_DIR}/xbs.d/${_platform}.cfg"

		db-init_run
	else
		for 'platform' in "${platforms[@]}"; do
			# Rename ("${plataform}") to easily script usage
			_platform_name="${platform/\//+}" _platform_name="${_platforms_name,,}"

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

				db-init_run
			else
				die "This %s plataform doesn't exist" "${plataform}"
			fi
		done
	fi
done

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