View previous topic :: View next topic |
Author |
Message |
guitoo Tux's lil' helper
Joined: 04 Jun 2004 Posts: 136
|
Posted: Sat Apr 22, 2017 3:01 pm Post subject: Keeping track of already recompiled package for gcc upgrade |
|
|
I switched to GCC 5 a few days ago and i didn't want to launch an emerge command that would take several days to complete.
Code: | revdep-rebuild --library 'libstdc++.so.6' -- --exclude gcc |
Instead i made a one-liner that give me all the packages that i still didn't rebuild since the switch to GCC 5. I'am using qlop to get the last time a package was merged.
I put all the packages that needed recompilation in a file called packages with 1 package per line of the form
Code: | =category/package-version |
gccdate is the date i compiled GCC 5 in seconds
Code: | gccdate=$(date -d "Apr 20 2017" +%s) |
Here is the one-liner that remove all package from the packages file that already have been remerged since gccdate.
Code: | for pack in $(cat packages); do line=$( qlop -l $pack | grep ${pack:1} | tail -n 1); pdate=$(date -d "$(echo $line | awk '{print $2,$3,$5,$4}')" +%s); if [ $gccdate -ge $pdate ]; then echo $pack; fi; done |
Now i can stop the merge, if i need to, without worrying about recompiling the same package again and again.
Here is what it actually does
for each package
Code: | for pack in $(cat packages); do |
list all emerge with the date
check for exact version
only keep last compilation
reformat the date
Code: | pdate=$(date -d "$(echo $line | awk '{print $2,$3,$5,$4}')" +%s) |
compare if the package is older than gccdate and print the package
Code: | if [ $gccdate -ge $pdate ]; then echo $pack |
|
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22880
|
Posted: Sat Apr 22, 2017 4:54 pm Post subject: |
|
|
I think there is a much easier way to do this. I see in /var/db/pkg/category/package a file named BUILD_TIME that has the epoch seconds at which the package was built (not installed). I see this for a package I installed years ago and never touched, so it is not a recent addition to Portage. Note that my form does not allow the leading = that you specified. It does require the package version to be specified and it will produce a leading = on output.
Code: | #!/bin/bash
set -e
boundary="$1"
if [[ -z "$boundary" ]]; then
echo "Usage: $0 <boundary-date>" >&2
exit 1
fi
if [[ -n "${boundary//[0-9 ]/}" ]]; then
# Assume user passed in a date in non-epoch form
boundary=$(date -d "$boundary" +%s)
fi
while read f; do
if [[ ! -d "${ROOT}/var/db/pkg/$f" ]]; then
echo "Ignoring uninstalled package $f" >&2
continue
fi
read BUILD_TIME < "${ROOT}/var/db/pkg/$f/BUILD_TIME"
if [[ "$boundary" -ge "$BUILD_TIME" ]]; then
echo "=$f"
fi
done < packages
|
|
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3477
|
Posted: Sat Apr 22, 2017 7:45 pm Post subject: |
|
|
How about hitting Ctrl+C and then typing emerge --resume?
I personally simply tend to suspend my pc instead of rebooting, so it didn't really matter to me that rebuilding stuff took it's time over 3 days or something. The state was still cached in RAM |
|
Back to top |
|
|
guitoo Tux's lil' helper
Joined: 04 Jun 2004 Posts: 136
|
Posted: Sat Apr 22, 2017 8:14 pm Post subject: |
|
|
Thx for the script. It's way faster than using qlop and i dont have to mess with date conversion. I wonder how old are the oldest packages in my system.
@szatox
There will inevitably have some packages that will fail and i will either have to get rid of them or remerge some dependencies. I rarely use --resume because i always have multiples emerge working at the same time anyway.
But if i see libreoffice, chromium or any webkit package I will Ctrl-C the S* out of it and --resume --skipfirst. Chromium takes 15 hours to compile. |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22880
|
Posted: Sat Apr 22, 2017 8:54 pm Post subject: |
|
|
For the least recently installed (which may differ from the least recently built if you ever installed a prebuilt tbz2): Code: | find "$ROOT/var/db/pkg/" -mindepth 2 -maxdepth 2 -printf '%T@ %T+ %P\n' |sort -n | gawk '{print $2, $3;}' | This prints all directories, with their times in machine-readable and human-readable forms, sorts by machine-readable, then discards that and shows only the human-readable parts. |
|
Back to top |
|
|
josephg l33t
Joined: 10 Jan 2016 Posts: 783 Location: usually offline
|
Posted: Sat Apr 22, 2017 9:57 pm Post subject: |
|
|
Hu wrote: | For the least recently installed (which may differ from the least recently built if you ever installed a prebuilt tbz2): Code: | find "$ROOT/var/db/pkg/" -mindepth 2 -maxdepth 2 -printf '%T@ %T+ %P\n' |sort -n | gawk '{print $2, $3;}' | This prints all directories, with their times in machine-readable and human-readable forms, sorts by machine-readable, then discards that and shows only the human-readable parts. |
thank you Hu this is very handy.. but i see too many packages listed from long ago. and i thought the gcc upgrade made me rebuild everything. should i recompile everything every few years (or months)?
Last edited by josephg on Sun Apr 23, 2017 2:16 pm; edited 1 time in total |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22880
|
Posted: Sat Apr 22, 2017 10:36 pm Post subject: |
|
|
No, the gcc upgrade only requires you to rebuild packages that depend on the gcc semantics that changed. You expressed interest in knowing the age of your eldest packages, so the command I gave lists all packages, including ones that are data-only or scripts-only, neither of which could depend on any gcc semantics. Your earlier approach of generating a hand-curated list of packages that depend on gcc semantics, then filtering it based on age, is correct for your current need. |
|
Back to top |
|
|
|