ReproNim / reproman

ReproMan (AKA NICEMAN, AKA ReproNim TRD3)
https://reproman.readthedocs.io
Other
24 stars 14 forks source link

gentoo support #279

Open yarikoptic opened 6 years ago

yarikoptic commented 6 years ago

for the sake of it with @tgbugs we explored gentoo a bit, here is an excerpt of bash history

$> docker run -it gentoo/stage3-amd64
...
0ea8074e5e45 /etc/portage # history
    1  ls /usr/portage
    2  cd /tmp
    3  wget http://distfiles.gentoo.org/snapshots/portage-latest.tar.bz2
    4  tar -tzvf portage-latest.tar.bz2 
    5  tar -tjvf portage-latest.tar.bz2 
    6  cd /usr/
    7  tar -xjvf /tmp/portage-latest.tar.bz2 
    8  tar -tjf portage-latest.tar.bz2 
    9  tar -xjvf /tmp/portage-latest.tar.bz2 
   10  tar -xjf /tmp/portage-latest.tar.bz2 
   11  emerge datalad
   12  emerge git-annex
   13  emerge fail2bn
   14  emerge fail2ban
   15  emerge gentoolkit
   16  equery b /usr/bin/fail2ban-client 
   17  emerge net-analyzer/fail2ban-0.10.3.1
   18  emerge =net-analyzer/fail2ban-0.10.3.1
   19  equery m /usr/bin/fail2ban-client 
   20  equery m fail2ban
   21  equery m vim
   22  vim
   23  eix
   24  emerge eix
   25  cd /var/db/
   26  ls
   27  cd pkg/
   28  ;s
   29  ls
   30  tree
   31  find
   32  cat ./net-analyzer/fail2ban-0.10.3.1/fail2ban-0.10.3.1.ebuild
   33  ls ./net-analyzer/fail2ban-0.10.3.1/
   34  cat ./net-analyzer/fail2ban-0.10.3.1/repository 
   35  emerge layman
   36  cd /etc/portage/
   37  vi make.conf 
   38  emerge vim
   39  vim make.
   40  vim make.conf 
   41  emerge layman
   42  vim make.conf 
   43  emerge layman
   44  emerge git-annex
   45  echo emerge layman -j4
tgbugs commented 6 years ago

All ebuilds that have been in the portage tree since about 2000 are at https://gitweb.gentoo.org/repo/gentoo/historical.git/. Newer 'old' ebuilds (i.e. since ~2015) can be recovered from https://gitweb.gentoo.org/repo/gentoo.git/ or the github mirror.

To confirm that you have the right source tarballs you would need to also get the old version of the Manifest, either by checking out the old version from historical.git or gentoo.git.

If the original source tarball was not archived from the start (they live in /usr/portage/distfiles/ by default), then you would have to hunt down the original since many of the original source uris may be gone (see for example line 6 from https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-analyzer/fail2ban/fail2ban-0.6.0.ebuild?hideattic=0&view=markup).

Reconstructing the full tree dependency tree can be done on the system at run time by chaining equery commands on the original system, or if you have traced every file that has been touched, then you can run equery b file1 file2 file3 file4 /path/to/file5 | cut -d' ' -f1 | sort -u and get all the packages at once. Performance seems a little slow for this, but it works. If running equery b becomes a frequent activity it shouldn't be too hard to build a reverse index from equery -N -C f $(cat /var/lib/portage/world | grep -v gentoo-sources) > /tmp/equery-all.txt or equery -N -C f $(eix -I -# | grep -v gentoo-sources) > /tmp/equery-all.txt (all installed, takes a bit longer).

Also it looks like there is a cache file located at /var/cache/edb/vdb_metadata.pickle that has most of the information (lacking environment.bz2) which can be loaded into python to avoid having to open lots of files in /var/db/pkg.

The one thing I still can't quite find is where the gcc/clang version used for compile is stored.

NOTE: all the gentoolkit machinery can be use from python on a gentoo system via the gentoolkit module.