From 4f40dc60c125ad1e14071c234b67315fab6c6fc3 Mon Sep 17 00:00:00 2001 From: Rob Funk Date: Fri, 18 Jun 2004 04:17:07 +0000 Subject: Move shipper to dist-tools directory svn path=/trunk/; revision=3889 --- dist-tools/shipper/rpm2lsm | 108 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100755 dist-tools/shipper/rpm2lsm (limited to 'dist-tools/shipper/rpm2lsm') diff --git a/dist-tools/shipper/rpm2lsm b/dist-tools/shipper/rpm2lsm new file mode 100755 index 00000000..6a05d6c7 --- /dev/null +++ b/dist-tools/shipper/rpm2lsm @@ -0,0 +1,108 @@ +#/bin/sh +# +# rpm2lsm -- generate Linux Software Map file from RPM meta information +# +# Author: Eric S. Raymond , 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.$$ <>/usr/tmp/rpm2lsm.$$ + fi +done + +cat >>/usr/tmp/rpm2lsm.$$ <