blob: b025052eb377cb5af8fefc982d395b20cca4974a (
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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
#!/bin/bash
if echo "${_flag_tty}" | grep -q 'sshd'; then
LC_COLLATE="C"
LC_ALL="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
fi
if [[ -z "${_flag_base}" ]]; then
_e_report_back "You must choose a base if your run gse without main menu. Aborting..."
_e_report_back "See man 1 gse for base options."
die "Aborting actions..."
fi
# ENVIROMENTAL ECHO FOR TESTING
echo "$@"
# STAGE A
clear
echo "============================================================================"
echo -e "\e[35m PART:A Fundamentals\e[0m"
echo "============================================================================"
echo -e "[\e[32m*\e[0m] \e[34mInitializing\e[0m"
# ALL ESSENTIAL VARIABLES FOR THE DOWNLOAD AND AUTHENTICATION PROCESS
source "${CWORKDIR}/etc/gentoo.conf" >/dev/null 2>&1 \
&& echo -e "[\e[32m*\e[0m] \e[35mExporting variables\e[0m" \
|| { echo -e "[\e[31m*\e[0m] \e[35mExporting variables\e[0m"; echo -e "\e[31mAborting\e[0m..."; sleep 2; return 1; }
# CHECK POSITIONAL PARAMETERS
inspector "$@"
# PART A FUNDAMENTALS
_part_a() {
# CHECK IF THERE IS ANY WORK DONE
if [[ "$(awk -F '=' '/CHECK/{ print $2 }' < "${CLOCALLG}/sinprog")" == 1 ]]; then
if echo "${_flag_base}" | grep -q 'catalyst'; then
_start_again "${CDISTDIR}/workdir-catalyst" "$@"
elif echo "${_flag_base}" | grep -q 'precomp'; then
_start_again "${CDISTDIR}/workdir-precomp" "$@"
fi
elif echo "$@" | grep -q 'force'; then
if echo "${_flag_base}" | grep -q 'catalyst'; then
_start_again "${CDISTDIR}/workdir-catalyst" "$@" "force"
elif echo "${_flag_base}" | grep -q 'precomp'; then
_start_again "${CDISTDIR}/workdir-precomp" "$@" "force"
fi
fi
# CALL CATALYST BUILD OR PRECOMPILED BUILD
case "${_flag_base}" in
catalyst )
echo "$@"
# PART NETWORK SEED
_do_hs '\-gseed' "before" "seed part"
_seed_net() {
if [[ $(echo "${_flag_network}") == 0 ]]; then
if _call_hook_points 'SEED' 'gseed' 'Part: Fetch tarball' "_fetch_new" "$@"; then
sinit_flow_monitor "SEED"
else
die "Fetching tarball FAILED"
fi
elif [[ ! -e "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2" ]]; then
die "No local tarball is present. Please enable network connection and try again"
elif [[ -e "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2" ]]; then
_e_report_back "Stage3 tarball located"
_e_report_back "Calling catalyst"
fi
}
_seed_net "$@"
_do_hs '\+gseed' "after" "seed part"
# PART CATALYST
_do_hs '\-gcat' "before" "catalyst part"
if _call_hook_points 'CATALYST' 'gcat' 'Part: Catalyst' "_callying_catalyst" "$@"; then
sinit_flow_monitor "CATALYST"
else
die "Part: Catalyst FAILED"
fi
_do_hs '\+gcat' "after" "Catalyst"
# PART CATALYST STAGE3 AND PORTAGE SNAPSHOT EXTRACTION
_do_hs '\-gextr' "before" "Catalyst Extraction"
if _call_hook_points 'EXTRACTION' 'gextr' 'Part: Catalyst Extraction' "_extracting_catalyst" "$@"; then
sinit_flow_monitor "EXTRACTION"
else
die "Part: Catalyst Extraction FAILED"
fi
_do_hs '\+gextr' "after" "Catalyst Extraction"
unset CATDIR
unset TARGETNAME
unset TARGETPATH
unset TARGETSTAMP
;;
precomp )
# PART NETWORK SEED
_do_hs '\-gseed' "before" "seed part"
_seed_net() {
if [[ $(echo "${_flag_network}") == 0 ]]; then
if _call_hook_points 'SEED' 'gseed' 'Part: Fetch tarball' "_fetch_new" "$@"; then
sinit_flow_monitor "SEED"
else
die "Fetching tarball FAILED"
fi
elif [[ ! -e "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2" ]]; then
die "No local tarball is present. Please enable network connection and try again"
elif [[ -e "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2" ]]; then
_e_report_back "Stage3 tarball located"
_e_report_back "Calling catalyst"
fi
}
_seed_net "$@"
_do_hs '\+gseed' "after" "seed part"
# PART PRECOMP STAGE3 EXTRACTION
_prec_workdir_function() {
_workdir_check "$1" "$2" "${@:3}" || die
}
_do_hs '\-gprec' "before" "Precomp extraction"
if _call_hook_points 'PRECOMP' 'gprec' 'Part: prec' "_prec_workdir_function" "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2" "${CDISTDIR}/workdir-precomp" "$@"; then
sinit_flow_monitor "PRECOMP"
else
die "Part: Precomp FAILED"
fi
_do_hs '\+gprec' "after" "Precomp extraction"
;;
esac
}
# PART A BEGINS
_do_hs '\-gparta' "before" "Part: A"
if _call_hook_points 'PARTA' "gparta" 'Part: A' "_part_a" "$@"; then
sinit_flow_monitor "PARTA"
else
die "Part: A FAILED"
fi
_do_hs '\+gparta' "after" "Part: A"
# EXPORT WORKDIR
case "${_flag_base}" in
catalyst )
BWORKDIR="${CDISTDIR}/workdir-catalyst";;
precomp )
BWORKDIR="${CDISTDIR}/workdir-precomp";;
esac
# PART B FUNCTION
_part_b() {
echo "============================================================================"
echo -e "\e[35m PART: B Preparing to enter the new system\e[0m"
echo "============================================================================"
if _am_i_root "$UID"; then
echo -e "[\e[32m*\e[0m] Requesting root privileges"
else
die "Requesting root privileges"
fi
if _prepare_chroot "$@"; then
_do_hs '\-gclean' "before" "clean part"
_clean_target "$@" || die
_do_hs '\+gclean' "after" "clean part"
else
die "Cleaning failed"
fi
}
# PART B BEGINS
_do_hs '\-gpartb' "before" "Part: B"
if _call_hook_points 'PARTB' "gpartb" 'Part: B' "_part_b" "${BWORKDIR}" "$@"; then
sinit_flow_monitor "PARTB"
else
die "Part: B FAILED"
fi
_do_hs '\+gpartb' "after" "Part: B"
if echo "${_flag_base}" | grep -q 'catalyst'; then
_archive_ "${BWORKDIR}" "catalyst"
elif echo "${_flag_base}" | grep -q 'precomp'; then
_archive_ "${BWORKDIR}" "precomp"
fi
|