aboutsummaryrefslogtreecommitdiff
blob: 0d043c62b91b35f95591390713870b4b8275d9a4 (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
#!/bin/bash

# if one thing fails, abort entirely
set -e

to_install=(world)

if [[ $1 = lucky ]]; then
	eix-update
	eix --stable --only-names | grep -E -v '^(acct|virtual|sec)-' | sort -u > /tmp/stable
	eix --installed --only-names | sort -u > /tmp/installed
	comm -23 /tmp/stable /tmp/installed > /tmp/uninstalled-stable
	sed -i 's/--binpkg-respect-use//' /etc/portage/make.conf

	to_install=(--autounmask --autounmask-keep-keywords --autounmask-license n --autounmask-write --autounmask-continue $(shuf -n1 /tmp/uninstalled-stable))
elif [[ $1 ]]; then
	pushd /etc/portage/variants/$1
	while read -r -d '' line; do
		dest=../../${line%.footer}
		if [[ ${line} = world* ]]; then
			dest=/var/lib/portage/world
		fi

		if [[ ${line} = world.remove ]]; then
			emerge -C $(<"${line}")
		elif [[ ${line} = *.footer ]]; then
			cat "${line}" >> "${dest}"
		else
			mkdir -p "${dest%/*}"
			cp "${line}" "${dest}"
		fi
	done < <(find . -type f -printf '%P\0')
	if [[ -f buildpkgonly ]]; then
		./buildpkgonly
	fi
	popd
fi

emerge -uDNkq --changed-deps --backtrack=100 --keep-going "${to_install[@]}"

if [[ ! $1 ]]; then
	emerge --depclean --quiet-unmerge-warn
fi