blob: 13e45247190f5a2e30adaae3988b73a31871a449 (
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
#!/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
# STAGE A
# CHECK POSITIONAL PARAMETERS
inspector "$@"
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; }
# 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)
if _seed_net "$@"; then
sinit_flow_monitor "SEED"
fi
if [[ "$(awk -F '=' '/CATALYST/{ print $2 }' < "${CLOCALLG}/sinprog")" == 0 ]] || echo "$@" | grep -q 'force'; then
_callying_catalyst "$@" || die "Catalyst failed"
sinit_flow_monitor "CATALYST"
else
if echo "${_lawful_args[@]}" | grep -q 'gcat'; then
_e_report_back "Catalyst: Lawful entry detected, proceeding..."
else
if echo "${_enforce_args[@]}" | grep -q 'gcat'; then
_e_report_back "Catalyst: Enforce entry detected, forcing..."
_callying_catalyst "$@" "force" || die
sinit_flow_monitor "CATALYST"
else
if _repeat_subpart "Catalyst" "configured"; then
_callying_catalyst "$@" || die
else
echo -e "\e[33mProceeding with extraction...\e[0m"
fi
fi
fi
fi
if [[ "$(awk -F '=' '/EXTRACTION/{ print $2 }' < "${CLOCALLG}/sinprog")" == 0 ]] || echo "$@" | grep -q 'force'; then
_extracting_catalyst "$@" || die "Extraction failed"
sinit_flow_monitor "EXTRACTION"
else
if echo "${_lawful_args[@]}" | grep -q 'extr'; then
_e_report_back "Extraction: Lawful entry detected, proceeding..."
else
if echo "${_enforce_args[@]}" | grep -q 'extr'; then
_e_report_back "Extraction: Enforce entry detected, forcing..."
_extracting_catalyst "$@" "force" || die
sinit_flow_monitor "EXTRACTION"
else
if _repeat_subpart "Extraction" "completed"; then
_extracting_catalyst "$@" || die
else
echo -e "\e[33mProceeding to Part: B...\e[0m"
fi
fi
fi
fi
unset CATDIR
unset TARGETNAME
unset TARGETPATH
unset TARGETSTAMP
;;
precomp)
if _seed_net "$@"; then
sinit_flow_monitor "SEED"
fi
if [[ "$(awk -F '=' '/PRECOMP/{ print $2 }' < "${CLOCALLG}/sinprog")" == 0 ]] || echo "$@" | grep -q 'force'; then
_workdir_check "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2" \
"${CDISTDIR}/workdir-precomp" "$@" || die
else
if echo "${_lawful_args[@]}" | grep -q 'gprec'; then
_e_report_back "Precomp: Lawful entry detected, proceeding..."
else
if echo "${_enforce_args[@]}" | grep -q 'gprec'; then
_e_report_back "Precomp: Enforce entry detected, forcing..."
_extracting_catalyst "$@" "force" || die
else
if _repeat_subpart "Precomp Extraction" "completed"; then
_workdir_check
"${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2" \
"${CDISTDIR}/workdir-precomp" "$@"
else
echo -e "\e[33mProceeding to Part: B...\e[0m"
fi
fi
fi
fi;;
esac
}
if [[ "$(awk -F '=' '/PARTA/{ print $2 }' < "${CLOCALLG}/sinprog")" == 0 || -n $(echo "${_flag_force_new}") ]] || echo "${_enforce_args[@]}" | grep -q 'gparta'; then
if [[ -n $(echo "${_flag_force_new}") ]] || echo "${_enforce_args[@]}" | grep -q 'gparta'; then
_part_a "$@" "force" || die
sinit_flow_monitor "PARTA"
else
_part_a "$@" || die
sinit_flow_monitor "PARTA"
fi
else
if echo "${_lawful_args[@]}" | grep -q 'gparta'; then
_e_report_back "Lawful entry detected on parta, proceeding..."
else
if echo "${_enforce_args[@]}" | grep 'gparta'; then
_e_report_back "Enforce entry detected on parta, forcing..."
_part_a "$@" "force" || die
sinit_flow_monitor "PARTA"
else
if repeat_parta "A"; then
_part_a "$@"
fi
fi
fi
fi
case "${_flag_base}" in
catalyst )
BWORKDIR="${CDISTDIR}/workdir-catalyst";;
precomp )
BWORKDIR="${CDISTDIR}/workdir-precomp";;
esac
echo "============================================================================"
echo -e "\e[35m PART: B Preparing to enter the new system\e[0m"
echo "============================================================================"
_am_i_root "$UID" && echo -e "[\e[32m*\e[0m] Requesting root privileges" \
|| { echo -e "[\e[31m*\e[0m] Requesting root privileges"; exit 1; }
TARGETSTAMP="$(grep 'version_stamp' "${CCONFDIR}/system/catalyst/stage3.spec" \
| sed '/^#/ d' | awk -F ' ' '{ print $2 }' | sed -e "s_\"__g")"
if [[ -n "${_flag_start_new}" ]] || echo "${_enforce_args[@]}" | grep 'gpartb'; then
if _prepare_chroot "${BWORKDIR}" "$@" 'cforce'; then
_clean_target "${BWORKDIR}" "$@" || die
else
die "Cleaning failed"
fi
else
if _prepare_chroot "${BWORKDIR}" "$@"; then
_clean_target "${BWORKDIR}" "$@" || die
else
die "Cleaning failed"
fi
fi
SUBBUILD=0
GSEVER="${GSEVER}.${SUBBUILD}"
while true; do
if ! ls "${CDISTDIR}/stage3-amd64-${GSEVER}.tar.bz2" >/dev/null 2>&1; then
echo -e "\e[34mArchiving...\e[0m"
tar cvf "${CDISTDIR}/stage3-amd64-${GSEVER}.tar.bz2" -C "${BWORKDIR}" >/dev/null 2>&1 \
&& { print_inf 1 && echo -e "\e[34mYou can find your system @ ${CDISTDIR}\e[0m"
echo -e "\e[34mWith version extension: ${GSEVER}\e[0m"; } \
|| die "Failed"
break
else
((++SUBBUILD))
fi
done
exit
gpg --armor --export email > "${FINALDIST}/key.asc" # THIS WILL BE ADDED TO THE HOSTS
gpg --detach-sign -o ${GSE_VER}.gpg "${FINALDIST}/${IMAGE}"
#rm -rf "$1/sinit.d"
unset CATDIR
unset TARGETPATH
unset TARGETSTAMP
|