summaryrefslogtreecommitdiff
path: root/create-repo
blob: 7905a0a5de34a1a3f4bc15b4c91c7db5959e5ec0 (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
#!/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)
		_repos=($@) && unset _repos[0] _repos[1]

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

			msg "Creating repos... from $2 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 $2 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