summaryrefslogtreecommitdiff
path: root/create-repo
blob: c977442d14c01988fd87c6cf0a29acd3e6ceb16f (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
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# Creates repository structure

source "$(dirname "$(readlink -e "$0")")/config_platforms"
source "$(dirname "$(readlink -e "$0")")/db-functions"

create-repo-usage() {
	msg "Usage: %s [platform] repo1 [repo2 ... repoX]" "${0##*/}"
	exit 1
}

if [ "$#" -eq '0' ]; then
	create-repo-usage
fi

for 'platform' in "${PLATFORMS[@]}"; do
	case "$1" in
	--platform|-platform|-p)

		# Don't create [--platform], [-platform] or [-p] and [<platforms>] repos
		_repos=($@) && unset _repos[0] _repos[1]

		# Rename plataform name ($2) to easily script usage
		_platform_name="${2/\//+}" _platform_name="${_platform_name,,}"

		if [ "${_platform_name}" == "${platform}" ]; then
			source "$(dirname "$(readlink -e "$0")")/config_${2}"

			msg "Creating repos... from ${PLATFORM_NAME} platform"
			for '_repo' in "${_repos[@]}"; do
				msg2 "Creating [%s]" "${_repo_all}"
				for '_arch' in "${ARCHES[@]}"; do
					mkdir -p "${REPO_DIR}/${_repo}/os/${_arch}" || \
						error "Failed creating %s dir" "${_arch}" "from ${PLATFORM_NAME} platform"
				done
			done

			msg "Don't forget to add them to the PKG_REPOS array on %s" "$(dirname "$(readlink -e "$0")")/config_${2}"
		else
			create-repo-usage
		fi
		;;
	*)
		source "$(dirname "$(readlink -e "$0")")/config_${platform}"

		msg "Creating repos... from all platforms"
		for '_repo_all' in "${@}"; do
			msg2 "Creating [%s]" "${_repo_all}"
			for '_arch' in "${ARCHES[@]}"; do
				mkdir -p "${REPO_DIR}/${_repo_all}/os/${_arch}" || \
					error "Failed creating %s dir" "${_arch}" "in all platforms"
			done
		done

		msg "Don't forget to add them to the PKG_REPOS array on %s" "$(dirname "$(readlink -e "$0")")/config_${platform}"
		;;
	esac
done

# if [ -n "${MULTILIB_ARCHES}" ]; then
# fi