#!/bin/bash # # turn a noarch package into srpm that "builds" into it again, # but without the actual build process -- effectively to get rid # of the need for BuildRequires during bootstraps; typical use: # $ rpm -bs --nodeps $(renoarch this.noarch.rpm) # (--define '_sourcedir /path/to/noarch/RPMS' might be useful too) # # NB: scripts/triggers not carried over [so far] [ -s "$1" ] || exit 1 # mark those; mandates release bump afterwards (NB: .re > .1) SUF=".re" q() { rpm -qp --qf="$1" "$2"; } mkspec() { rpm -qp "$1" >&/dev/null || exit 2 OUT="$(basename "$1")" OUT="${OUT%.rpm}.spec" export LANG=C.UTF-8 read N V R < <(q '%{name}\t%{version}\t%{release}\n' "$1") read E < <(q '%{epoch}\n' "$1"); E="${E/(none)/}" read S < <(q '%{summary}\n' "$1") read L < <(q '%{license}\n' "$1") #read G < <(q '%{group}\n' "$1") # unused #read D < <(q '%{description}\n' "$1") # unused P="$(rpm --eval '%packager')" P="${P/\%packager/Renoar C.H. }" { cat << EOF # bootstrap spec generated by $(basename "$0") on $(date +%Y-%m-%d) Name: $N Version: $V Release: $R$SUF EOF [ -z "$E" ] || cat << EOF Epoch: $E EOF cat << EOF Summary: piggyback the needed %name version License: $L Group: Development/Other Source: $(basename "$1") BuildArch: noarch AutoReqProv: no EOF { rpm -qp --requires "$1" | grep -v '^rpmlib' | sed 's,^,Requires: ,' echo rpm -qp --provides "$1" | sed 's,^,Provides: ,' } | sed 's,:[^ ].*$,,' # drop disttag [ -z "$SUF" ] || cat << EOF Provides: $N = ${E:+$E:}$V-$R EOF cat << EOF %description %summary %prep %setup -cT rpm2cpio %SOURCE0 | cpio -id %build # any "corrective" action here %install cp -a . %buildroot %files EOF rpm -qlp "$1" | grep -v "^(" cat << EOF %changelog * $(date '+%a %b %d %Y') $P ${E:+$E:}$V-$R$SUF - bootstrap package EOF } > "$OUT" && echo "$OUT" || rm "$OUT" } # repackage for i in "$@"; do mkspec "$i"; done