From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Dmitry V. Levin" To: devel@linux.iplabs.ru Message-ID: <20010116045615.A4669@LDV.fandra.org> Mail-Followup-To: devel@linux.iplabs.ru References: <20010114042016.A6353@LDV.fandra.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qlTNgmc+xy1dBmNv" Content-Disposition: inline In-Reply-To: <20010114042016.A6353@LDV.fandra.org>; from ldv@fandra.org on Sun, Jan 14, 2001 at 04:20:16AM +0300 Subject: [devel] Re: I: specfile cleaner Sender: devel-admin@linux.iplabs.ru Errors-To: devel-admin@linux.iplabs.ru X-BeenThere: devel@linux.iplabs.ru X-Mailman-Version: 2.0 Precedence: bulk Reply-To: devel@linux.iplabs.ru List-Help: List-Post: List-Subscribe: , List-Id: IPLabs Linux Team Developers mailing list List-Unsubscribe: , List-Archive: X-Original-Date: Tue, 16 Jan 2001 04:56:15 +0300 Date: Tue, 16 Jan 2001 04:56:15 +0300 Archived-At: List-Archive: List-Post: --qlTNgmc+xy1dBmNv Content-Type: multipart/mixed; boundary="0F1p//8PRICkK4MW" Content-Disposition: inline Content-Transfer-Encoding: 8bit --0F1p//8PRICkK4MW Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: 8bit Greetings! On Sun, Jan 14, 2001 at 04:20:16AM +0300, Dmitry V. Levin wrote: > Если Вы собираете пакеты, то небольшой "чистильщик" 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. --0F1p//8PRICkK4MW Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=cleanup_spec #!/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]+:|%package|%description|%pre|%preun|%post|%postun|%files)[ ]+/\1 /g' "$F" perl -pi -e 's/^%make$/%make_build/g;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/^copyright: /License: /ig;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 --0F1p//8PRICkK4MW-- --qlTNgmc+xy1dBmNv Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE6Y6o/ZqIoNiVITrsRAiPdAJ0UGAkbt/ycL7475i67Kod4S1r8rACgxRLd iBfq3R3nEg2klloKNP5jFZc= =SPbW -----END PGP SIGNATURE----- --qlTNgmc+xy1dBmNv-- _______________________________________________ Devel mailing list Devel@linux.iplabs.ru http://www.logic.ru/mailman/listinfo/devel