aboutsummaryrefslogtreecommitdiffstats
path: root/dist-tools/shipper/rpm2lsm
blob: 6a05d6c71e0bf73a6da0f70ac2615ccde54cc884 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#/bin/sh
#
# rpm2lsm -- generate Linux Software Map file from RPM meta information
#
# Author:       Eric S. Raymond <esr@thyrsus.com>, 31 July 2002
# Project page: http://www.catb.org/~esr/
#
# Requires fmt(1), awk(1), and rpm(8).

while getopts a:m:k:p: c;
do
  case $c in
   'a') author=$OPTARG;;
   'm') maintainer=$OPTARG;;
   'k') keywords=$OPTARG;;
   'p') platforms=$OPTARG;;
   '?') echo "rpm2lsm: invalid switch specified - aborting."; exit 1;;
  esac
done
shift `expr $OPTIND - 1`

# If no RPM was given, look in the current directory and pick the last
# one in sort order.  That's likely to be the most recent.
if [ -z "$1" ]
then
	set -- *.rpm
	while [ "$2" ]
	do
		shift
	done
fi

# Mine out all the single-token fields we'll need
rpm=$1
set -- `rpm --queryformat="%{name} %{version} %{release}" -qp $rpm`
name=$1
version=$2
release=$3

# Extract and reformat the desciption
description=`rpm --queryformat="%{description}" -qp $rpm | fmt -w 65 | sed '2,$s/^/                /'`

# Who am I?
fullname=`cat /etc/passwd | awk -F : "/^${USER}/ "'{print $5}'`
fullname="${USER}@${HOSTNAME} ($fullname)"

if [ -z "$author" ]
then 
    if [ -f AUTHORS ]
    then
	author=`cat AUTHORS`
    else
	author=$fullname
    fi
fi

# Fill in keywords if present
if [ -n "$keywords" ]
then
    keywords="Keywords:       $keywords\n"
fi

# Default the maintainer field properly
if [ -z "$maintainer" ]
then
    maintainer=`rpm --queryformat="%{packager}" -qp $rpm`
    if [ "$maintainer" = "(none)" ]
    then
        maintainer=$author
    fi
fi

# The date
date=`date '+%Y-%m-%d'`

cat >/usr/tmp/rpm2lsm.$$ <<EOF
Begin3
Title:		%{name}
Version:	%{version}
Entered-date:	${date}
Description:	${description}
${keywords}Author: 	${author}
Maintained-by:	${maintainer}
Primary-site:	%{url}
EOF

# File patterns that we ship 
tarballs="${name}-${version}.tar.gz ${name}-${version}.tgz"
rpms=${name}-${version}-${release}.*.rpm

trap "rm -f /usr/tmp/rpm2lsm.$$"  0 2 15
for file in $tarballs $rpms
do
    if [ -f $file ]
    then
        set -- `du $file`; size=$1
        echo "		${size}	${file}" >>/usr/tmp/rpm2lsm.$$
    fi
done

cat >>/usr/tmp/rpm2lsm.$$ <<EOF
Platforms:      ${platforms:-All}
Copying-policy:	%{license}
End
EOF

format=`cat /usr/tmp/rpm2lsm.$$`
rpm --queryformat="$format" -qp $rpm
#414141", "& c Gray26", "* c #444444", "= c Gray28", "- c #4c4c4c", "; c Gray30", ": c #4e4e4e", "> c Gray32", ", c #565656", "< c #5a5a5a", "1 c Gray37", "2 c #5f5f5f", "3 c Gray38", "4 c #626262", "5 c #676767", "6 c #686868", "7 c #6a6a6a", "8 c Gray42", "9 c #6c6c6c", "0 c Gray43", "q c #767676", "w c #777777", "e c Gray47", "r c #7b7b7b", "t c Gray50", "y c #808080", "u c #818181", "i c #838383", "p c #848484", "a c Gray52", "s c Gray53", "d c Gray54", "f c #8b8b8b", "g c Gray55", "h c #8e8e8e", "j c Gray57", "k c #929292", "l c #959595", "z c Gray59", "x c #979797", "c c #989898", "v c Gray60", "b c #9b9b9b", "n c Gray61", "m c #9f9f9f", "M c Gray64", "N c #a5a5a5", "B c #a7a7a7", "V c Gray66", "C c #a9a9a9", "Z c #acacac", "A c #aeaeae", "S c #afafaf", "D c Gray69", "F c #b1b1b1", "G c #b2b2b2", "H c Gray70", "J c #b4b4b4", "K c #b7b7b7", "L c Gray72", "P c #bbbbbb", "I c #c0c0c0", "U c #c1c1c1", "Y c #c3c3c3", "T c Gray77", "R c #c8c8c8", "E c Gray80", "W c Gray82", "Q c #d3d3d3", "! c Gray83", "~ c #d8d8d8", "^ c #dadada", "/ c Gray86", "( c #dddddd", ") c Gray88", "_ c #e4e4e4", "` c Gray90", "' c Gray91", "] c Gray93", "[ c #f1f1f1", "{ c Gray97", "} c Gray98", "| c #fdfdfd", " . c Gray100", /* pixels */ "} } } } } } } } } } } } } } } } } } } } } } } } } } ' } ' ' ' ' ' ' ' ' ~ ~ ~ ~ ~ ~ ~ R ~ R R R R R L R L L L L L V L V V V V c ", "} } } } } } } } } } } } } } } } } } } } } } } ' } ' } ' } ' ' ' ' ' ~ ' ' ~ ~ ~ ~ R ~ R R R R R R L R L L L L V L V V V V V c c ", "} } } } } } } } } } } } } } } } } } } } } } } } } ' } ' ' ' ' ' ' ' ~ ~ ~ ~ ~ ~ ~ R ~ R ~ R R R L R L L L L L L V L V V c c V c ", "} } } } } } } } } } } } } } } } } } } } } } ' ' } ' ' } ' ' ' ' ~ ~ ' ~ ~ ~ ~ ~ R ~ R R R R R L R L L L L L L V V V V c V c c c ", "} } } } } } } } } } } } } } } } } } } } ' } } ' } ' ' ' ' ' ' ' ' ~ ~ ~ ~ ~ R ~ R R R R R L R L L L L L L V V L V V V c c c c s ", "} } } } } } } } } } } } } } } } } } } } } ' } ' } ' ' ' ' ' ~ ~ ~ ~ ~ ~ ~ ~ ~ R ~ R R R R R L R L L L L V L V V c V c c c c s c ", "} } } } } } . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .b c c c c s s ", "} } } } } } .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b c c c s s s ", "} } } } } } .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b c s s c s s ", "} } } } } } .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b s c s s s w ", "} } } } } } .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b c s s s s w ", "} } } } } } .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b s s s w w w ", "} } } } } } .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b s s w s w w ", "} } } } } } .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b w s w w w w ", "} } } } } } .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b s w w w w 5 ", "} } } } } } .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b w w w w w 5 ", "} } } } } } .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b s w w 5 5 5 ", "} } } } } } .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b w 5 w 5 5 5 ", "} } } } } } .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b w 5 5 5 5 5 ", "} } } } } } .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b 5 w 5 5 5 , ", "} } } } ' } .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b 5 5 5 , 5 , ", "} } } } } ' .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b 5 5 5 5 , , ", "} } ' } } ' .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b 5 , , , , , ", "} } } ' } ' .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b 5 5 5 , , , ", "} ' } ' } ' .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b , , , , = , ", "' } } ' ' } .b b b b b b b b b b b b b b b b b b b b b b b b b p y p p r p p y p p r p p y p p r p p b b b b b b , , , , = = ", "} ' ' } ' ' .b b b b b b b b b b b b b b b b b b b b b b b i t 3 { [ } { } { } { [ { } { [ } { [ { y b b b b b b , , = , = = ", "' } ' ' ' ' .b b b b b b b b b b b b b b b b b b b b b i * 2 0 8 J | { } { } { } | | [ | | { | | { r b b b b b b , , = = = = ", "' } ' ' ' ' .b b b b b b b b . . . . . p r b b b b 1 % 4 A A 7 & G ( } } } | } { } | | { } | } ! M p b b b b b b = , = = = @ ", "' ' ' ' ' ' .b b b b b b b b . . . . . } [ 6 d : 2 e m A K F Q m # l J ^ } { } } } { } | } ` k N } r b b b b b b = = = = = @ ", "' ' ' ' ' ' .b b b b b b b b . . . . . { } , 4 b m f F K S F F / Q s : < I U | } { } | ' n n } } { p b b b b b b = = = @ @ @ ", "' ' ' ~ ' ~ .b b b b b b b b . . . . . } { q C v l k f F K K B 9 u / H z D W g U | _ n g } } { | } y b b b b b b = = @ = @ @ ", "' ' ' ' ~ ' .b b b b b b b b . . . . . } } q z x x k v d e 1 2 $ , - - > i ) } ! p Z { } Z | } | [ p b b b b b b = = @ @ @ @ ", "' ' ' ~ ~ ~ .b b b b b b b b . . . . . } { 8 m h j z x m h p s y } E ) G T } { } } } } { _ v [ | | p b b b b b b @ @ @ @ @ + ", "' ~ ~ ' ~ ~ .b b b b b b b b . . . . . [ } 8 m m b h n k j x C r | | } P | [ | } } { | } | ] M | [ p b b b b b b @ = @ + @ + ", "~ ' ~ ~ ~ ~ .b b b b b b b b . . . . . { | q s 2 2 a z z z e 2 i } _ n } { | | } { } } { } { _ M } i b b b b b b @ @ @ @ + + ", "~ ' ~ ~ ~ ~ .b b b b b b b b . . . . . | } & 1 s s , , , ; 8 s r } Y } | } } { } | } } } | } } } ! y b b b b b b @ @ + + @ + ", "~ ~ ~ ~ ~ ~ .b b b b b b b b . . . . . } { 0 b b b b b b b b b i y r i y p y p y p r p p y i r p p r b b b b b b + @ + + + + ", "~ ~ ~ R ~ R .b b b b b b b b . . . . . i r b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b + @ + + + O ", "~ ~ ~ ~ R R .b b b b b b b b . . o . . b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b + + + + O + ", "~ R R ~ R ~ .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b + + + + O O ", "~ ~ R R R R .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b + + O O O O ", "R ~ R R R R .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b + + O + O O ", "~ R R R R R .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b + O O O O O ", "R R R R L R .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b O O O O X O ", "R R R R R L .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b O O O O X X ", "R R R L L R .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b O O X O X X ", "R R L R L L .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b O O X O X X ", "R L L L L L .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b X O X X X X ", "R L R L L L .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b O X X X X X ", "L L L L L V .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b O X X X X X ", "R L L L L L .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b X X X X X X ", "L L L V V V .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b X X X X X X ", "L L L L L V .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b X X X X X X ", "L V V V V V .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b X X X X X X ", "L L V L V V .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b X X X X X X ", "V L V V V V .b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b X X X X X X ", "V V V V c V b X X X X X X ", "V V V V c c c c c s s s s w s w w 5 w 5 5 5 5 5 , , , , = , = = @ = @ @ @ @ + + + + + + O O O O X X X X X X X X X X X X X X X X ", "V V c V c c c s c s s s s w w w w w 5 5 5 5 5 , , , , , = = = = = @ @ @ @ + @ + + + O + O O O O O X O X X X X X X X X X X X X X ", "V V c c c c c s s s s w s w w w 5 5 5 5 5 , , , , , = , = = = @ @ @ @ @ + + + + + + O O O O X X O X X X X X X X X X X X X X X X ", "c V c c c s c s s s s w w w w 5 w 5 5 5 5 , 5 , , , = = = = @ = @ @ @ + @ + + + + O O O O O O X X X X X X X X X X X X X X X X X ", "c c c c c s s s s w s w w 5 w 5 5 5 5 , , , , , = , = = = @ @ @ @ + @ + + + + O O O O O X X O X X X X X X X X X X X X X X X X X ", "c c c s c s s s s w w w w w 5 5 5 , 5 5 , , , , = = = = @ = @ @ @ @ + + + O + + O O O O O X X X X X X X X X X X X X X X X X X X " };