aboutsummaryrefslogtreecommitdiff
blob: 9620cc06a02b31f4de471877316f2ecbd8c8e88e (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
#!/usr/bin/env bash
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1

if ! ___eapi_has_prefix_variables; then
	ED=${D}
fi

got_mode=
for arg; do
	# - can either be an option or a mode string
	[[ ${arg} == -* && ${arg} != -[ugorwxXst] ]] && continue
	if [[ ! ${got_mode} ]]; then
		got_mode=1
		continue
	fi
	if [[ ${arg} != /* ]]; then
		eqawarn "Relative path passed to '${0##*/}': ${arg}"
		eqawarn "This is unsupported. Please use 'chmod' when you need to work on files"
		eqawarn "outside the installation image (\${ED})."
	fi
done

# we can't prefix all arguments because
# chmod takes random options
slash="/"
chmod "${@/#${slash}/${ED%/}${slash}}"
ret=$?
[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
exit $ret