Skip to content

Commit

Permalink
Make buildkernel optional, support pump/distcc
Browse files Browse the repository at this point in the history
Can deselect buildkernel dependency now by turning off buildkernel
USE flag in ebuild. This allows genup to be used in e.g. embedded
contexts, which previously required genup-lite.
  • Loading branch information
sakaki- committed Aug 28, 2015
1 parent a523d5f commit 4e7f82a
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 23 deletions.
82 changes: 65 additions & 17 deletions genup
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Will offer to update the kernel, if a new version has become available.
# Intended to be run interactively.
#
# Copyright (c) 2014 sakaki <[email protected]>
# Copyright (c) 2014-2015 sakaki <[email protected]>
#
# License (GPL v3.0)
# ------------------
Expand All @@ -28,7 +28,7 @@ set -u

# ********************** variables *********************
PROGNAME="$(basename "${0}")"
VERSION="1.0.8"
VERSION="1.0.9"
ETCPROFILE="/etc/profile"
RED_TEXT="" GREEN_TEXT="" YELLOW_TEXT="" RESET_ATTS="" ALERT_TEXT=""
if [[ -v TERM && -n "${TERM}" && "${TERM}" != "dumb" ]]; then
Expand All @@ -42,12 +42,18 @@ declare -i VERBOSITY=1
PREFIXSTRING="* "
SHOWPREFIX="${GREEN_TEXT}${PREFIXSTRING}${RESET_ATTS}"
SHOWSUFFIX=""
# following variable is conformed on installation by ebuild
# (to reflect setting of "buildkernel" USE flag)
USE_BUILDKERNEL=true
VERBOSITYFLAG=""
ASKFLAG=""
ALERTFLAG=""
EMERGEARGS=""
BUILDKERNELARGS=""
EIXSYNCARGS=""
PUMP=""
NOPUMP="-distcc -distcc-pump"
PORTAGEFEATURES=""
# following should already be in the environment; but to be safe...
export NUMCPUS=$(grep -E 'processor\s+:' /proc/cpuinfo | wc -l)
export NUMCPUSPLUSONE=$(( NUMCPUS + 1 ))
Expand Down Expand Up @@ -178,9 +184,7 @@ update_all_packages_in_world_set_and_dependencies() {
show "Updating @world set (for new versions, or changed use flags)..."
if ((ARG_ASK==0 && ARG_IGNORE_REQUIRED_CHANGES==0)); then
# if in non-interactive mode, we'll check first if the build
# looks possible (as emerge does not return an error code if
# a user modification to package.use etc. is required to proceed)
# you can set the --ignore-required-changes option to
# looks possible; you can set the --ignore-required-changes option to
# suppress this test
if grep -qi "The following \(keyword\|mask\|USE\|license\) changes are necessary to proceed" \
<(emerge ${VERBOSITYFLAG} ${EMERGEARGS} --pretend --deep \
Expand All @@ -189,13 +193,13 @@ update_all_packages_in_world_set_and_dependencies() {
USER_CHANGES_REQUIRED=1
fi
fi
if ! emerge ${ASKFLAG} ${ALERTFLAG} ${VERBOSITYFLAG} ${EMERGEARGS} --deep \
if ! ${PUMP} emerge ${ASKFLAG} ${ALERTFLAG} ${VERBOSITYFLAG} ${EMERGEARGS} --deep \
--with-bdeps=y --newuse --update --backtrack=50 @world; then
# per make manpage, if multiple "j" opts are specified, the last
# one takes precedence, so this is legitimate
if MAKEOPTS="${MAKEOPTS-} -j1" emerge --resume; then
if MAKEOPTS="${MAKEOPTS-} -j1" FEATURES="${NOPUMP}" emerge --resume; then
warning "emerge completed successfully, but only by restricting"
warning "build parallelism"
warning "build parallelism and distcc"
else
# we still have a problem, allow the user to attempt to fix if
# running interactively
Expand All @@ -221,10 +225,10 @@ update_all_packages_in_world_set_and_dependencies() {
}
rebuild_external_modules_if_necessary() {
show "Creating any necessary external modules (e.g., VirtualBox)..."
if ! emerge ${VERBOSITYFLAG} @module-rebuild; then
if MAKEOPTS="${MAKEOPTS-} -j1" emerge --resume; then
if ! ${PUMP} emerge ${VERBOSITYFLAG} @module-rebuild; then
if MAKEOPTS="${MAKEOPTS-} -j1" FEATURES="${NOPUMP}" emerge --resume; then
warning "emerge @module-rebuild completed successfully, but only by restricting"
warning "build parallelism"
warning "build parallelism and distcc"
else
warning "Failed to complete emerge @module-rebuild due to error"
warning "Continuing..."
Expand All @@ -239,10 +243,10 @@ rebuild_packages_depending_on_stale_libraries() {
# the below emerge will rebuild any such consumers, so that the old
# library may be freed
show "Rebuilding any consumers of old shared libraries, which did not autoupdate..."
if ! emerge ${VERBOSITYFLAG} @preserved-rebuild; then
if MAKEOPTS="${MAKEOPTS-} -j1" emerge --resume; then
if ! ${PUMP} emerge ${VERBOSITYFLAG} @preserved-rebuild; then
if MAKEOPTS="${MAKEOPTS-} -j1" FEATURES="${NOPUMP}" emerge --resume; then
warning "emerge @preserved-rebuild completed successfully, but only by restricting"
warning "build parallelism"
warning "build parallelism and distcc"
else
die "Failed to complete emerge @preserved-rebuild due to error"
fi
Expand Down Expand Up @@ -420,11 +424,13 @@ Options:
(selecting this also automatically selects --ask)
-b, --buildkernel-args=ARGS
pass provided additional ARGS to the initial
(staging) buildkernel invocation
(staging) buildkernel invocation (requires buildkernel
USE flag to have been set)
-c, --dispatch-conf run dispatch-conf, even if in non-interactive mode
-d, --deploy-from-staging
if an updated kernel is successfully built in staging,
afterwards try to copy it onto the EFI system partition
(requires buildkernel USE flag to have been set)
-e, --emerge-args=ARGS
pass provided additional ARGS to the main emerge
e.g., use --emerge-args='--autounmask-write' to
Expand All @@ -438,7 +444,8 @@ Options:
don't purge source tarballs (distfiles) for uninstalled
versions of packages (or uninstalled packages)
-n, --no-kernel-upgrade
do not attempt to run buildkernel
do not attempt to run buildkernel (implied if
buildkernel USE flag has not been set)
-p, --no-perl-cleaner do not attempt to run perl-cleaner
-P, --no-python-updater
do not attept to run python-updater
Expand All @@ -456,17 +463,52 @@ print_version() {
printf "%s\n" "${VERSION}"
}
display_usage_message_and_bail_out() {
if [ ! -z "${1+x}" ]; then
printf "%s: %s\n" "${PROGNAME}" "${1}" >&2
fi
print_usage >&2
cleanup_and_exit_with_code 1
}
internal_consistency_option_checks() {
# following not exhaustive, just some more obvious snafus
local KERNMSG="--no-kernel-upgrade"
if ! "${USE_BUILDKERNEL}"; then
KERNMSG="buildkernel USE flag unset"
fi
if ((ARG_NO_KERNEL_UPGRADE==1)) || ! "${USE_BUILDKERNEL}"; then
if [[ -n "${BUILDKERNELARGS}" ]]; then
display_usage_message_and_bail_out "cannot specify --buildkernel-args with ${KERNMSG}"
fi
if ((ARG_DEPLOYFROMSTAGING==1)); then
display_usage_message_and_bail_out "cannot specify --deploy-from-staging with ${KERNMSG}"
fi
fi
}
read_portage_features_if_necessary() {
if [ -z "${PORTAGEFEATURES}" ]; then
show "Checking Portage configuration, please wait..."
PORTAGEFEATURES=$(grep '^FEATURES.*$' <(emerge --info))
fi
}
check_if_using_webrsync_gpg() {
# we have to amend the args to eix if using webrsync-gpg feature
if grep -qi "^FEATURES.*webrsync-gpg.*$" <(emerge --info); then
read_portage_features_if_necessary
if grep -qi "webrsync-gpg" <<<"${PORTAGEFEATURES}"; then
# force use of emerge-webrsync instead of emerge --sync
show "Portage feature webrsync-gpg detected: using -w option with eix-sync"
EIXSYNCARGS="-w"
fi
}
check_if_using_distcc() {
# check for the relevant feature... turn on PUMP prefix if
# we find it
read_portage_features_if_necessary
if grep -qi "distcc-pump" <<<"${PORTAGEFEATURES}"; then
# set prefix for emerge in normal situation...
show "Portage feature distcc-pump detected: will pump emerge"
PUMP="pump"
fi
}
process_command_line_options() {
local TEMP
declare -i RC
Expand Down Expand Up @@ -533,12 +575,18 @@ process_command_line_options() {
else
suppress_alert
fi
# force 'no kernel upgrade' mode if buildkernel USE flag not set
if ! "${USE_BUILDKERNEL}"; then
ARG_NO_KERNEL_UPGRADE=1
fi
internal_consistency_option_checks
}

# *************** start of script proper ***************
suppress_colour_and_alert_if_output_not_to_a_terminal
process_command_line_options "${@}"
check_if_using_webrsync_gpg
check_if_using_distcc
display_greeting
check_gcc_config_and_reset_if_necessary
update_portage_tree_and_sync_eix
Expand Down
26 changes: 20 additions & 6 deletions genup.8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH GENUP 8 "Version 1.0.8: August 2015"
.TH GENUP 8 "Version 1.0.9: August 2015"
.SH NAME
genup \- update Portage tree, all installed packages, and kernel
.SH SYNOPSIS
Expand Down Expand Up @@ -88,7 +88,7 @@ By default, \fBgenup\fR will:
a) attempt to perform the update automatically;
b) attempt to rebuild the kernel (if a new version becomes available);
c) fail immediately on any error;
d) invoke underlying tools (such as \fBbuildkernel\fR(1)) in non-interactive
d) invoke underlying tools (such as \fBbuildkernel\fR(8)) in non-interactive
mode; and
e) not invoke \fBdispatch-conf\fR(1) to resolve clashing configuration file
updates (unless the \fB--dispatch-conf\fR option has been specified)
Expand All @@ -101,7 +101,7 @@ c) fail immediately on any error, \fBexcept\fR when that error occurs during the
@world update \fBemerge\fR(1) (in which case, prompt whether or not to retry,
allowing the problem \(em for example, a missing use flag \(em to be fixed in
a separate terminal);
d) invoke most underlying tools (such as \fBbuildkernel\fR(1)) in interactive mode; and
d) invoke most underlying tools (such as \fBbuildkernel\fR(8)) in interactive mode; and
e) invoke \fBdispatch-conf\fR(1) to resolve clashing configuration file updates.

In both interactive and non-interactive modes, \fBgenup\fR can be instructed
Expand All @@ -121,7 +121,7 @@ area). These arguments are \fInot\fR passed to the second invocation, where used
partition).
.TP
.BR \-c ", " \-\-dispatch\-conf
Always forces \fBdispatch-conf\rR(1) to be run, where necessary, even if
Always forces \fBdispatch-conf\fR(1) to be run, where necessary, even if
not in interactive mode.
.TP
.BR \-d ", " \-\-deploy\-from\-staging
Expand Down Expand Up @@ -176,11 +176,13 @@ It has no effect in interactive mode.
.BR \-k ", " \-\-keep\-old\-distfiles
By default, \fBgenup\fR will remove any source tarballs that have previously
been downloaded by Portage, but which do not relate to the installed version of
any package. This option inhibits such cleaning.
any package.
This option inhibits such cleaning.
.TP
.BR \-n ", " \-\-no\-kernel\-upgrade
Do not perform (in non-interactive mode) or offer to perform (in interactive
mode) a kernel recompile, even should a newer version be available.
mode) a kernel recompile, even should a newer version be available.
This option is implied if the \fBbuildkernel\fR USE flag is unset.

Note, this does \fBnot\fR itself prevent the update of \fBgentoo-sources\fR (or similar
package), during the @world \fBemerge\fR(1) step.
Expand All @@ -207,6 +209,10 @@ Because of this, \fBgenup\fR will attempt to
automatically resume any \fBemerge\fR(1) operation with parallel make
inhibited, should the original operation fail. A warning is issued if this
happens.

In a similar fashion, if you are using distributed compilation
with the \fBdistcc\fR and \fBdistcc-pump\fR features, these will be
automatically inhibited if operations are retried.
.SH AUTOMATING GENUP
Should you wish to run \fBgenup\fR automatically, you need to ensure it has
an appropriate environment.
Expand All @@ -221,6 +227,14 @@ export PATH="/usr/local/sbin:/usr/local/bin:"\\
"/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin"
genup >/var/log/latest-genup-run.log 2>&1
.fi
.SH EFFECT OF USE FLAGS
If the \fBbuildkernel\fR USE flag is \fIun\fRset when \fBgenup\fR is emerged
(it is set by default), then in effect the \fB--no-kernel-upgrade\fR option
is always forced on, and as such
\fBgenup\fR will never attempt to call
\fBbuildkernel\fR(8).
This makes it suitable for use in an embedded context (where there may
be no EFI system partition etc.).
.SH COPYRIGHT
.nf
Copyright \(co 2014-2015 sakaki
Expand Down

0 comments on commit 4e7f82a

Please sign in to comment.