summaryrefslogtreecommitdiff
path: root/Documentation/maintainers/new/copy-to-main-tree.sh
blob: 2c942e5079530e97ee979ff80614eaa16d6c970d (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
#!/bin/bash

# Requires:
# dev-util/pkgdev
# Optional:
# dev-vcs/git
# dev-util/pkgcheck

. $(dirname "$0")/lib.sh

: ${SOURCE_REPO:="$(realpath $(dirname $0)/../../../)"}
: ${TARGET_REPO:="$(pwd)"}

help() {
	echo Simple set-based ebuild copier.
	echo
	echo Given a set in the source repository, copies all ebuilds with the specified
	echo version into the target repository. Optionally, if target is a git repository,
	echo each ebuild will be committed as \"cat/pn: TARGETVERSION version bump\"
	echo
	echo Reads TARGET_REPO from your enviroment, defaulting to the current directory.
	echo
	echo Usage: copy-to-main-tree.sh SETNAME TARGETVERSION
	echo Example: copy-to-main-tree.sh kde-frameworks-5.72 5.72.0
	exit 0
}


SETNAME="$1"
TARGETVERSION="$2"

if [[ $1 == "--help" ]] ; then
	help
fi

if [[ -z "${SETNAME}" || -z "${TARGETVERSION}" ]] ; then
	echo ERROR: Not enough arguments
	echo
	help
fi

packages=$(get_package_list_from_set ${SETNAME})

for cp in ${packages} ; do
	trap "echo Exited without finishing!; exit;" SIGINT SIGTERM

	target_dir="${TARGET_REPO}/${cp}"

	if [[ ! -d "${target_dir}" ]] ; then
		mkdir "${target_dir}"
	fi

	pushd "${target_dir}" > /dev/null

	pn=$(basename $(pwd))
	ebuild="${pn}-${TARGETVERSION}.ebuild"

	cp "${SOURCE_REPO}/${cp}/${ebuild}" .
	pkgdev manifest

	popd > /dev/null

done

if [[ -d "${TARGET_REPO}/.git" ]] && hash git 2>/dev/null && hash pkgdev 2>/dev/null; then
	for cp in ${packages} ; do
		pushd "${TARGET_REPO}/${cp}" > /dev/null

		git add .
		pkgdev commit . -m "${TARGETVERSION} version bump"

		popd > /dev/null
	done

	if hash pkgcheck 2>/dev/null; then
		pushd "${TARGET_REPO}" > /dev/null
			pkgcheck scan --commits
		popd > /dev/null
	fi
fi