aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos.K <freedomrfox@gmail.com>2017-06-23 14:56:15 +0300
committerChristos.K <freedomrfox@gmail.com>2017-06-23 14:56:15 +0300
commitc13e28ece77cfdfc47d9c21d8010a3ad88929a81 (patch)
tree9dc02b7fc506d498de122ac442af21d7bf00a6ea
parentFixed script's path issue (diff)
downloadGSE-c13e28ece77cfdfc47d9c21d8010a3ad88929a81.tar.gz
GSE-c13e28ece77cfdfc47d9c21d8010a3ad88929a81.tar.bz2
GSE-c13e28ece77cfdfc47d9c21d8010a3ad88929a81.zip
Changed pipes to if statements and fixed flow issues on bad conditions
-rwxr-xr-xscripts/chroot_scripts/cfunctions134
-rwxr-xr-xscripts/chroot_scripts/chroot_init2
-rwxr-xr-xscripts/functions/catalyst_functions4
-rwxr-xr-xscripts/functions/sinit_functions358
-rwxr-xr-xscripts/sinit32
5 files changed, 324 insertions, 206 deletions
diff --git a/scripts/chroot_scripts/cfunctions b/scripts/chroot_scripts/cfunctions
index 6651419..1b9d500 100755
--- a/scripts/chroot_scripts/cfunctions
+++ b/scripts/chroot_scripts/cfunctions
@@ -158,28 +158,40 @@ port_prof_f() {
if mkdir -p /usr/local/portage/{metadata,profiles}; then
chown -R portage:portage /usr/local/portage || return 1
echo 'gse' > /usr/local/portage/profiles/repo_name || return 1
+
cp "${CHDIR}/localrepo/layout.conf" "/usr/local/portage/metadata/layout.conf" || return 1
cp "${CHDIR}/localrepo/localrepo.conf" "/etc/portage/repos.conf/localrepo.conf" || return 1
- mkdir -p "/usr/local/portage/profiles/gse" \
- && mkdir -p "/usr/local/portage/profiles/default/linux/${ARCH}/13.0/gse" \
- && cp "${CHDIR}/profiles/parent-gse/eapi" \
- "/usr/local/portage/profiles/gse/eapi" \
- && cp "${CHDIR}/profiles/parent-gse/make.defaults" \
- "/usr/local/portage/profiles/gse/make.defaults" \
- && cp "${CHDIR}/profiles/parent-gse/package.use" \
- "/usr/local/portage/profiles/gse/package.use" \
- && cp "${CHDIR}/profiles/parent-gse/package.use.force" \
- "/usr/local/portage/profiles/gse/package.use.force" \
- && cp "${CHDIR}/profiles/child-gse/eapi" \
- "/usr/local/portage/profiles/default/linux/${ARCH}/13.0/gse/eapi" \
- && cp "${CHDIR}/profiles/child-gse/parent" \
- "/usr/local/portage/profiles/default/linux/${ARCH}/13.0/gse/parent" \
- && echo "# Local profile" > "/usr/local/portage/profiles/profiles.desc" \
- && echo "amd64 default/linux/amd64/13.0/gse exp" \
- >> "/usr/local/portage/profiles/profiles.desc" \
- && echo -e "[\e[32m*\e[0m] Creating [\e[34mprofile\e[0m]" \
- || { echo -e "[\e[31m*\e[0m] Creating [\e[34profile\e[0m]"; return 1; }
+ if mkdir -p "/usr/local/portage/profiles/gse"; then
+ if mkdir -p "/usr/local/portage/profiles/default/linux/${ARCH}/13.0/gse"; then
+ cp "${CHDIR}/profiles/parent-gse/eapi" \
+ "/usr/local/portage/profiles/gse/eapi" || return 1
+
+ cp "${CHDIR}/profiles/parent-gse/make.defaults" \
+ "/usr/local/portage/profiles/gse/make.defaults" || return 1
+
+ cp "${CHDIR}/profiles/parent-gse/package.use" \
+ "/usr/local/portage/profiles/gse/package.use" || return 1
+
+ cp "${CHDIR}/profiles/parent-gse/package.use.force" \
+ "/usr/local/portage/profiles/gse/package.use.force" || return 1
+
+ cp "${CHDIR}/profiles/child-gse/eapi" \
+ "/usr/local/portage/profiles/default/linux/${ARCH}/13.0/gse/eapi" || return 1
+
+ cp "${CHDIR}/profiles/child-gse/parent" \
+ "/usr/local/portage/profiles/default/linux/${ARCH}/13.0/gse/parent" || return 1
+
+ echo "# Local profile" > "/usr/local/portage/profiles/profiles.desc" || return 1
+ echo "amd64 default/linux/amd64/13.0/gse exp" \
+ >> "/usr/local/portage/profiles/profiles.desc" || return 1
+ else
+ echo -e "[\e[31m*\e[0m] Creating [\e[34profile\e[0m]"; return 1
+ fi
+ else
+ echo -e "[\e[31m*\e[0m] Creating [\e[34profile\e[0m]"
+ return 1
+ fi
else
echo -e "[\e[31m*\e[0m] Creating [\e[34profile\e[0m]"
return 1
@@ -207,7 +219,11 @@ part_portage() {
dist_ccashe_f || return 1
_emerge_depclear
- port_prof_f || return 1
+ if port_prof_f; then
+ echo -e "[\e[32m*\e[0m] Creating [\e[34mprofile\e[0m]"
+ else
+ ask_for_shell "Creating GSE profile failed"
+ fi
else
echo -e "\e[31mFaild\e[0m Configuring [\e[32mpackage.use\e[0m]"
ask_for_shell "Could not configure package.use files"
@@ -217,7 +233,7 @@ part_portage() {
exit 1
fi
- if echo "$@" | grep -q 'cforce' || ! echo "$@" | grep -q '_flag_auto'; then
+ if echo "$@" | grep -q 'cforce' || echo "$@" | grep -q '_flag_auto'; then
echo -e "\e[34mEnabling basic profile\e[0m]"
eselect profile set 1 && echo -e "\e[34mEnabled\e[0m" \
|| ask_for_shell "Could not enable basic profile"
@@ -317,9 +333,10 @@ _update_eix() {
if eix-update >LAST_ACTION 2>&1; then
_e_report_back "Update of eix was successful"
_monitor_chroot_flow "UPDATE"
+ return 0
else
echo "eix-update" > LAST_FAILED_COMMAND
- ask_for_shell "Updating eix failed"
+ ask_for_shell "Updating eix failed"
fi
}
@@ -342,11 +359,21 @@ _portage_subpart() {
if [[ -n $(echo "$@" | grep 'catalyst') ]]; then
#emerge --sync >LAST_ACTION 2>&1 && pass || { echo "emerge --sync" > LAST_FAILED_COMMAND; combat_medic; }
- rsync -aAXhrv root@192.168.2.2:/usr/portage/ /usr/portage/ >LAST_ACTION 2>&1 && pass || { echo "emerge--webrsync" > LAST_FAILED_COMMAND; combat_medic; }
+ fi rsync -aAXhrv root@192.168.2.2:/usr/portage/ /usr/portage/ >LAST_ACTION 2>&1; then
+ pass
+ else
+ echo "rsync -aAXhrv root@192.168.2.2:/usr/portage/ /usr/portage/" > LAST_FAILED_COMMAND
+ combat_medic
+ fi
env-update >LAST_ACTION 2>&1
elif [[ -n $(echo "$@" | grep 'precomp') ]]; then
- #emerge-webrsync >LAST_ACTION 2>&1 && pass || { echo "emerge--webrsync" > LAST_FAILED_COMMAND; combat_medic; }
- rsync -aAXhrv root@192.168.2.2:/usr/portage/ /usr/portage/ >LAST_ACTION 2>&1 && pass || { echo "emerge--webrsync" > LAST_FAILED_COMMAND; combat_medic; }
+ #emerge-webrsync >LAST_ACTION 2>&1 && pass || { echo "emerge-webrsync" > LAST_FAILED_COMMAND; combat_medic; }
+ if rsync -aAXhrv root@192.168.2.2:/usr/portage/ /usr/portage/ >LAST_ACTION 2>&1; then
+ pass
+ else
+ echo "rsync -aAXhrv root@192.168.2.2:/usr/portage/ /usr/portage/" > LAST_FAILED_COMMAND
+ combat_medic
+ fi
env-update >LAST_ACTION 2>&1
fi
@@ -359,7 +386,7 @@ _portage_subpart() {
_emerge_eix
echo -e "\e[34mUpdating eix database\e[0m"
if _update_eix; then
- :
+ _o_report_back "Updated"
else
combat_medic
fi
@@ -367,7 +394,7 @@ _portage_subpart() {
echo -e "\e[33meix located\e[0m"
echo -e "\e[34mUpdating eix database\e[0m"
if _update_eix; then
- :
+ _o_report_back "Updated"
else
combat_medic
fi
@@ -409,26 +436,38 @@ _configure_timezone() {
fi
if emerge --config sys-libs/timezone-data | grep "invalid" >LAST_ACTION 2>&1; then
- echo "UTC" >/etc/timezone; emerge --config sys-libs/timezone-data \
- && echo -e "[\e[32m*\e[0m] Resetting to UTC" \
- || { echo -e "[\e[31m*\e[0m] Resetting to UTC"; combat_medic; }
+ if echo "UTC" >/etc/timezone; emerge --config sys-libs/timezone-data; then
+ echo -e "[\e[32m*\e[0m] Resetting to UTC"
+ else
+ echo -e "[\e[31m*\e[0m] Resetting to UTC"
+ combat_medic
+ fi
fi
}
_configure_locale() {
if [[ -z $(cat "${CHDIR}/locale.gen" | sed '/^#/ d' | sed '/^\s*$/d') ]]; then
sed -i '/en_US.UTF-8/d' /etc/locale.gen
- echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && echo -e "[\e[32m*\e[0m] Configuring [\e[34mlocale\e[0m]" \
- || echo -e "[\e[31m*\e[0m] Configuring [\e[34mlocale\e[0m]"
+
+ if echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; then
+ echo -e "[\e[32m*\e[0m] Configuring [\e[34mlocale\e[0m]"
+ else
+ echo -e "[\e[31m*\e[0m] Configuring [\e[34mlocale\e[0m]"
+ fi
else
echo "$(cat "${CHDIR}/locale.gen")" > /etc/locale.gen
sed -i '/en_US.UTF-8/d' /etc/locale.gen
- echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && echo -e "[\e[32m*\e[0m] Configuring \e[34mlocale\e[0m" \
- || echo -e "[\e[31m*\e[0m] Configuring [\e[34mlocale\e[0m]"
+
+ if echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; then
+ echo -e "[\e[32m*\e[0m] Configuring \e[34mlocale\e[0m"
+ else
+ echo -e "[\e[31m*\e[0m] Configuring [\e[34mlocale\e[0m]"
+ fi
fi
locale-gen
export LC_ALL="en_US.UTF-8"
+
SETLOC=$(eselect locale list | grep en_US | awk -F ' ' '{ print $1 }' \
| awk -F '[' '{ print $2 }' | awk -F ']' '{ print $1 }')
@@ -518,18 +557,19 @@ _configure_fstab() {
}
_copy_function() {
- [[ -n $(cat "${CHDIR}/$1" | sed '/^#/ d' | sed '/^\s*$/d') ]] \
- && if cp "${CHDIR}/$1" /etc/conf.d/"$2"; then
- echo -e "[\e[32m*\e[0m] Configuring [\e[34m$3\e[0m]"
- else
- echo -e "[\e[31m*\e[0m] Configuring [\e[34m$3\e[0m]"
- echo "###################################" >> issues.info
- echo "Issue: $3 $(date)" >> issues.info
- echo "Command: ${CHDIR}/$1 /etc/conf.d/$2" >> issues.info
- echo "Items --->" >> issues.info
- cat /etc/conf.d/"$2" >> issues.info
- echo "###################################" >> issues.info
- ask_for_shell "Failed configuring $3"
+ if [[ -n $(cat "${CHDIR}/$1" | sed '/^#/ d' | sed '/^\s*$/d') ]]
+ if cp "${CHDIR}/$1" /etc/conf.d/"$2"; then
+ echo -e "[\e[32m*\e[0m] Configuring [\e[34m$3\e[0m]"
+ else
+ echo -e "[\e[31m*\e[0m] Configuring [\e[34m$3\e[0m]"
+ echo "###################################" >> issues.info
+ echo "Issue: $3 $(date)" >> issues.info
+ echo "Command: ${CHDIR}/$1 /etc/conf.d/$2" >> issues.info
+ echo "Items --->" >> issues.info
+ cat /etc/conf.d/"$2" >> issues.info
+ echo "###################################" >> issues.info
+ ask_for_shell "Failed configuring $3"
+ fi
fi
}
@@ -649,7 +689,7 @@ _kernel_build() {
env-update > /dev/null 2>&1 && source /etc/profile && export PS1="( 'Part H: Building the Kernel' ) $PS1"
export PATH=${PATH}:${CHDIR}
MKPS=$(grep MAKEOPTS "/etc/portage/make.conf" | sed '/^#/ d' | sed -e "s_\"__g" | awk -F '-j' '{print $2}' | sed '/^\s*$/d')
- if echo "$@" | grep -q 'cforce' || ! echo "$@" | grep -q '_flag_auto'; then
+ if echo "$@" | grep -q 'cforce' || echo "$@" | grep -q '_flag_auto'; then
echo -e "The \e[34mBuilding kernel\e[0m"
if genkernel --install kernel --kernel-config="${CHDIR}/kernel-conf" \
--makeopts="-j${MKPS}" --btrfs --postclear --e2fsprogs; then
diff --git a/scripts/chroot_scripts/chroot_init b/scripts/chroot_scripts/chroot_init
index 2f2af5a..4106ca6 100755
--- a/scripts/chroot_scripts/chroot_init
+++ b/scripts/chroot_scripts/chroot_init
@@ -46,7 +46,7 @@ else
die "Part: Update Failed"
fi
_do_hs '\+gupdate' "after" "Part: Portage Update"
-sleep 20
+
# PART PORTAGE, PROFILE AND FEATURES UPDATE
_do_hs '\-gportage' "before" "Part: Portage"
if _call_hook_points 'PORTAGE' 'gportage' 'Part: Portage' 'part_portage' "$@"; then
diff --git a/scripts/functions/catalyst_functions b/scripts/functions/catalyst_functions
index a78d90a..5aca06d 100755
--- a/scripts/functions/catalyst_functions
+++ b/scripts/functions/catalyst_functions
@@ -252,8 +252,8 @@ _stagex() {
cat "${CCONFDIR}/system/catalyst/stage$2.spec" | sed '/^#/ d' | sed '/^\s*$/d' \
> "${CATDIR}/.stage$2.spec"
- #catalyst -c "${CCONFDIR}/system/catalyst/catalyst.conf" -f "${CATDIR}/.stage$2.spec" \
- #&& pass || die "Failed"
+ catalyst -c "${CCONFDIR}/system/catalyst/catalyst.conf" -f "${CATDIR}/.stage$2.spec" \
+ && pass || die "Failed"
else
die "Could not locate stage$2-${ARCH}-${TARGETSTAMP}.tar.bz2"
fi
diff --git a/scripts/functions/sinit_functions b/scripts/functions/sinit_functions
index dd0f694..1b8bf36 100755
--- a/scripts/functions/sinit_functions
+++ b/scripts/functions/sinit_functions
@@ -14,58 +14,58 @@ _subshell() {
parameters_check() {
- if [[ -n $(echo "$@" | grep '\--force-new') ]] && [[ -n $(echo "$@" | grep '\--lawful-good') || -n $(echo "$@" | grep '\-lg') ]]; then
+ if echo "$@" | grep -q '\--force-new' && ( ( echo "$@" | grep -q '\--lawful-good' || echo "$@" | grep -q '\-lg' ) ); then
die "Warning: --force-new suppresses --lawful-good"
sleep 2
fi
- if [[ -n $(echo "$@" | grep '\--force-new') && -n $(echo "$@" | grep '\--enforce') ]]; then
+ if echo "$@" | grep -q '\--force-new' && echo "$@" | grep -q '\--enforce'; then
_e_report_back "Warning: --force-new implies --enforce=*"
sleep 2
fi
- if [[ -n "$(echo "$@" | grep '\--verbose')" || -n "$(echo "$@" | grep '\-v')" ]] && [[ -n "$(echo "$@" | grep '\--auto=yes')" ]]; then
+ if [[ "$(echo "$@" | grep -q '\--verbose')" || "$(echo "$@" | grep -q '\-v')" ]] && echo "$@" | grep -q '\--auto=yes'; then
die "Error: verbose & interactive mode (auto=yes) can not be set at the same time"
fi
- if [[ -n "$(echo "$@" | grep '\--quiet')" || -n "$(echo "$@" | grep '\-q')" ]] && [[ -n "$(echo "$@" | grep '\--verbose')" || -n "$(echo "$@" | grep '\-v')" ]]; then
+ if [[ "$(echo "$@" | grep -q '\--quiet')" || "$(echo "$@" | grep '\-q')" ]] && ((echo "$@" | grep -q '\--verbose' || echo "$@" | grep -q '\-v')); then
die "Error: verbose & quiet can not be set at the same time"
fi
- if [[ -n $(echo "$@" | grep '\--lawful-good') && -n $(echo "$@" | grep '\--enforce') ]]; then
+ if echo "$@" | grep -q '\--lawful-good' && echo "$@" | grep -q '\--enforce'; then
_e_report_back "Warning: --lawful-good suppresses --enforce"
fi
- if [[ -n $(echo "$@" | grep '\--force-new') && -n $(echo "$@" | grep '\--keep') ]]; then
+ if echo "$@" | grep -q '\--force-new' && echo "$@" | grep -q '\--keep'; then
die "Warning: --force-new suppresses --keep. This combination is know to give unexpected results."
fi
- if [[ -n $(echo "$@" | grep '\--health-check') && "$#" != 1 ]]; then
- die "Warning: --health-check unknown parameters ${@:2}"
+ if echo "$@" | grep -q '\--health-check' && [[ "$#" != 1 ]]; then
+ die "Warning: --health-check unknown parameters ${*:2}"
fi
- if [[ -n $(echo "$@" | grep '\--replace-new') && "$#" != 1 ]]; then
- die "Warning: --replace-new: unknown parameters ${@:2}"
+ if echo "$@" | grep -q '\--replace-new' && [[ "$#" != 1 ]]; then
+ die "Warning: --replace-new: unknown parameters ${*:2}"
fi
- if [[ -n $(echo "$@" | grep '\--build-minimal') && -n $(echo "$" | grep '\--enforce' | grep 'gkernel') ]]; then
+ if echo "$@" | grep -q '\--build-minimal' && echo "$" | grep -q '\--enforce' | grep -q 'gkernel'; then
_e_report_back "Warning: --build-minimal suppresses kernel build {gkernel}"
sleep 2
fi
- if [[ -n $(echo "$@" | grep '\--build-minimal') && -n $(echo "$@" | grep '\--enforce' | grep 'ginitrd') ]]; then
+ if echo "$@" | grep -q '\--build-minimal' && echo "$@" | grep -q '\--enforce' | grep -q 'ginitrd'; then
_e_report_back "Warning: --build-minimal suppresses initramfs {ginitrd}"
sleep 2
fi
- if [[ -n $(echo "$@" | grep '\--build-minimal') && -n $(echo "$@" | grep '\--enforce' | grep 'ginst') ]]; then
+ if echo "$@" | grep -q '\--build-minimal' && echo "$@" | grep -q '\--enforce' | grep -q 'ginst'; then
_e_report_back "Warning: --build-minimal suppresses custom package installation {ginst}"
sleep 2
fi
}
die() {
- echo -e "\e[31m$@\e[0m" 1>&2 ; exit 1
+ echo -e "\e[31m$*\e[0m" 1>&2 ; exit 1
}
burn() {
@@ -120,7 +120,7 @@ _o_report_back() {
}
inspector() {
- [[ -z "$@" ]] && print_inf_f
+ [[ -z "$*" ]] && print_inf_f
}
pass() {
@@ -183,32 +183,6 @@ _extracting_catalyst() {
|| return 1
}
-_clean_target() {
- inspector "$@"
- [[ -z "$(echo "$@" | grep 'workdir')" ]] && print_inf_f
-
- burn "$1/var/log"
- burn "$1/var/tmp"
- burn "$1/LAST_FAILED_COMMAND"
- burn "$1/LAST_ACTION"
- burn "$1/issues.info"
- burn "$1/root/.bash*"
- burn "$1/usr/src/linux*"
- burn "$1/sinit.d"
- # MINIMAL SYSTEM REQUEST
- if [[ -n "${_flag_minimal}" ]]; then
- burn "$1/usr/portage"
- burn "$1/var/cache"
- burn "$1/var/db"
- burn "$1/root/.cache"
- burn "$1/usr/local/portage"
- mv "$1/root/.ssh" "$1/"
- burn "$1/root"
- mkdir -p "$1/root"
- mv "$1/.ssh" "$1/root/.ssh"
- fi
-}
-
sinit_flow_monitor() {
# PROCESS FLOW TWEAKER DURING ALL BUT CHROOT STAGE. DO NOT EDIT THIS FILE!
case "$1" in
@@ -295,7 +269,7 @@ _pseudo_check_purge(){
&& break
done
- if [[ -n "$@" && -z "$(cat /proc/mounts | grep "workdir-$2")" ]]; then
+ if [[ -n "$*" && -z "$(cat /proc/mounts | grep "workdir-$2")" ]]; then
if [[ -e "$1" ]]; then
echo -e "\e[34mMarking workdir for purge\e[0m"
burn "$1"
@@ -334,7 +308,7 @@ _start_again() {
}
_extract_tarball() {
- [[ -z "$@" && -d "$2" ]] && die "Wrong Parameters"
+ [[ -z "$*" && -d "$2" ]] && die "Wrong Parameters"
mkdir -p "$2"
echo -e "\e[34mExtracting tarball\e[0m"
@@ -355,7 +329,7 @@ _extract_tarball() {
}
_workdir_check() {
- [[ -z "$@" && -d "$2" ]] && die "Wrong Parameters"
+ [[ -z "$*" && -d "$2" ]] && die "Wrong Parameters"
if echo "$@" | grep -q 'force'; then
_e_report_back "This may take some time"
_e_report_back "Checking..."
@@ -405,18 +379,25 @@ _am_i_root() {
}
_export_latest() {
- export GENTOOKEY="$(lynx -dump ${SIGNING_KEY} | grep "(4096-bit RSA)" | head -1 | awk -F '(' '{ print $1}')"
- export "GENTOOKEY"
- export GENTOOLATEST="$DIST/$(wget -q -O- "${DIST}/latest-stage3-$ARCH.txt" | tail -n 1 | awk -F ' ' '{ print $1 }')"
- export STAGE3TB=$(wget -q -O- "${DIST}/latest-stage3-$ARCH.txt" | tail -n 1 | awk -F ' ' '{ print $1 }' | awk -F '/' '{ print $2 }')
- export GENTOOLATESTASC="$DIST/$(wget -q -O- "${DIST}/latest-stage3-$ARCH.txt" | tail -n 1 | awk -F ' ' '{ print $1 }').DIGESTS.asc"
+ GENTOOKEY="$(lynx -dump ${SIGNING_KEY} | grep "(4096-bit RSA)" | head -1 | awk -F '(' '{ print $1}')"
+ export GENTOOKEY
+ GENTOOLATEST="$DIST/$(wget -q -O- "${DIST}/latest-stage3-$ARCH.txt" | tail -n 1 | awk -F ' ' '{ print $1 }')"
+ export GENTOOLATEST
+ STAGE3TB=$(wget -q -O- "${DIST}/latest-stage3-$ARCH.txt" | tail -n 1 | awk -F ' ' '{ print $1 }' | awk -F '/' '{ print $2 }')
+ export STAGE3TB
+ GENTOOLATESTASC="$DIST/$(wget -q -O- "${DIST}/latest-stage3-$ARCH.txt" | tail -n 1 | awk -F ' ' '{ print $1 }').DIGESTS.asc"
+ export GENTOOLATESTASC
}
_gentoo_key() {
[[ -z "${GENTOOKEY}" ]] && die "Wrong Parameters" && return 1
- eval gpg --keyserver hkps.pool.sks-keyservers.net --recv-keys "${_flag_silence}" ${GENTOOKEY} \
- && echo -e "[\e[32m*\e[0m]\e[32m Fetching Key\e[0m" \
- || { echo -e "[\e[31m*\e[0m]\e[31m Fetching Key\e[0m"; return 1; }
+
+ if eval gpg --keyserver hkps.pool.sks-keyservers.net --recv-keys "${GENTOOKEY}" "${_flag_silence}"; then
+ echo -e "[\e[32m*\e[0m]\e[32m Fetching Key\e[0m"
+ else
+ echo -e "[\e[31m*\e[0m]\e[31m Fetching Key\e[0m"
+ return 1
+ fi
}
_get_latest() {
@@ -431,28 +412,44 @@ _get_latest() {
echo -e "[\e[34m*\e[0m] Marking stage3-${ARCH}-latest.tar.bz2.DIGESTS for purging"
burn "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2.DIGESTS"
echo -e "[\e[32m*\e[0m] Fetching \e[34m${STAGE3TB}\e[0m"
- eval wget -c -O "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2" "${GENTOOLATEST}" "${_flag_silence}" \
- && echo "${STAGE3TB}" > "${CDISTDIR}/dists/latest.info" \
- && pass || die "FAILED"
+ if eval wget -c -O "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2" "${GENTOOLATEST}" "${_flag_silence}"; then
+ echo "${STAGE3TB}" > "${CDISTDIR}/dists/latest.info"
+ pass
+ else
+ die "FAILED"
+ fi
else
echo -e "[\e[32m*\e[0m] Fetching \e[34m${STAGE3TB}\e[0m"
- wget -c -O "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2" "${GENTOOLATEST}" \
- && echo "${STAGE3TB}" > "${CDISTDIR}/dists/latest.info" \
- && pass || die "FAILED"
+ if wget -c -O "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2" "${GENTOOLATEST}"; then
+ echo "${STAGE3TB}" > "${CDISTDIR}/dists/latest.info"
+ pass
+ else
+ die "FAILED"
+ fi
+ fi
+
+ if eval wget -c -O "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2.DIGESTS.asc" "${GENTOOLATESTASC}" "${_flag_silence}"; then
+ echo -e "[\e[32m*\e[0m] Fetching \e[34m${GENTOOLATEST}\e[0m"
+ else
+ echo -e "[\e[31m*\e[0m] \e[31mFAILD\e[0m: Fetching \e[34m${GENTOOLATEST}\e[0m"
+ die
fi
- eval wget -c -O "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2.DIGESTS.asc" "${GENTOOLATESTASC}" "${_flag_silence}" \
- && echo -e "[\e[32m*\e[0m] Fetching \e[34m${GENTOOLATEST}\e[0m" \
- || { echo -e "[\e[31m*\e[0m] \e[31mFAILD\e[0m: Fetching \e[34m${GENTOOLATEST}\e[0m"; exit 1; }
- eval wget -c -O "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2.DIGESTS" "${GENTOOLATEST}.DIGESTS" "${_flag_silence}" \
- && echo -e "[\e[32m*\e[0m] Fetching \e[34m${GENTOOLATEST}.DIGESTS\e[0m" \
- || { echo -e "[\e[31m*\e[0m] \e[31mFAILD\e[0m: Fetching $\e[34m${GENTOOLATEST}.DIGESTS\e[0m"; exit 1; }
+ if eval wget -c -O "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2.DIGESTS" "${GENTOOLATEST}.DIGESTS" "${_flag_silence}"; then
+ echo -e "[\e[32m*\e[0m] Fetching \e[34m${GENTOOLATEST}.DIGESTS\e[0m"
+ else
+ echo -e "[\e[31m*\e[0m] \e[31mFAILD\e[0m: Fetching $\e[34m${GENTOOLATEST}.DIGESTS\e[0m"
+ die
+ fi
}
_verify_download() {
- eval gpg --verify "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2.DIGESTS.asc" "${_flag_silence}" \
- && echo -e "[\e[32m*\e[0m] Verifying \e[35mcryptographic signature\e[0m" \
- || { echo -e "[\e[31m*\e[0m] \e[31mFAILD\e[0m: Verifying \e[31mcryptographic signature\e[0m"; exit 1; }
+ if eval gpg --verify "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2.DIGESTS.asc" "${_flag_silence}"; then
+ echo -e "[\e[32m*\e[0m] Verifying \e[35mcryptographic signature\e[0m"
+ else
+ echo -e "[\e[31m*\e[0m] \e[31mFAILD\e[0m: Verifying \e[31mcryptographic signature\e[0m"
+ die
+ fi
[[ $(grep -A 1 -i sha512 "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2.DIGESTS.asc" | head -n 2 | grep stage3 | awk -F ' ' '{ print $1 }') \
== $(sha512sum "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2" | awk -F ' ' '{ print $1 }') ]] \
@@ -486,7 +483,7 @@ _call_force_new() {
_fetch_new() {
# CHECK FOR THE POSITIONAL PARAMETERS AND BAILOUT IF THEY ARE MISSING
- [[ -z "$@" ]] && die "Wrong parameters"
+ [[ -z "$*" ]] && die "Wrong parameters"
echo -e "\e[33mSearching for tarball...\e[0m"
if [[ -n "${_flag_fetch}" ]] || echo "$@" | grep -q 'force'; then
_export_latest
@@ -534,18 +531,29 @@ _unmount() {
# MOUNT DEV & SYS WITH RBIND THEN RSLAVE ON TARGET BUILDDIR
_mount_dev_sys() {
inspector "$@"
- mount --rbind /dev "$1/$2" \
- && mount --make-rslave "$1/$2" \
- && echo -e "[\e[32m*\e[0m] Mounting $2" \
- || { echo -e "[\e[31*\e[0m] Mounting $2"; die "Failed"; }
+
+ if mount --rbind "/$2" "$1/$2"; then
+ if mount --make-rslave "$1/$2"; then
+ echo -e "[\e[32m*\e[0m] Mounting $2"
+ else
+ echo -e "[\e[31*\e[0m] Mounting $2"
+ die "Failed"
+ fi
+ else
+ die "Failed mounting $2"
+ fi
}
# MOUNT PROC ON TARGET BUILDDIR
_mount_proc() {
inspector "$@"
- mount -t proc /proc "$1/proc" \
- && echo -e "[\e[32m*\e[0m] Mounting proc" \
- || { echo -e "[\e[31m*\e[0m] Mounting proc"; die "Failed"; }
+
+ if mount -t proc /proc "$1/proc"; then
+ echo -e "[\e[32m*\e[0m] Mounting proc"
+ else
+ echo -e "[\e[31m*\e[0m] Mounting proc"
+ die "Failed"
+ fi
}
# THIS SCRIPT IS SOURCED AT THE BEGINING FOR CHECKING THE BUILDER'S RUNTIME DEPENDENCIES
@@ -562,13 +570,17 @@ _lcreq() {
# GENTOO SECTION
case "$1" in
1)
- [[ $(command -v eix) ]] \
- || { echo -e "[\e[33m*\e[0m] \e[35mPlease install eix to proceed!\e[0m" \
- && { _am_i_root_sub "$UID" && echo -e "[\e[32m*\e[0m] Root privileges found" \
- && emerge -aq eix && echo -e "[\e[33m*\e[0m] \e[35mUpdating database\e[0m" \
- && eval eix-sync -a "${_flag_silence}"; } \
- || { echo -e "[\e[31m*\e[0m] Could not get root privileges" \
- && echo "Please resolve this issue and start again" && exit 1; }; }
+ if ! [[ $(command -v eix) ]]; then
+ echo -e "[\e[33m*\e[0m] \e[35mPlease install eix to proceed!\e[0m"
+ if _am_i_root_sub "$UID"; then
+ echo -e "[\e[32m*\e[0m] Root privileges found"
+ emerge -aq eix && echo -e "[\e[33m*\e[0m] \e[35mUpdating database\e[0m"
+ eval eix-sync -a "${_flag_silence}"
+ else
+ echo -e "[\e[31m*\e[0m] Could not get root privileges"
+ die "Please resolve this issue and start again"
+ fi
+ fi
mapfile -t lreq < <(cat "${CLOCALLG}/loc_req" | sed '/^#/ d' | sed '/^\s*$/d')
@@ -579,10 +591,12 @@ _lcreq() {
else
echo -e "[\e[31m*\e[0m] Searching for $i"
echo -e "[\e[33m*\e[0m] Attempting to resolve the missing dependency"
- _am_i_root $UID && echo -e "[\e[32m*\e[0m] Root privileges found" \
- && emerge -aq "$i" \
- || { echo -e "[\e[31m*\e[0m] Could not get root privileges" \
- && echo "Please resolve this issue and start again" && exit 1; }
+ if _am_i_root $UID && echo -e "[\e[32m*\e[0m] Root privileges found"; then
+ emerge -aq "$i"
+ else
+ echo -e "[\e[31m*\e[0m] Could not get root privileges"
+ die"Please resolve this issue and start again"
+ fi
fi
done;;
2)
@@ -719,7 +733,7 @@ librarium() {
_flag_time_warp=''
_flag_time_state=''
while true; do
- [[ -z "$@" ]] && return 0
+ [[ -z "$*" ]] && return 0
case "$1" in
--fetch-new|-fn )
_e_report_back "Fetch new is enabled"
@@ -874,8 +888,12 @@ librarium() {
fi
echo -e "\e[35mTime warp enabled for $(ls "${CLOCALLG}/states" | grep "^${1#*=}_")\e[0m"
- _flag_time_warp="${CLOCALLG}/states/$(ls "${CLOCALLG}/states" | grep "^${1#*=}_")"
- export _flag_time_warp
+ if ls "${CLOCALLG}/states" | grep "^${1#*=}_"; then
+ _flag_time_warp="${CLOCALLG}/states/$(ls "${CLOCALLG}/states" | grep "^${1#*=}_")"
+ export _flag_time_warp
+ else
+ die "No such a mark: ${1#*=}"
+ fi
;;
--time-state* )
@@ -884,7 +902,6 @@ librarium() {
fi
if [[ "$(echo "${1#*=}")" == '-' ]]; then
- [[ -z "${CLOCALLG}/states" ]] && die
rm -rf "${CLOCALLG}/states/$(ls "${CLOCALLG}/states" | grep "^${1#*=}_")"
elif [[ "$(echo "${1#*--time-state}")" == '?' ]]; then
_o_report_back "Time States"
@@ -1150,17 +1167,6 @@ inquisitor() {
# MAKE CHECKS AS DESCRIBED IN WITCH HUNT
witch_hunt "$@"
- if [[ "$(echo "${_flag_verbose}")" == 0 ]]; then
- _silence=1
- export _silence
- elif [[ "$(echo "${_flag_quiet}")" == 0 ]]; then
- _silence=0
- export _silence
- else
- _silence=9
- export _silence
- fi
-
# PERFORM RUNTIME DEPENDENCIES CHECK. ISSUE WARNING FOR ALL BUT GENTOO
if [[ "$(awk -F '=' '/RDEP/{ print $2 }' <"${CLOCALLG}/sinprog")" == 0 ]]; then
_dependencies_check && sinit_flow_monitor "RDEP"
@@ -1169,11 +1175,24 @@ inquisitor() {
}
_auto_def_silence_def() {
+ # AUTOMODE
if ! echo "$@" | grep -q '\--auto=yes'; then
_flag_auto=1
export _flag_auto
fi
+ # CONFIGURE SILENCE MODE
+ if [[ "$(echo "${_flag_verbose}")" == 0 ]]; then
+ _silence=1
+ export _silence
+ elif [[ "$(echo "${_flag_quiet}")" == 0 ]]; then
+ _silence=0
+ export _silence
+ else
+ _silence=9
+ export _silence
+ fi
+
if [[ "${_silence}" == 0 ]]; then
_flag_silence='>/dev/null 2>&1'
_flag_chroot_silence=0
@@ -1203,11 +1222,14 @@ _time_state() {
fi
((++k))
done
+
echo "state_name:${state_name}" > "${CLOCALLG}/states/${k}_${state_name}/main_flags"
echo "_flag_base:${_flag_base}" >> "${CLOCALLG}/states/${k}_${state_name}/main_flags"
+
for i in "${_flags_listA[@]}"; do
echo "$i:${!i}" >> "${CLOCALLG}/states/${k}_${state_name}/main_flags"
done
+
if [[ -e "${CLOCALLG}/states/${k}_${state_name}/${state_name}_enforce" ]]; then
rm -f "${CLOCALLG}/states/${k}_${state_name}/${state_name}_enforce"
fi
@@ -1216,27 +1238,32 @@ _time_state() {
rm -f "${CLOCALLG}/states/${k}_${state_name}/${state_name}_lawful"
fi
- for i in "${_enforce_args[@]}"; do
- echo "$i" >> "${CLOCALLG}/states/${k}_${state_name}/${state_name}_enforce"
- done
+ if [[ -n "$(echo "${_enforce_args[@]}")" ]]; then
+ for i in "${_enforce_args[@]}"; do
+ echo "$i" >> "${CLOCALLG}/states/${k}_${state_name}/${state_name}_enforce"
+ done
+ fi
- for i in "${_lawful_args[@]}"; do
- echo "$i" >> "${CLOCALLG}/states/${k}_${state_name}/${state_name}_lawful"
- done
+ if [[ -n "$(echo "${_lawful_args[@]}")" ]]; then
+ for i in "${_lawful_args[@]}"; do
+ echo "$i" >> "${CLOCALLG}/states/${k}_${state_name}/${state_name}_lawful"
+ done
+ fi
if [[ -n "${_flag_sdir}" ]]; then
rm -f "${CLOCALLG}/states/${k}_${state_name}/doscripts"
- if [[ "${CLOCALLG}/doscripts" ]]; then
+ if [[ "$(ls "${CLOCALLG}/doscripts")" ]]; then
cp "${CLOCALLG}/doscripts" "${CLOCALLG}/states/${k}_${state_name}"
fi
fi
+
cp -r "${CCONFDIR}" "${CLOCALLG}/states/${k}_${state_name}"
+
+ _e_report_back "==========================================================================================="
+ _e_report_back "State has been saved. To refer at this state in the future, use --time-warp=[state's mark]"
+ _e_report_back "==========================================================================================="
+ exit 0
fi
-
- _e_report_back "==========================================================================================="
- _e_report_back "State has been saved. To refer at this state in the future, use --time-warp=[state's mark]"
- _e_report_back "==========================================================================================="
- exit 0
}
# TIME WARP
@@ -1245,7 +1272,7 @@ _warping_time() {
# EXPORT STORED CONFIG.D LOCATION
CCONFDIR="${_flag_time_warp}/config.d"
export CCONFDIR
- ls "${_flag_time_warp}/doscripts"
+
if [[ -e "${_flag_time_warp}/doscripts" ]]; then
_flag_sdir=0
cp "${_flag_time_warp}/doscripts" "${CLOCALLG}/doscripts"
@@ -1261,27 +1288,32 @@ _warping_time() {
done < <(cat "${_flag_time_warp}/main_flags" | grep '_')
for i in "${_flags_listA[@]}"; do
- if [[ "$(echo ${!i})" == 0 ]]; then
- _flags_stagea+=("${i}")
- fi
+ if [[ "$(echo ${!i})" == 0 ]]; then
+ _flags_stagea+=("${i}")
+ fi
done
# EXPORT ENFORCE SAVED ARGS
- _enforce_args=()
- while read -r s; do
- _enforce_args+=("${s}")
- done < <(cat "${_flag_time_warp}/${state_name}_enforce")
+ if [[ -e "${_flag_time_warp}/${state_name}_enforce" ]]; then
+ _enforce_args=()
+ while read -r s; do
+ _enforce_args+=("${s}")
+ done < <(cat "${_flag_time_warp}/${state_name}_enforce")
+
+ export _enforce_args
+ fi
# EXPORT LAWFUL SAVED ARGS
- _lawful_args=()
- while read -r s; do
- _lawful_args+=("${s}")
- done < <(cat "${_flag_time_warp}/${state_name}_lawful")
-
- export _enforce_args
- export _lawful_args
+ if [[ -e "${_flag_time_warp}/${state_name}_lawful" ]]; then
+ _lawful_args=()
+ while read -r s; do
+ _lawful_args+=("${s}")
+ done < <(cat "${_flag_time_warp}/${state_name}_lawful")
+
+ export _lawful_args
+ fi
- _auto_def_silence_def "$@"
+ _auto_def_silence_def "$@" "${_flags_stagea[@]}"
_flags_stagea+=("${_flag_base}")
echo "base:$_flag_base"
@@ -1289,7 +1321,11 @@ _warping_time() {
echo "sdir:$_flag_sdir"
echo "sdir_path:$_flag_sdir_path"
+ # MAKE CHECKS AS DESCRIBED IN WITCH HUNT
+ witch_hunt "$@"
+
source "${CWORKDIR}/scripts/sinit" "${_flags_stagea[@]}"
+ exit 0
fi
}
@@ -1297,7 +1333,7 @@ warp() {
# DIE IF PP ARE NULL
inspector "$@"
- # FILTER AND EXPORT ALL FLAGS AND ARGUMENTS. DIE UNLESS CONDITIONS ARE EXACT
+ # FILTER AND EXPORT ALL FLAGS AND ARGUMENTS. DIE UNLESS CONDITIONS ARE TRUE
librarium "$@"
# STAGE A & B
@@ -1384,6 +1420,68 @@ warp() {
# STAGE C
}
+_clean_target() {
+ inspector "$@"
+ [[ -z "$(echo "$@" | grep 'workdir')" ]] && print_inf_f
+
+ rm -f "$1/LAST_FAILED_COMMAND"
+ rm -f "$1/LAST_ACTION"
+ rm -f "$1/issues.info"
+ rm -f "$1/root/.bash*"
+}
+
+_archive_() {
+ _o_report_back "Preparing to archive the system"
+ _e_report_back "Unbinding..."
+
+ _unmount "${_flag_base}"
+
+ TARGETSTAMP="$(grep 'version_stamp' "${CCONFDIR}/system/catalyst/stage3.spec" \
+ | sed '/^#/ d' | awk -F ' ' '{ print $2 }' | sed -e "s_\"__g")"
+
+ SUBBUILD=0
+ GVEX="${GSEVER}.${SUBBUILD}"
+ EXCLUDE="--exclude=root/* \
+ --exclude=dev/* \
+ --exclude=proc/* \
+ --exclude=run/* \
+ --exclude=sys/* \
+ --exclude=tmp/* \
+ --exclude=usr/portage/* \
+ --exclude=usr/src/* \
+ --exclude=usr/tmp/* \
+ --exclude=var/lock/* \
+ --exclude=var/cache/* \
+ --exclude=var/tmp/* \
+ --exclude=var/db/* \
+ --exclude=var/empty/* \
+ --exclude=var/spool/*
+ --exclude=var/log/* \
+ --exclude=var/run/* \
+ --exclude=sinit.d" \
+
+ _e_report_back "Generating name..."
+ while true; do
+ if ! ls "${CDISTDIR}/stage3-amd64-${GVEX}.tar.bz2" >/dev/null 2>&1; then
+ (cd "$1"
+ _o_report_back "Creating the stage4 tarball"
+ if [[ "${_flag_base}" == 'catalyst' ]]; then
+ eval tar -cjpP --ignore-failed-read "${EXCLUDE}" -f "${CDISTDIR}/stage3-amd64-${TARGETSTAMP}-${GVEX}.tar.bz2" . "${_flag_silence}"
+ elif [[ "${_flag_base}" == 'precomp' ]]; then
+ eval tar -cjpP --ignore-failed-read "${EXCLUDE}" -f "${CDISTDIR}/stage3-amd64-prc-${GVEX}.tar.bz2" . "${_flag_silence}"
+ fi
+ ) \
+ && { _o_report_back "Archived" && echo -e "\e[34mYou can find your system @ ${CDISTDIR}\e[0m"
+ echo -e "\e[34mWith version extension: ${GVEX}\e[0m"; } \
+ || die "Failed"
+ break
+ else
+ GVEX="${GSEVER}.${SUBBUILD}"
+ ((++SUBBUILD))
+ fi
+ done
+}
+
_do_rs() {
while read -r s;do
source "${_flag_sdir_path}/$s"
diff --git a/scripts/sinit b/scripts/sinit
index aec763d..869f2ec 100755
--- a/scripts/sinit
+++ b/scripts/sinit
@@ -180,33 +180,13 @@ else
fi
_do_hs '\+gpartb' "after" "Part: B"
-exit
-umount -l "${BWORKDIR}/"*
-umount -l "${BWORKDIR}/"*
-umount -l "${BWORKDIR}/"*
-umount -l "${BWORKDIR}/"*
-umount -l "${BWORKDIR}/"*
-
-TARGETSTAMP="$(grep 'version_stamp' "${CCONFDIR}/system/catalyst/stage3.spec" \
-| sed '/^#/ d' | awk -F ' ' '{ print $2 }' | sed -e "s_\"__g")"
-
-SUBBUILD=0
-GVEX="${GSEVER}.${SUBBUILD}"
-while true; do
- if ! ls "${CDISTDIR}/stage3-amd64-${GVEX}.tar.bz2" >/dev/null 2>&1; then
- (cd "${BWORKDIR}"
- tar -cjpP --ignore-failed-read "${CDISTDIR}/stage3-amd64-${TARGETSTAMP}-${GVEX}.tar.bz2" . >/dev/null 2>&1; ) \
- && { _o_report_back "Archived" && echo -e "\e[34mYou can find your system @ ${CDISTDIR}\e[0m"
- echo -e "\e[34mWith version extension: ${GVEX}\e[0m"; } \
- || die "Failed"
- break
- else
- GVEX="${GSEVER}.${SUBBUILD}"
- ((++SUBBUILD))
- fi
-done
+if echo "${_flag_base}" | grep -q 'catalyst'; then
+ _archive_ "${BWORKDIR}" "catalyst"
+elif echo "${_flag_base}" | grep -q 'precomp'; then
+ _archive_ "${BWORKDIR}" "precomp"
+fi
-exit
+exit 1
gpg --armor --export email > "${FINALDIST}/key.asc" # THIS WILL BE ADDED TO THE HOSTS
gpg --detach-sign -o "${GSE_VER}".gpg "${FINALDIST}/${IMAGE}"