@@ -20,12 +20,12 @@ DIFFOSCOPE="diffoscope"
2020orig_argv=(" $0 " " $@ " )
2121src_owner=${SUDO_USER:- $USER }
2222function check_root() {
23- (( EUID == 0 )) && return
24- if type -P sudo > /dev/null; then
25- exec sudo -- " ${orig_argv[@]} "
26- else
27- exec su root -c " $( printf ' %q' " ${orig_argv[@]} " ) "
28- fi
23+ (( EUID == 0 )) && return
24+ if type -P sudo > /dev/null; then
25+ exec sudo -- " ${orig_argv[@]} "
26+ else
27+ exec su root -c " $( printf ' %q' " ${orig_argv[@]} " ) "
28+ fi
2929}
3030
3131# Use a private gpg keyring
@@ -34,98 +34,98 @@ function gpg() {
3434}
3535
3636function init_gnupg() {
37- [ ! -d " $BUILDDIRECTORY /_gnupg" ] && mkdir -p " $BUILDDIRECTORY /_gnupg"
37+ [ ! -d " $BUILDDIRECTORY /_gnupg" ] && mkdir -p " $BUILDDIRECTORY /_gnupg"
3838
39- # ensure signing key is available
40- gpg --auto-key-locate nodefault,wkd --locate-keys pierre@archlinux.de
39+ # ensure signing key is available
40+ gpg --auto-key-locate nodefault,wkd --locate-keys pierre@archlinux.de
4141}
4242
4343# Desc: Sets the appropriate colors for output
4444function colorize() {
45- # prefer terminal safe colored and bold text when tput is supported
46- if tput setaf 0 & > /dev/null; then
47- ALL_OFF=" $( tput sgr0) "
48- BOLD=" $( tput bold) "
49- BLUE=" ${BOLD} $( tput setaf 4) "
50- GREEN=" ${BOLD} $( tput setaf 2) "
51- RED=" ${BOLD} $( tput setaf 1) "
52- YELLOW=" ${BOLD} $( tput setaf 3) "
53- else
54- ALL_OFF=" \e[0m"
55- BOLD=" \e[1m"
56- BLUE=" ${BOLD} \e[34m"
57- GREEN=" ${BOLD} \e[32m"
58- RED=" ${BOLD} \e[31m"
59- YELLOW=" ${BOLD} \e[33m"
60- fi
61- readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
45+ # prefer terminal safe colored and bold text when tput is supported
46+ if tput setaf 0 & > /dev/null; then
47+ ALL_OFF=" $( tput sgr0) "
48+ BOLD=" $( tput bold) "
49+ BLUE=" ${BOLD} $( tput setaf 4) "
50+ GREEN=" ${BOLD} $( tput setaf 2) "
51+ RED=" ${BOLD} $( tput setaf 1) "
52+ YELLOW=" ${BOLD} $( tput setaf 3) "
53+ else
54+ ALL_OFF=" \e[0m"
55+ BOLD=" \e[1m"
56+ BLUE=" ${BOLD} \e[34m"
57+ GREEN=" ${BOLD} \e[32m"
58+ RED=" ${BOLD} \e[31m"
59+ YELLOW=" ${BOLD} \e[33m"
60+ fi
61+ readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
6262}
6363colorize
6464
6565# Desc: Message format
6666function msg() {
67- local mesg=$1 ; shift
67+ local mesg=$1 ; shift
6868 # shellcheck disable=SC2059
69- printf " ${GREEN} ==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF} \n" " $@ " >&2
69+ printf " ${GREEN} ==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF} \n" " $@ " >&2
7070}
7171
7272# Desc: Sub-message format
7373function msg2() {
74- local mesg=$1 ; shift
74+ local mesg=$1 ; shift
7575 # shellcheck disable=SC2059
76- printf " ${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF} \n" " $@ " >&2
76+ printf " ${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF} \n" " $@ " >&2
7777}
7878
7979# Desc: Warning format
8080function warning() {
81- local mesg=$1 ; shift
81+ local mesg=$1 ; shift
8282 # shellcheck disable=SC2059
83- printf " ${YELLOW} ==> $( gettext " WARNING:" ) ${ALL_OFF}${BOLD} ${mesg}${ALL_OFF} \n" " $@ " >&2
83+ printf " ${YELLOW} ==> $( gettext " WARNING:" ) ${ALL_OFF}${BOLD} ${mesg}${ALL_OFF} \n" " $@ " >&2
8484}
8585
8686# Desc: Error format
8787function error() {
88- local mesg=$1 ; shift
88+ local mesg=$1 ; shift
8989 # shellcheck disable=SC2059
90- printf " ${RED} ==> $( gettext " ERROR:" ) ${ALL_OFF}${BOLD} ${mesg}${ALL_OFF} \n" " $@ " >&2
90+ printf " ${RED} ==> $( gettext " ERROR:" ) ${ALL_OFF}${BOLD} ${mesg}${ALL_OFF} \n" " $@ " >&2
9191}
9292
9393# #
9494# usage : lock( $fd, $file, $message, [ $message_arguments... ] )
9595# #
9696lock () {
97- # Only reopen the FD if it wasn't handed to us
98- if ! [[ " /dev/fd/$1 " -ef " $2 " ]]; then
99- mkdir -p -- " $( dirname -- " $2 " ) "
100- eval " exec $1 >" ' "$2"'
101- fi
97+ # Only reopen the FD if it wasn't handed to us
98+ if ! [[ " /dev/fd/$1 " -ef " $2 " ]]; then
99+ mkdir -p -- " $( dirname -- " $2 " ) "
100+ eval " exec $1 >" ' "$2"'
101+ fi
102102
103- flock -n " $1 "
103+ flock -n " $1 "
104104}
105105
106106# #
107107# usage : slock( $fd, $file, $message, [ $message_arguments... ] )
108108# #
109109slock () {
110- # Only reopen the FD if it wasn't handed to us
111- if ! [[ " /dev/fd/$1 " -ef " $2 " ]]; then
112- mkdir -p -- " $( dirname -- " $2 " ) "
113- eval " exec $1 >" ' "$2"'
114- fi
115-
116- if ! flock -sn " $1 " ; then
117- flock -s " $1 "
118- fi
110+ # Only reopen the FD if it wasn't handed to us
111+ if ! [[ " /dev/fd/$1 " -ef " $2 " ]]; then
112+ mkdir -p -- " $( dirname -- " $2 " ) "
113+ eval " exec $1 >" ' "$2"'
114+ fi
115+
116+ if ! flock -sn " $1 " ; then
117+ flock -s " $1 "
118+ fi
119119}
120120
121121# #
122122# usage : lock_close( $fd )
123123# #
124124lock_close () {
125- local fd=$1
126- # https://github.com/koalaman/shellcheck/issues/862
127- # shellcheck disable=2034
128- exec {fd}>& -
125+ local fd=$1
126+ # https://github.com/koalaman/shellcheck/issues/862
127+ # shellcheck disable=2034
128+ exec {fd}>& -
129129}
130130
131131# Desc: Executes an command inside a given nspawn container
@@ -134,11 +134,11 @@ lock_close() {
134134function exec_nspawn(){
135135 local container=$1
136136 systemd-nspawn -q \
137- --as-pid2 \
138- --register=no \
139- --pipe \
140- -E " PATH=/usr/local/sbin:/usr/local/bin:/usr/bin" \
141- -D " $BUILDDIRECTORY /$container " " ${@: 2} "
137+ --as-pid2 \
138+ --register=no \
139+ --pipe \
140+ -E " PATH=/usr/local/sbin:/usr/local/bin:/usr/bin" \
141+ -D " $BUILDDIRECTORY /$container " " ${@: 2} "
142142}
143143
144144# Desc: Removes the root container
@@ -236,11 +236,11 @@ function init_chroot(){
236236 else
237237
238238 if lock 9 " $BUILDDIRECTORY " /root.lock; then
239- printf ' Server = %s\n' " $HOSTMIRROR " > " $BUILDDIRECTORY " /root/etc/pacman.d/mirrorlist
240- exec_nspawn root pacman -Syu --noconfirm
241- lock_close 9
239+ printf ' Server = %s\n' " $HOSTMIRROR " > " $BUILDDIRECTORY " /root/etc/pacman.d/mirrorlist
240+ exec_nspawn root pacman -Syu --noconfirm
241+ lock_close 9
242242 else
243- msg " Couldn't acquire lock on root chroot, didn't update."
243+ msg " Couldn't acquire lock on root chroot, didn't update."
244244 fi
245245 fi
246246 trap - ERR INT
392392
393393xdg_repro_dir= " ${XDG_CONFIG_HOME:- $HOME / .config} /archlinux-repro"
394394if [[ -r " $xdg_repro_dir /repro.conf" ]]; then
395- # shellcheck source=/dev/null
396- source " $xdg_repro_dir /repro.conf"
395+ # shellcheck source=/dev/null
396+ source " $xdg_repro_dir /repro.conf"
397397elif [[ -r " $HOME /.repro.conf" ]]; then
398- # shellcheck source=/dev/null
399- source " $HOME /.repro.conf"
398+ # shellcheck source=/dev/null
399+ source " $HOME /.repro.conf"
400400fi
401401
402402
0 commit comments