Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Keeping track of already recompiled package for gcc upgrade
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
guitoo
Tux's lil' helper
Tux's lil' helper


Joined: 04 Jun 2004
Posts: 136

PostPosted: Sat Apr 22, 2017 3:01 pm    Post subject: Keeping track of already recompiled package for gcc upgrade Reply with quote

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
Code:
qlop -l $pack

check for exact version
Code:
grep ${pack:1}

only keep last compilation
Code:
tail -n 1

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
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22876

PostPosted: Sat Apr 22, 2017 4:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3477

PostPosted: Sat Apr 22, 2017 7:45 pm    Post subject: Reply with quote

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 :roll:
Back to top
View user's profile Send private message
guitoo
Tux's lil' helper
Tux's lil' helper


Joined: 04 Jun 2004
Posts: 136

PostPosted: Sat Apr 22, 2017 8:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22876

PostPosted: Sat Apr 22, 2017 8:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
josephg
l33t
l33t


Joined: 10 Jan 2016
Posts: 783
Location: usually offline

PostPosted: Sat Apr 22, 2017 9:57 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22876

PostPosted: Sat Apr 22, 2017 10:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum