[devel] I: specfile cleaner
Dmitry V. Levin
=?iso-8859-1?q?ldv_=CE=C1_fandra=2Eorg?=
Вс Янв 14 04:20:17 MSK 2001
Greetings!
Если Вы собираете пакеты, то небольшой "чистильщик" spec-файлов не
повредит.
usage: cleanup_spec specfile1 [specfileN]*
Regards,
Dmitry
+-------------------------------------------------------------------------+
Dmitry V. Levin mailto://ldv@fandra.org
Software Engineer PGP pubkey http://www.fandra.org/users/ldv/pgpkeys.html
IPLabs Linux Team http://linux.iplabs.ru
Fandra Project http://www.fandra.org
+-------------------------------------------------------------------------+
UNIX is user friendly. It's just very selective about who its friends are.
----------- следующая часть -----------
#!/bin/sh -e
PROG="${0##*/}"
: "${TMPDIR:=$HOME/tmp}"
TMPFILE="$(mktemp "$TMPDIR/$PROG.XXXXXX")"
Exit()
{
RETVAL=$?
trap "" EXIT
rm -f "$TMPFILE"
exit $RETVAL
}
trap "Exit " SIGHUP SIGPIPE SIGINT SIGTERM EXIT
RemoveEmpty()
{
awk 'BEGIN{empty=0} /^.+$/{empty=0} /^$/{if(!empty){print;empty=1}} {if(!empty)print $0}' <$1 >"$TMPFILE" &&
cat "$TMPFILE" >"$1"
}
RemoveClean()
{
awk 'BEGIN{clean=0} {printed=0} /^%(pre|post|trig|files|changelog)/{clean=0} /^./{if(clean){print "%clean";clean=0}} /^%clean$/{clean=1;printed=1} /^$/{if(clean){printed=1}} {if(!printed)print $0}' <$1 >"$TMPFILE" &&
cat "$TMPFILE" >"$1"
}
CleanFiles()
{
awk 'BEGIN{found=0} {printed=0} /^./{found=0} /^%(description|prep|build|install|pre|post|trig|files|changelog)([^_]|$)/{found=1} /^%(pre|post|trig).*[ ]-p[ ]/{found=0} /^$/{if(found)printed=1} {if(!printed)print $0}' <$1 >"$TMPFILE" &&
cat "$TMPFILE" >"$1"
}
for F in "$@"; do
perl -pi -e 's/%\{([A-Za-z_0-9]+)\}([^A-Za-z_0-9]|$)/%$1$2/g' "$F"
perl -pi -e 's/%\{([A-Za-z_0-9]+)\}([^A-Za-z_0-9]|$)/%$1$2/g' "$F"
perl -pi -e 's/%\{([A-Za-z_0-9]+)\}([^A-Za-z_0-9]|$)/%$1$2/g' "$F"
perl -pi -e 's/[ ]+$//g' "$F"
perl -pi -e 's/^([A-Za-z_0-9]+:)[ ]+/\1 /g' "$F"
perl -pi -e 's/^%make\s+/%make_build /g;s/%_prefix/%prefix/g;s/%_initrddir/%_initdir/g;s/%_install_info/%install_info/g;s/%_remove_install_info/%uninstall_info/g' "$F"
perl -pi -e 's/^prereq: /PreReq: /ig;s/^buildrequires: /BuildRequires: /ig;s/^buildprereq: /BuildPreReq: /ig' "$F"
perl -pi -e 's/^buildroot: .*//ig' "$F"
perl -pi -e 's/^rm\s+-rf\s+"?\$RPM_BUILD_ROOT"?$//g' "$F"
perl -pi -e 's/^%defattr\s*\(\s*-\s*,\s*root\s*,\s*root\s*(,\s*(-|0?755)\s*)?\)//g' "$F"
RemoveEmpty "$F"
RemoveClean "$F"
CleanFiles "$F"
done
----------- следующая часть -----------
Было удалено вложение не в текстовом формате...
Имя : =?iso-8859-1?q?=CF=D4=D3=D5=D4=D3=D4=D7=D5=C5=D4?=
Тип : application/pgp-signature
Размер : 232 байтов
Описание: =?iso-8859-1?q?=CF=D4=D3=D5=D4=D3=D4=D7=D5=C5=D4?=
Url : <http://lists.altlinux.org/pipermail/devel/attachments/20010114/a7414d65/attachment-0001.bin>
Подробная информация о списке рассылки Devel