package NAMING scheme
I could not find a document that would confirm this, though I did see many examples by various individuals that contradicted this. But I'm basically interested in what is used by Slackware and maybe SBo. My purpose is so I can make a tool that will translate a package name with a version to a package name without a version, for matching a version-less reference.
The base version-less package name may have any number of "-" characters separating parts of the name. A version string is constructed that does not include any "-" characters. It is appended to the name separated by "-", followed by some kind of sequence number (what is this called, "packaging version"), also separated by "-". I have seen package names with as many as 4 "-" separated parts before the version number, such as "font-adobe-utopia-100dpi". So the following awk command could input the full versioned name and output the version-less name: Code:
awk -F- '{m=NF-2;s="";for(i=1;i<m;++i){s=s "-" $i;};print substr(s,2);}' |
Try using regular expressions instead of parsing the string with bare hands.
|
If you google for slackware package naming convention, this is the top hit. http://www.slackware.com/~mozes/docs...esentation.pdf
Is this what you mean? Code:
bash-4.2$ echo "icedtea-web-1.4-x86_64-2alien.txz" | rev | cut -d'-' -f4- | rev |
If I'm understanding this correctly, you're trying to get just the package name (or package name with version)?
I don't know a whole lot of awk, so I use this (for package name only): Code:
rev | cut -f 4- -d "-" | rev Code:
ls -1 /var/log/packages | rev | cut -f 4- -d "-" | rev If you want package names with version, you just need to change the field list to "3-" so it looks like: Code:
ls -1 /var/log/packages | rev | cut -f 3- -d "-" | rev |
Quote:
|
Why reinvent the wheel? Just have a look at functions package_base() and package_name() in /sbin/{install,remove,upgrade}pkg ;)
ERRATUM read pkgbase(), not package_base() |
Quote:
I was focused more on "is this really the naming scheme" (my google search just didn't come up with anything, perhaps because I did not use the term "convention"), rather than "how could one parse this" (I have no trouble with that ... I just do it by hand). |
Quote:
I did see "package_name()" but it seems to be more complex and I don't really follow it. Can the name scheme be described in English? (or French or German or Norwegian is OK) |
If you are using bash, then simply:
PKG=full-name-version-arch-build #(with or without *.txz) echo NAME=${PKG%-*-*-*} You are correct, the separator is the '-' character and fields should be viewed from right to left. In other words, if you have a version number(or arch or build) with a '-' in them, then installpkg will be confused. Names can have any number of '-' chars in them as you like. |
Here is PART of what I am going to be doing with this. I want a search mechanism where an exact package can be found, rather than a prefix (that would be tempting but for what I'm doing would cause problems). If I did a prefix type search then "sysvinit" could match all of "sysvinit-2.88dsf-i486-3.txz" and "sysvinit-functions-8.53-i486-2.txz" and "sysvinit-scripts-2.0-noarch-15.txz". But I really want "sysvinit" to match "
sysvinit-2.88dsf-i486-3.txz". To get "sysvinit-functions-8.53-i486-2.txz" then "sysvinit-functions" should be used. This is because of the way I am building a list of packages that will be used to select package files for installation (it will also allow specifying the package with the version). I don't need help on how this will be done. I was just looking for confirmation of the name scheme, that the last 3 parts separated by "-" are not part of the name itself. |
Quote:
|
Quote:
Quote:
Code:
$ ls /var/log/packages | sed -r 's/^([[:graph:]]+)(-[[:alnum:]\.\+_]+){3}$/\1/' Code:
$ diff -s <(ls /var/log/packages | rev | cut -f 4- -d "-" | rev) <(ls /var/log/packages | sed -r 's/^([[:graph:]]+)(-[[:alnum:]\.\+_]+){3}$/\1/') |
This is what I use in one of my scripts. It generates a list of available packages using the following approach
Code:
gazl@ws1:~$ function reformat_available() { sed -e 's:^\(.*/\)\(.*\)-\([^-]*\)-\([^-]*\)-\([0-9]\+\)\(.*\)\(\.t.z\)$:\2 \2-\3-\4-\5\6 \1\2-\3-\4-\5\6\7:'; } If you want to look-up a specific package it's just a case of tightening the grep using the appropriate anchors. Code:
gazl@ws1:~$ find /local/slackware/slackware64-current/slackware64/ -name "*.t?z" | reformat_available | grep sysvinit |
You need to store all candidates in an array, and loop through them until you find the package you want.
A simple example to illustrate it: Code:
$ pkgs=$(find . -name "sysvinit*") |
Quote:
|
All times are GMT -5. The time now is 12:25 AM. |