Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Rebuild your /usr/portage/packages
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
garo
Bodhisattva
Bodhisattva


Joined: 15 Jul 2002
Posts: 860
Location: Edegem,BELGIUM

PostPosted: Sat May 01, 2004 9:27 am    Post subject: Rebuild your /usr/portage/packages Reply with quote

If you emerge with the "-b" option then the directory "/usr/portage/packages" contains all your generated packages as binaries.
The subdirectory "All" contains the binaries, the other subdirectory's have the name of the categories of packages (like "app-editors" for example) and contain the symlinks to the files in "All".
These packages can be very usefull if you want to install gentoo on a identical system or if you want re-install your system, it can save you lots of time.
But what if you only recently used the "-b" option, in this case you don't have binary versions of all your packages. To fix this problem, here is a bash command that searches all packages on your system, looks if you have a binary version of it, and otherwise re-emerges it with the "-B" option (this makes a binary version of the package, but doesn't install the package on your system).

Check with which USE-flags everything will be merged:
Code:
for a in `for b in \`epm -qa\` ; do if [ ! -f /usr/portage/packages/All/$b.tbz2 ] ; then echo $b ; fi ; done | xargs epm -qG` ; do echo =$a ; done | xargs emerge --oneshot -Bvp


Emerge it:
Code:
for a in `for b in \`epm -qa\` ; do if [ ! -f /usr/portage/packages/All/$b.tbz2 ] ; then echo $b ; fi ; done | xargs epm -qG` ; do echo =$a ; done | xargs emerge --oneshot -B


You can also use quickpkg to in this script to save compilation time and use the allready existing files on your system to create the package, but you have to be sure that there are no files deleted. (If a file is modified, then the modified version will be included)
Code:
for a in `for b in \`epm -qa\` ; do if [ ! -f /usr/portage/packages/All/$b.tbz2 ] ; then echo $b ; fi ; done | xargs epm -qG` ; do quickpkg  =$a ; done



To run this script you need the following software (if you don't have it, emerge it):
sys-apps/portage (I am 100 % sure you already have this)
app-shells/bash (I am 99 % sure you already have this)
sys-apps/findutils (I am 90 % sure you already have this)
app-portage/epm (I am 20 % sure you already have this)
If you don't want to emerge epm then you can use the following code:
Code:
for i in `qpkg -nc -v -I` ; do if [ ! -f /usr/portage/packages/$i.tbz2 ] ; then quickpkg =$i ; fi; done

The code without epm checks for the precense of the symbolic links to the packages, it doesn't check the precense of the actual packages. (It will work with 99.9% of the people, but if you are part of that 0.1% that messed up the symlinks then you have to use the epm code.)

English is not my mother language so it could be that there are some grammatical mistakes in this post, please tell me if you see one.

TODO:
1) delete old packages (optional)
2) put a layout in this post (optional)

Thanks to Angrybob for the idea of using quickpkg
Thanks to Regeya for the qpkg code
_________________
My favorite links this month:
- Surf Random
- Web-based SSH
- Stop Spam


Last edited by garo on Wed May 05, 2004 11:46 am; edited 4 times in total
Back to top
View user's profile Send private message
Angrybob
Guru
Guru


Joined: 19 Apr 2003
Posts: 575

PostPosted: Sat May 01, 2004 12:39 pm    Post subject: Reply with quote

instead of using emerge -B use quickpkg, saves having to recompile something you have allready installed
Back to top
View user's profile Send private message
garo
Bodhisattva
Bodhisattva


Joined: 15 Jul 2002
Posts: 860
Location: Edegem,BELGIUM

PostPosted: Sun May 02, 2004 9:04 am    Post subject: Reply with quote

thanks ! I didn't know quickpkg existed...
But before i update this howto, what happens if you:
-already modified a config file of a package before running quickpkg ?
-deleted a file of a package before running quickpkg ?
_________________
My favorite links this month:
- Surf Random
- Web-based SSH
- Stop Spam
Back to top
View user's profile Send private message
ecatmur
Advocate
Advocate


Joined: 20 Oct 2003
Posts: 3595
Location: Edinburgh

PostPosted: Mon May 03, 2004 6:31 am    Post subject: Reply with quote

quickpkg uses:
Code:
tar -vjcf ${MYDIR}/bin.tar.bz2 --files-from=${MYDIR}/filelist --no-recursion
So if the file has been modified it is the modified file that is added - useful for propagating shared configs across a network of Gentoo boxes. If a file has been removed you will get:
tar: <file>: Cannot stat: No such file or directory
and at the end:
tar: Error exit delayed from previous errors
but the binpkg will still be created.
_________________
No more cruft
dep: Revdeps that work
Using command-line ACCEPT_KEYWORDS?
Back to top
View user's profile Send private message
garo
Bodhisattva
Bodhisattva


Joined: 15 Jul 2002
Posts: 860
Location: Edegem,BELGIUM

PostPosted: Mon May 03, 2004 5:05 pm    Post subject: Reply with quote

updated with quickpkg, the part to delete old packages is on its way
_________________
My favorite links this month:
- Surf Random
- Web-based SSH
- Stop Spam
Back to top
View user's profile Send private message
regeya
Apprentice
Apprentice


Joined: 28 Jul 2002
Posts: 270
Location: Desoto, IL, USA

PostPosted: Tue May 04, 2004 6:50 am    Post subject: Reply with quote

I'm sure someone will find something wrong with this; I suck at shellscripting (and embarrassingly enough, my first introduction to UNIX was in 1996. :oops: )

Code:

for i in `qpkg -nc -v -I | awk '{ print $1 }'` ; do if [ ! -f /usr/portage/packages/$i.tbz2 ] ; then quickpkg =$i ; fi; done
Back to top
View user's profile Send private message
garo
Bodhisattva
Bodhisattva


Joined: 15 Jul 2002
Posts: 860
Location: Edegem,BELGIUM

PostPosted: Tue May 04, 2004 5:21 pm    Post subject: Reply with quote

regeya wrote:
I'm sure someone will find something wrong with this; I suck at shellscripting (and embarrassingly enough, my first introduction to UNIX was in 1996. :oops: )

Code:

for i in `qpkg -nc -v -I | awk '{ print $1 }'` ; do if [ ! -f /usr/portage/packages/$i.tbz2 ] ; then quickpkg =$i ; fi; done


I didn't test the code (I am to lazy, but as you know "a lazy programmer is a good programmer") but:
- I don't understand why you piped the output of qpkg to | awk '{ print $1 }. Awk doesn't change the output.
- There is a (very small) problem in your code. I checked if the package existed in "/usr/portage/packages/All/" and you checked if it existed in "/usr/portage/packages/group/". The files in "/usr/portage/packages/group/" are only symlinks, so if they exist it doesn't always mean that the binary package actually exist.

Thank you for the qpkg code ! I never use qpkg, so i didn't know the possibilities, i'm going to combine my script with your script in the first post of this topic.
_________________
My favorite links this month:
- Surf Random
- Web-based SSH
- Stop Spam
Back to top
View user's profile Send private message
regeya
Apprentice
Apprentice


Joined: 28 Jul 2002
Posts: 270
Location: Desoto, IL, USA

PostPosted: Tue May 04, 2004 10:03 pm    Post subject: Reply with quote

garo wrote:

- I don't understand why you piped the output of qpkg to | awk '{ print $1 }. Awk doesn't change the output.
- There is a (very small) problem in your code. I checked if the package existed in "/usr/portage/packages/All/" and you checked if it existed in "/usr/portage/packages/group/". The files in "/usr/portage/packages/group/" are only symlinks, so if they exist it doesn't always mean that the binary package actually exist.

Thank you for the qpkg code ! I never use qpkg, so i didn't know the possibilities, i'm going to combine my script with your script in the first post of this topic.


First: I was tired and couldn't think of a better way to strip off that trailing "*" on some packages (why is it there, anyway?

Second: I tested this on my own system and it worked fine, believe it or not. I'll look into it. EDIT: I suppose stripping off everything before the "/" and the whitespace would get me the package name; I suck at regexps. I think I'm starting to see why epm might be a good idea. ;-D
Back to top
View user's profile Send private message
garo
Bodhisattva
Bodhisattva


Joined: 15 Jul 2002
Posts: 860
Location: Edegem,BELGIUM

PostPosted: Wed May 05, 2004 11:49 am    Post subject: Reply with quote

regeya wrote:
I tested this on my own system and it worked fine, believe it or not. I'll look into it. EDIT: I suppose stripping off everything before the "/" and the whitespace would get me the package name; I suck at regexps. I think I'm starting to see why epm might be a good idea. ;-D


It will work with most of the people, but if you changed the symlinks in /usr/portage/packages it will not work.

Quote:
I was tired and couldn't think of a better way to strip off that trailing "*" on some packages (why is it there, anyway?


What "*" ? I never see the *-character when i run qpkg.
_________________
My favorite links this month:
- Surf Random
- Web-based SSH
- Stop Spam
Back to top
View user's profile Send private message
regeya
Apprentice
Apprentice


Joined: 28 Jul 2002
Posts: 270
Location: Desoto, IL, USA

PostPosted: Thu May 06, 2004 2:19 am    Post subject: Reply with quote

garo wrote:
regeya wrote:
I tested this on my own system and it worked fine, believe it or not. I'll look into it. EDIT: I suppose stripping off everything before the "/" and the whitespace would get me the package name; I suck at regexps. I think I'm starting to see why epm might be a good idea. ;-D


It will work with most of the people, but if you changed the symlinks in /usr/portage/packages it will not work.

Quote:
I was tired and couldn't think of a better way to strip off that trailing "*" on some packages (why is it there, anyway?


What "*" ? I never see the *-character when i run qpkg.


Wal shucks! Guess I hadn't realized how tired I was. You only see asterisks if you don't use the -nc option. My bad. :oops:

Once again, I suck at shellscripting, so if you see a glaring error in this one, I'm more than happy to take constructive criticism. :D

Code:
for i in `qpkg -nc -v -I` ; do if [ ! -f /usr/portage/packages/All/`echo $i | sed "s/^.*\///"`.tbz2 ]; then quickpkg =$i; fi; done


Then again, maybe the original method was better... :twisted:
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