summaryrefslogtreecommitdiff
path: root/Documentation/maintainers/new/set-based-remove.sh
blob: 4f0da7ed7848108189ba7eda0da1786e34fbe8c5 (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
#!/bin/bash

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

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

: ${TARGET_REPO:="$(pwd)"}

help() {
	echo Simple set-based version removed.
	echo
	echo Given a set file, removes all packages of a specified version.
	echo Optionally, if target is a git repository, each change will be
	echo committed as \"cat/pn: drop VERSION*\".
	echo
	echo Reads TARGET_REPO from your environment, defaulting to the current directory.
	echo
	echo Usage: set-based-remove.sh SETNAME VERSION
	echo Example: set-based-remove.sh kde-plasma-5.19 5.19.1
	exit 0
}


SETNAME="$1"
VERSION="$2"

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

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

packages=$(get_package_list_from_set ${SETNAME})

for package in ${packages} ; do
	trap "echo Exited without finishing!; exit;" SIGINT SIGTERM
	pushd "${TARGET_REPO}/${package}" > /dev/null

	pn=$(basename $(pwd))

	rm -f ${pn}-${VERSION}.ebuild
	rm -f ${pn}-${VERSION}-r*.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 .

		popd > /dev/null
	done

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