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
|