Skip to content

Commit

Permalink
Fix check_gcc_config_and_reset_if_necessary fn
Browse files Browse the repository at this point in the history
Previously tried to run gcc to get version number, which fails
when the gcc config is invalid...
  • Loading branch information
sakaki- committed Nov 11, 2015
1 parent f6aec42 commit f194cda
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
26 changes: 23 additions & 3 deletions buildkernel
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ shopt -s nullglob
# ********************** variables *********************
PROGNAME="$(basename "${0}")"
CONFFILE="/etc/${PROGNAME}.conf"
VERSION="1.0.12"
VERSION="1.0.13"
ETCPROFILE="/etc/profile"
DEFAULTEFIBOOTFILE="bootx64.efi"
EFIBOOTFILE="${DEFAULTEFIBOOTFILE}"
Expand Down Expand Up @@ -116,6 +116,7 @@ USE_PLYMOUTH=true
VERBOSITYFLAG=""
ASKFLAG=""
ALERTFLAG=""
PORTAGEINFO=""
# following array variables set by find_all_gpg_keyfile_partitions function
declare -a GPGUUIDS GPGPARTNAMES GPGDEVNAMES GPGPARTNUMS
# following array variables set by find_all_luks_partitions function
Expand Down Expand Up @@ -249,14 +250,33 @@ check_file_exists() {
die "File '${1}' does not exist"
fi
}
read_portage_info_if_necessary() {
if [ -z "${PORTAGEINFO}" ]; then
show "Checking Portage configuration, please wait..."
PORTAGEINFO="$(emerge --info)"
fi
}
check_gcc_config_and_reset_if_necessary() {
# check if gcc-config exists with an error - if it does, then
# attempt to set one based on the current gcc version number
if ! gcc-config --get-current-profile >/dev/null 2>&1; then
# unset or invalid, attempt to force this to the current gcc
# version
local GCC_VERSION="$(gcc --version | head -n 1 | sed 's/^.* //')"
if gcc-config "${GCC_VERSION}"; then
read_portage_info_if_necessary
local CHOST="$(grep '^CHOST=.*' <<<"${PORTAGEINFO}")"
CHOST="$(cut -d\" -f2 <<< ${CHOST})"
local GCC_VERSION=""
# can't be sure we have eix installed
if eix --version >/dev/null 2>&1; then
# we do, so can cleanly check latest installed gcc version
GCC_VERSION="$(eix --installed --exact sys-devel/gcc --format '<installedversions:NAMEVERSION>' --versionsort | tail -n 1)"
GCC_VERSION="${GCC_VERSION##*gcc-}"
else
# we don't, have to hack the most recent gcc version
GCC_VERSION="$(ls -1v "/usr/${CHOST}/gcc-bin" | tail -n 1)"
fi
local FULL_GCC_ID="${CHOST}-${GCC_VERSION}"
if gcc-config "${FULL_GCC_ID}"; then
warning "gcc configuration was reset"
if [ -s "${ETCPROFILE}" ]; then
set +e
Expand Down
2 changes: 1 addition & 1 deletion buildkernel.8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH BUILDKERNEL 8 "Version 1.0.12: August 2015"
.TH BUILDKERNEL 8 "Version 1.0.13: November 2015"
.SH NAME
buildkernel \- build secure boot kernel, save to EFI system partition
.SH SYNOPSIS
Expand Down
2 changes: 1 addition & 1 deletion buildkernel.conf.5
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH BUILDKERNEL 5 "Version 1.0.12: August 2015"
.TH BUILDKERNEL 5 "Version 1.0.13: November 2015"
.SH NAME
buildkernel.conf \- a configuration file for \fBbuildkernel\fR(8)
.SH SYNOPSIS
Expand Down

0 comments on commit f194cda

Please sign in to comment.