LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-05-2009, 08:37 AM   #1
Himilhil
Member
 
Registered: Jun 2009
Posts: 52

Rep: Reputation: 15
How to split title of slackware package?


I need to get in my python script a name and a version of slackware package from it title. I thought that name, version, architecture etc. in title of package is separated with dashes. But after i had found packages with title like "network-scripts-12.2-noarch-4". In this title dash is in the middle of package name ("network-scripts"). I don't know how could i get name and version in this case algorithmically. Is there any algorithm of getting name and version from slackware package title?
 
Old 07-05-2009, 09:02 AM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
The algorithm is usually this:

1) reverse the name of the package
2) with delimiter '-', fields are:
field 1 is the release
field 2 is the architecture
field 3 is the version
and the rest of the fields is the name
3) reverse the name again

In bash it would be:
Code:
bash-3.1$ echo 'xorg-server-xnest-1.4.0.90-x86_64_slamd64-1' | rev | cut -d - -f 1 | rev
1
bash-3.1$ echo 'xorg-server-xnest-1.4.0.90-x86_64_slamd64-1' | rev | cut -d - -f 2 | rev
x86_64_slamd64
bash-3.1$ echo 'xorg-server-xnest-1.4.0.90-x86_64_slamd64-1' | rev | cut -d - -f 3 | rev
1.4.0.90
bash-3.1$ echo 'xorg-server-xnest-1.4.0.90-x86_64_slamd64-1' | rev | cut -d - -f 1-3 --complement | rev
xorg-server-xnest
 
Old 07-05-2009, 11:45 AM   #3
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 232Reputation: 232Reputation: 232
Quote:
Is there any algorithm of getting name and version from slackware package title?
You already have this in a number of bash scripts i.e. installpkg, removepkg, upgradepkg - namely pkgtools. Just have a look at the workings of the "package_name" bash function in these scripts.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't call method "title" on undefined title in Perl script scuzzman Programming 12 12-11-2009 04:40 AM
How to split file , .. awk or split ERBRMN Linux - General 9 08-15-2006 12:02 AM
using older slackware package for newer slackware. Is it problematic? hottdogg Slackware 2 12-13-2005 03:57 AM
under with title and sub title the "GTK devel" found in fc3? AKAKAK Fedora 3 02-27-2005 05:51 AM
split package error chuck2 Slackware 2 07-08-2003 12:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration