Welcome to Upkeep’s documentation!

upkeep.ecleans() → int

Runs the following clean up commands:

  • emerge --depclean --quiet
  • emerge --quiet @preserved-rebuild
  • revdep-rebuild --quiet
  • eclean-dist --deep
  • rm -fR /var/tmp/portage/*
Returns:Exit code of the last command.
Return type:int
upkeep.emerges() → int

Runs the following steps:

  • emerge --oneshot --quiet --update portage
  • emerge --keep-going --tree --quiet --update --deep --newuse @world
  • emerge --keep-going --quiet @live-rebuild
  • emerge --keep-going --quiet @preserved-rebuild
  • systemctl daemon-reexec if applicable
  • upgrade kernel

In the second step, if -H is not passed, heavier packages like Clang and Chromium are built separately, to hopefully allow a machine to remain responsive while building packages.

This function understands the following CLI flags:

  • -a / --ask: Pass --ask to the emerge @world command
  • -L / --no-live-rebuild: Skip emerge @live-rebuild step
  • -P / --no-preserved-rebuild: Skip emerge @preserved-rebuild step
  • -D / --no-daemon-reexec: Skip systemctl daemon-reexec step
  • -U / --no-upgrade-kernel: Skip upgrading the kernel
  • -H / --split-heavy: Split heavy packages to be built separately.
Returns:The exit code of the last command from upgrade_kernel or 0.
Return type:int

See also

upgrade_kernel()

upkeep.esync() → int

Syncs Portage sources. Requires app-portage/eix to be installed.

This runs the following:

  • layman -S (if -l is passed in CLI arguments and if it is available)
  • eix-sync
Returns:Exit code of eix-sync.
Return type:int
upkeep.rebuild_kernel(num_cpus: Optional[int] = None, config_path: Optional[str] = None) → int

Rebuilds the kernel.

Runs the following steps:

  • Checks for a kernel configuration in /usr/src/linux/.config or /proc/config.gz
  • make oldconfig
  • make
  • make modules_install
  • emerge --quiet --keep-going --quiet-fail --verbose @module-rebuild @x11-module-rebuild
  • Archives the old kernel and related files in /boot to the old kernels directory.
  • make install
  • dracut --force (if GRUB is installed)
  • grub-mkconfig -o /boot/grub/grub.cfg (if GRUB is installed)
Parameters:
  • num_cpus (int) – Number of CPUs (or threads) to pass to make -j.... If not passed, defaults to getting the value from multiprocessing.cpu_count().
  • config_path (Optional[str]) – Configuration file path.
Raises:
  • KernelConfigError – If a kernel configuration cannot be found.
  • RuntimeError – If grub-mkconfig fails
Returns:

Returns the exit code of the last run command.

Return type:

int

See also

upgrade_kernel()

upkeep.rebuild_kernel_command() → int

Entry point for the rebuild-kernel command.

See also

rebuild_kernel()

upkeep.upgrade_kernel(num_cpus: Optional[int] = None, config_path: Optional[str] = None, fatal: Optional[bool] = True) → int

Upgrades the kernel.

The logic used here is to check the eselect kernel output for two kernel lines, where one is selected and the newest kernel is not. The newest kernel then gets picked and upgrade_kernel() takes care of the rest.

Parameters:
  • num_cpus (int) – Number of CPUs (or threads) to pass to make -j.... If not passed, defaults to getting the value from multiprocessing.cpu_count().
  • config_path (Optional[str]) – Configuration file path.
  • fatal (Optional[bool]) – If True, raises certain exceptions or returns 1. If False, always returns 0.
Returns:

Returns 1 if the eselect output is not usable. Otherwise, returns the result from upgrade_kernel().

Return type:

int

See also

rebuild_kernel()

upkeep.upgrade_kernel_command() → int

Entry point for the upgrade-kernel command.

See also

upgrade_kernel()

Indices and tables