Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/gawk -f
- function dep_fix(str, a,k1,p1,p2,out,seps){
- split(str,a,",")
- out = ""
- for (k1 in a){
- p1=a[k1]
- gsub(/^+/,"",p1)
- split(p1,p2,/&../,seps) # +libqpdf21>8.4 > p2[1]="+libqpdf21" seps[1]=">" p2[2]="8.4",
- switch (seps[1]) {
- case ">":
- out = out ", " p2[1] " (>" p2[2] ")"
- break
- case "&ge":
- out = out ", " p2[1] " (>=" p2[2] ")"
- break
- case "<":
- out = out ", " p2[1] " (<" p2[2] ")"
- break
- case "&le":
- out = out "," p2[1] " (<=" p2[2] ")"
- break
- case "&eq":
- out = out ", " p2[1] " (=" p2[2] ")"
- break
- default:
- out = out ", " p2[1]
- break
- }
- gsub(/^, /,"",out)
- }
- return out
- }
- BEGIN{FS="|"}
- {
- PACKAGE=$2
- print "Package: " PACKAGE
- VERSION = $3
- #TODO make PACKAGE regular expression safe
- gsub(/[+]/,"\\+",PACKAGE)
- gsub(PACKAGE,"",VERSION)
- gsub(/^_/,"",VERSION)
- gsub(/_[^_]*$/,"",VERSION)
- print "Version: " VERSION
- ARCH = $1
- gsub(/.*_/,"",ARCH)
- if ( ARCH == "i386" ){
- print "Architecture: " ARCH
- } else if ( ARCH = noarch ){
- print "Architecture: noarch"
- }
- #TODO Architecture: $1 but trimmed after last _ check that it is like i386
- print "Maintainer: unspecified"
- DEPS = $9
- DEPS = dep_fix(DEPS)
- if (length(DEPS)>0){
- print "Depends: " DEPS
- }
- print "Priority: " PRIORITY
- print "Section: " $5
- print ""
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement