Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Script to resurrect dead ebuilds
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
zeroth
Tux's lil' helper
Tux's lil' helper


Joined: 27 Feb 2006
Posts: 128

PostPosted: Thu Apr 15, 2010 4:23 pm    Post subject: Script to resurrect dead ebuilds Reply with quote

I occasionally need ebuilds that have been removed from portage, so I wrote this bash script to automate downloading them and their patches. this could use more features but so far it's worked like a charm for me.

just pop it into the root of your local portage overlay and read the usage. it'll automatically digest ebuilds once they're fetched.

Code:

#!/bin/bash

if [[ "$#" < "3" ]] ; then
        echo "Usage: resurrect-ebuild [Cegory] [pacakgename] [version]"
        echo "Usage: resurrect-ebuild [Cegory] [pacakgename] [version] [revision]"
        exit 1
fi

SOURCE="http://sources.gentoo.org/viewcvs.py/*checkout*/gentoo-x86/"
C="$1" # Category
PN="$2"
V="$3"

if [[ "$4" != "" ]] ; then
        PR="-$4"
else
        PR=""
fi

P="$PN-$V"
PVR="$P$R"
MY_PN="$P$R"

mkdir "$C/$PN/files" -p

# get ebuild
if [[ -f "$C/$PN/$MY_PN.ebuild" ]] ; then
        echo "RESURRECT: ebuild already fetched, skipping: $MY_PN"
else
        wget "$SOURCE/$C/$PN/$MY_PN.ebuild" || {
                echo "RESURRECT: Error: failed to fetch ebuild $C/$PN/$MY_PN" >&2
                exit 1
        }
        mv "$MY_PN.ebuild" "$C/$PN"
fi

# get patches
patches=`sed -n '/epatch/{s/.*epatch.*[/]\(.*\.patch\).*/\1/g;p}' "$C/$PN/$MY_PN.ebuild"`
cd "$C/$PN/files"
for patch in ${patches[@]} ; do
        patch=`echo $patch |
                sed 's/${PN}/'"$PN"'/g' |
                sed 's/${P}/'"$P"'/g' |
                sed 's/${V}/'"$V"'/g' |
                sed 's/${PV}/'"$PV"'/g'`

        if [[ -f "$patch" ]] ; then
                echo "RESURRECT: patch already fetched, skipping: $patch"
        else
                wget "$SOURCE/$C/$PN/files/$patch" || {
                        echo "RESURRECT: Error: failed to fetch patch $C/$PN/files/$patch" >&2
                        exit 1
                }
        fi
done

cd ..

ebuild "$MY_PN.ebuild" digest


Last edited by zeroth on Thu Apr 15, 2010 6:54 pm; edited 4 times in total
Back to top
View user's profile Send private message
avx
Advocate
Advocate


Joined: 21 Jun 2004
Posts: 2152

PostPosted: Thu Apr 15, 2010 4:44 pm    Post subject: Reply with quote

Now this is nice, thank you. Would be cool if it could be included in gentoolkit or the like.
Back to top
View user's profile Send private message
beandog
Bodhisattva
Bodhisattva


Joined: 04 May 2003
Posts: 2072
Location: /usa/utah

PostPosted: Thu Apr 15, 2010 4:59 pm    Post subject: Reply with quote

Very cool ... for some reason, it stalls on me when setting the patches var w/egrep (tried it w/media-sound audacious 1.5.1)
_________________
If it ain't broke, tweak it. dvds | blurays | blog | wiki
Back to top
View user's profile Send private message
zeroth
Tux's lil' helper
Tux's lil' helper


Joined: 27 Feb 2006
Posts: 128

PostPosted: Thu Apr 15, 2010 6:16 pm    Post subject: Reply with quote

yes, it stalls on my machine during egrep or somewhere thereafter as well, Idon't know why. if I CTRL+C and run it again, it runs fine. I thought maybe the digest was hanging, but I don't know where exactly the problem is.

on another note, when I get some time, I want to make the script properly parse full package atoms instead of supplying each argument separetely, ie

# resurrect-ebuild =media-libs/alsa-lib-1.0.17-r1

instead of

# resurrect-ebuild media-libs alsa-lib 1.0.17 r1

some simple sed'ing should do the trick


edit: made some improvements and fixes in top post
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming 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