ec2-api-tools.spec作成スクリプト

#!/bin/sh
SOURCE=ec2-api-tools.zip
SPEC=ec2-api-tools.spec
DESTDIR=/usr

wget -q http://s3.amazonaws.com/ec2-downloads/$SOURCE -O $SOURCE
VERSION=`unzip -l ec2-api-tools.zip | awk '/ec2-api-tools-/{print $4; exit}' | sed -r 's|ec2-api-tools-([^/]+).*|\1|'`

cat <<EOF > $SPEC
Summary: Amazon EC2 API Tools
Name: ec2-api-tools
Version: $VERSION
Release: 1
License: Amazon Software License
Group: Development/Tools
Source: ec2-api-tools.zip
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildArch: noarch

%define destdir $DESTDIR
%define _unpackaged_files_terminate_build 0

%description
The API tools serve as the client interface to the Amazon EC2 web service. Use these tools to register and launch instances, manipulate security groups, and more.

%prep
%setup -q

%install
install -d \$RPM_BUILD_ROOT/%{destdir}/bin
install -d \$RPM_BUILD_ROOT/%{destdir}/lib
install -m 755 bin/* \$RPM_BUILD_ROOT/%{destdir}/bin/
install -m 644 lib/* \$RPM_BUILD_ROOT/%{destdir}/lib/

%files
EOF

unzip -l $SOURCE | awk '$4 ~ /ec2-api-tools-.+\/(bin|lib)\/.+/ && $4 !~ /\.cmd/{sub(/[^/]+/,"'$DESTDIR'",$4); print $4}' >> $SPEC