summaryrefslogtreecommitdiff
path: root/any-to-ours
blob: a84c3683731e410675454be7f9867e4e7b48a2c0 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
# Releases 'any' packages from Arch-derivations arches to ours

trap_exit() {
	echo
	error "$@"
	exit 1
}

platform_name="${platform/\//+}"
source "$(dirname "$(readlink -e "$0")")/config_${platform_name,,}"
source "$(dirname "$(readlink -e "$0")")/db-libremessages"

# From makepkg
set -E

trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT
trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT
trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR

# Traverse all Arch repos
for '_repo' in "${MAIN_REPOS[@]}"; do
	msg "Processing %s..." "${_repo}"

	# Find 'any' packages
	# This is hardcoded but it could release other arches...
	PKGS=($(find "${REPO_DIR}/${_repo}/os/${ARCHES[0]}/" \
	             -iname '*-any.pkg.tar.?z' \
	             -printf "%f "))

	if [ ${#PKGS[@]} -eq 0 ]; then
		msg2 "No '%s' packages here" any
		continue
	fi

	for '_arch' in "${ARCHES[@]}"; do
		msg2 "Syncing %s..." "${_arch}"

		# Sync 'any' only and extract the synced packages
		SYNCED=($(
				rsync -av \
					--include='*-any.pkg.tar.?z' \
					--include='*-any.pkg.tar.?z.sig' \
					--exclude='*' \
					"${REPO_DIR}/${_repo}/os/${ARCHES[0]}/" \
					"${REPO_DIR}/${_repo}/os/${_arch}/" 2>&1 | \
					grep 'any\.pkg\.tar\..z$' | \
					cut -d ' ' -f 1 ))

		if [ "${#SYNCED[@]}" -eq 0 ]; then
			msg2 "Already synced (or error happened)"
			continue
		fi

		msg2 "Synced %d packages: %s" "${#SYNCED[@]}" "${SYNCED[*]}"

		msg2 "Adding to db..."

		pushd "${REPO_DIR}/${_repo}/os/${_arch}/" >/dev/null

		# Add the packages to the db
		repo-add "${_repo}${DB_EXT}" "${SYNCED[@]}"

		popd >/dev/null 

		# Avoid mixups
		unset 'SYNCED' 'PKGS'
	done
	if [ -n "${MULTILIB}" ]; then
		for '_repo_multilib' in "${MULTILIB_REPOS[@]}"; do
			msg "Processing %s..." "${_repo}" '(multilib)'

			# Find 'any' packages
			# This is hardcoded but it could release other arches...
			PKGS_MULTILIB=($(find "${REPO_DIR}/${_repo_multilib}/os/${MULTILIB[0]}/" \
			                      -iname '*-any.pkg.tar.?z' \
			                      -printf "%f "))

			if [ ${#PKGS_MULTILIB[@]} -eq 0 ]; then
				msg2 "No '%s' multilib packages here" any
				continue
			fi

			for '_arch_multilib' in "${MULTILIB[@]}"; do
				msg2 "Syncing %s..." "${_arch_multilib}" '(multilib)'

				# Sync 'any' only and extract the synced packages
				SYNCED_MULTILIB=($(
						rsync -av \
							--include='*-any.pkg.tar.?z' \
							--include='*-any.pkg.tar.?z.sig' \
							--exclude='*' \
							"${REPO_DIR}/${_repo_multilib}/os/${MULTILIB[0]}/" \
							"${REPO_DIR}/${_repo_multilib}/os/${_arch_multilib}/" 2>&1 | \
							grep 'any\.pkg\.tar\..z$' | \
							cut -d ' ' -f 1 ))

			if [ "${#SYNCED_MULTILIB[@]}" -eq 0 ]; then
				msg2 "Already synced (or error happened)"
				continue
			fi

			msg2 "Synced %d packages: %s" "${#SYNCED_MULTILIB[@]}" "${SYNCED_MULTILIB[*]}"

			msg2 "Adding Multilib to db..."

			pushd "${REPO_DIR}/${_repo_multilib}/os/${_arch_multilib}/" >/dev/null

			# Add the packages to the db
			repo-add "${_repo_multilib}${DB_EXT}" "${SYNCED_MULTILIB[@]}"

			popd >/dev/null

			# Avoid mixups
			unset 'SYNCED_MULTILIB' 'PKGS_MULTILIB'
		done
	fi
done