-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathpacman-7.1.0-add-asroot-option.patch
More file actions
131 lines (118 loc) · 3.24 KB
/
Copy pathpacman-7.1.0-add-asroot-option.patch
File metadata and controls
131 lines (118 loc) · 3.24 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
diff --git a/scripts/libmakepkg/executable/fakeroot.sh.in b/scripts/libmakepkg/executable/fakeroot.sh.in
index 469ac03a..d87eb8ee 100644
--- a/scripts/libmakepkg/executable/fakeroot.sh.in
+++ b/scripts/libmakepkg/executable/fakeroot.sh.in
@@ -28,6 +28,9 @@ source "$MAKEPKG_LIBRARY/util/message.sh"
executable_functions+=('executable_fakeroot')
executable_fakeroot() {
+ if (( EUID == 0 && ASROOT)); then
+ return 0
+ fi
if (( SOURCEONLY || BUILDPKG )); then
if ! type -p fakeroot >/dev/null; then
error "$(gettext "Cannot find the %s binary.")" "fakeroot"
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index da69df8b..cf09bac9 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -79,6 +79,7 @@ SIGNPKG=''
SPLITPKG=0
SOURCEONLY=0
VERIFYSOURCE=0
+ASROOT=0
MAKEPKG_LINT_PKGBUILD=${MAKEPKG_LINT_PKGBUILD:-1}
@@ -879,6 +880,27 @@ run_split_packaging() {
pkgname=("${pkgname_backup[@]}")
}
+build_package() {
+ if (( SOURCEONLY )); then
+ create_srcpackage
+ if (( INFAKEROOT )); then
+ msg "$(gettext "Leaving %s environment.")" "fakeroot"
+ fi
+ exit $E_OK
+ fi
+
+ prepare_buildenv
+
+ chmod 755 "$pkgdirbase"
+ if (( ! SPLITPKG )); then
+ run_single_packaging
+ else
+ run_split_packaging
+ fi
+
+ create_debug_package
+}
+
usage() {
printf "makepkg (pacman) %s\n" "$makepkg_version"
echo
@@ -967,7 +989,7 @@ OPT_LONG=('allsource' 'check' 'clean' 'cleanbuild' 'config:' 'dir:' 'force' 'gen
'skippgpcheck' 'source' 'syncdeps' 'verifysource' 'version')
# Pacman Options
-OPT_LONG+=('asdeps' 'noconfirm' 'needed' 'noprogressbar')
+OPT_LONG+=('asdeps' 'noconfirm' 'needed' 'noprogressbar' 'asroot')
if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
exit $E_INVALID_OPTION
@@ -980,6 +1002,7 @@ while true; do
# Pacman Options
--asdeps) ASDEPS=1;;
--needed) NEEDED=1;;
+ --asroot) ASROOT=1;;
--noconfirm) PACMAN_OPTS+=("--noconfirm") ;;
--noprogressbar) PACMAN_OPTS+=("--noprogressbar") ;;
@@ -1117,7 +1140,7 @@ if (( LOGGING )) && ! ensure_writable_dir "LOGDEST" "$LOGDEST"; then
fi
if (( ! INFAKEROOT )); then
- if (( EUID == 0 )); then
+ if (( EUID == 0 && ! ASROOT )); then
error "$(gettext "Running %s as root is not allowed as it can cause permanent,\n\
catastrophic damage to your system.")" "makepkg"
exit $E_ROOT
@@ -1243,23 +1266,7 @@ fi
# Run the bare minimum in fakeroot
if (( INFAKEROOT )); then
- if (( SOURCEONLY )); then
- create_srcpackage
- msg "$(gettext "Leaving %s environment.")" "fakeroot"
- exit $E_OK
- fi
-
- prepare_buildenv
-
- chmod 755 "$pkgdirbase"
- if (( ! SPLITPKG )); then
- run_single_packaging
- else
- run_split_packaging
- fi
-
- create_debug_package
-
+ build_package
msg "$(gettext "Leaving %s environment.")" "fakeroot"
exit $E_OK
fi
@@ -1303,7 +1310,11 @@ if (( SOURCEONLY )); then
check_source_integrity all
cd_safe "$startdir"
- enter_fakeroot
+ if (( EUID == 0 )); then
+ build_package
+ else
+ enter_fakeroot
+ fi
if [[ $SIGNPKG = 'y' ]]; then
msg "$(gettext "Signing package...")"
@@ -1409,7 +1420,11 @@ else
cd_safe "$startdir"
fi
- enter_fakeroot
+ if (( EUID == 0 )); then
+ build_package
+ else
+ enter_fakeroot
+ fi
create_package_signatures || exit $E_PRETTY_BAD_PRIVACY
fi