1 |
On Sun, 21 Oct 2007 11:44:46 +0100 |
2 |
Steve Long <slong@××××××××××××××××××.uk> wrote: |
3 |
|
4 |
> Markus Rothe wrote: |
5 |
> |
6 |
> > Attached are the scripts I use to commit packages stable/unstable. |
7 |
> > Somewhere must be a bug! |
8 |
> > |
9 |
> > 'name_split.cpp' splits a package name like sys-devel/gcc-4.1.2 into |
10 |
> > category, package name and version number. It's done in c++ as |
11 |
> > that's the only language I do more with than 'hello world' |
12 |
> > programms. Not much more, just more. ;-) |
13 |
> > |
14 |
> You can do this quite easily with a shell function. Here's a slightly |
15 |
> modded version of the one we use in update: |
16 |
> # returns true if there was a version |
17 |
> getPkgNameVer() { |
18 |
> case "$1" in |
19 |
> *-cvs[0-9]*) |
20 |
> pName=${1%-cvs[0-9]*} |
21 |
> pVer=${1#$pName-} |
22 |
> ;; *-[0-9]*) |
23 |
> pName=${1%%-[0-9]*} # from first -N |
24 |
> pVer=${1#$pName-} |
25 |
> ;; *) |
26 |
> pName=$1 |
27 |
> pVer= |
28 |
> ;; esac |
29 |
> pCat=${pName%/*}; pN=${pName#*/} |
30 |
> [ "$pVer" ] && return 0 |
31 |
> return 1 |
32 |
> } |
33 |
> ..which leaves the results in globals pName (which includes cat) |
34 |
> pVer, pCat and pN (no category.) It handles cvs ebuilds as well, and |
35 |
> is in sh. |
36 |
|
37 |
But like name_splitted.cpp is buggy as it assumes that a dash followed |
38 |
by a digit starts the version part. See |
39 |
echo ${PORTDIR}/*-*/* | tr ' ' '\n' | grep '\-[[:digit:]]' |
40 |
for some names that break the assumption. |
41 |
|
42 |
And no clue what that cvs stuff is supposed to do, as there are no |
43 |
packages using that naming pattern, and the (unused) cvs versioning |
44 |
extension in portage-2.1 also uses a different pattern. |
45 |
|
46 |
Marius |
47 |
|
48 |
-- |
49 |
Public Key at http://www.genone.de/info/gpg-key.pub |
50 |
|
51 |
In the beginning, there was nothing. And God said, 'Let there be |
52 |
Light.' And there was still nothing, but you could see a bit better. |