Skip to content

emcek/pyerge

image Python CI Coverage Status Codacy Badge License Downloads image pre-commit.ci status Maintainability Rating

pyerge

It is a small python wrapper tool for emerge (Gentoo package manager - Portage). It can mount RAM disk of a defined size and compile packages inside it. Pyerge provide various tools to check and show emerge/portage status for conky.

Table of Contents

Name

It should be called PYMERGE for PYthon and eMERGE, but when I create the repository, I misspelled the name, and I keep it like that.

Requirements

  • Python-3.10+
  • sys-apps/portage (for: emerge)
  • app-portage/eix (for: eix-sync)
  • app-portage/genlop (for: genlop)
  • app-portage/smart-live-rebuild (for: smart-live-rebuild)
  • app-admin/sudo (for: sudo)
  • sys-apps/coreutils (for: df)
  • net-misc/iputils (for: ping)

Installation

Copy ebuild from GitHub Releases into your local repository (i.e. /var/db/repos/local/app-portage/pyerge) and run as root:

eselect repository create local
cd /var/db/repos/local/app-portage/pyerge
cp /path/to/pyerge-0.7.2.ebuild .
cp /path/to/metadata.xml .
pkgdev manifest  # (from: dev-util/pkgdev)
# or
ebuild pyerge-0.7.2.ebuild manifest
eix-update
echo "app-portage/pyerge ~amd64" >> /etc/portage/package.accept_keywords
emerge app-portage/pyerge

Ebuild is good quality as RepoMan sez: "If everyone were like you, I'd be out of business!"

Main usage

Pyerge API/CLI parameter are not stable yes and are subject to change. Main pyerge script is called pye and has two main actions: check and emerge

pye check

sudo pye check

It basically run:

  • sync portage eix-sync
  • sudo emerge -pvNDu --nospinner --with-bdeps=y --color n @world (and save output to log_file_1)
  • Estimete time for running emerge @world with genlop -pn (and save to log_file_2)

Some useful switches:

  • -l, --local - run everthing without eix-sync
  • -q, --quiet - no output from pyerge itself only from other tools like eix, or emerge
  • -v, --verbose - be more verbose

pye emerge

sudo pye -w emerge

It basically run:

  • check if emerge isn't running
  • set environment variable PORTAGE_TMPDIR to /var/tmp/portage
  • mount 4G RAM disk to /var/tmp/portage
  • run emerge -NDu --nospinner --with-bdeps=y --keep-going=y @world
  • unmount RAM disk

Some useful switches:

  • -d, --clean-print - after running emerge -pvNDu @world it will show output from deep clean - emegre -pc
  • -c, --clean-run - after running emerge -pvNDu @world it will run deep clean - emerge -c (imply -d)

After emerge action you can pass any emerge CLI parameter, it will be passed directly into emerge. So, you can build:

sudo pye -s 1G emerge -a app-admin/conky

It will mount only 1G RAM disk and ask while compiling app-admin/conky package.

  • -s, --size - size of RAM disk with postfix i.e. 1024K, 512M, 2G

Tools for Conky

Those tools are created especially for Conky monitoring. i.e. part of my .conkyrc:

color0 5b6dad
color1 7f8ed3
TEXT
${color0}Sensors:
 ${color0}CPU1: ${color1}${hwmon 0 temp 2}°C ${color0}CPU2: ${color1}${hwmon 0 temp 3}°C
 ${color0}md126 (root): ${color1}${execi 60 e_raid -n md126}   ${color0}md127 (swap): ${color1}${execi 60 e_raid -n md127}
${color1}$hr
${color0}File Systems:
 ${color0}root ${color1}${fs_used /}/${fs_size /} ${color1}${fs_bar /}
 ${color0}boot ${color1}${fs_used /boot}/${fs_size /boot} ${color1}${fs_bar /boot}
 ${color0}portage ${color1}${fs_used /var/tmp/portage}/${fs_size /var/tmp/portage} ${color1}${fs_bar 6 /var/tmp/portage}
${color1}$hr
${color0}Portage:
 ${color0}Last Sync: ${color1}${execi 120 e_sync}
 ${color0}Progress:  ${color1}${execibar 30 e_prog}
 ${color0}Package:   ${color1}${execi 30 e_curr}
 ${color0}ETA:       ${color1}${execi 30 e_eta}
 ${color0}Status:    ${color1}${execi 30 e_sta}
 ${color0}Update:    ${color1}${execi 30 e_upd}
 ${color0}Download:  ${color1}${execi 30 e_dl}
 ${color0}EUT:       ${color1}${execi 30 e_eut}
 ${color0}Live:      ${color1}${execi 5400 e_live all}
${color1}$hr
${color0}Gentoo Linux Security Advisories:
${color1}${execi 5400 glsa list -e 25}
${color0}Affected GLSA:
${color1}${execi 5400 glsa test -e 40}

e_sync

e_sync

Print date of last emerge syc eix-sync

e_dl

e_dl

Run after pye check print size of downloads of @world

i.e. output:

3,239,589 KiB

e_curr

e_curr

Run during sudo pye emereg or sudo emerge - print current building (lastly built) package

e_eut

e_eut

Run after pye check - print estimated update time from genlop -pn

i.e. output:

2 days 10h 36min

e_eta

e_eta

Run during sudo pye emerge or sudo emerge - print estimetet left time to the end of compilation, based on genlop

e_log

e_log

Run after pye check - print content of next @world update

e_sta

e_sta

Status of emerge/portage. Possible values: Compiling, Cleaning, Autoclean, Completed, Finished, Synced, Syncing, Unmerging, Merging, Unmerge

e_prog

e_prog

Run during sudo pye emerge or sudo emerge - print current progress of emerge as float i.e. output - if emerge is building (5 of 6) package it will return 83.3333 You can use it in conky as: ${execibar 30 e_prog}

e_upd

e_upd

Run after pye check - print types of next @world update. Possible values: U, N, NS, R, Un, D, B

i.e. output:

19 U, 2 R, 1 Un, 2 D

it means 19 upgrades, 2 reinstals, 1 uninstall, 2 downgrades

e_raid

e_raid <raid dev>

Print RAID status form /proc/mdstat

e_raid md126:

i.e. output:

[UUU]

e_live

e_live <action>

Print names and number of live ebuild to rebuild

e_live all

i.e. output:

cvechecker,openmw (2 of 3)

glsa

glsa -e 5 list

List last 5 of GLSA entries

202107-55: SDL 2: Multiple vulnerabilities
202107-54: libyang: Multiple vulnerabilities
202107-53: Leptonica: Multiple vulnerabilities
202107-52: Apache Velocity: Multiple vulnerabilities
202107-51: IcedTeaWeb: Multiple vulnerabilities
glsa -e 40 test

Check system against the last 40 of GLSA.

System is not affected by any of listed GLSAs

or list of IDs:

202107-53,202107-52

About

It is Python wrapper tool for emerge (Gentoo package manager - Portage). It can mount RAM disk of defined size and compile packages inside it

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors