ALT Linux Team development discussions
 help / color / mirror / Atom feed
* [devel] I: specfile cleaner
@ 2001-01-14  1:20 Dmitry V. Levin
  2001-01-16  1:56 ` [devel] " Dmitry V. Levin
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry V. Levin @ 2001-01-14  1:20 UTC (permalink / raw)
  To: devel


[-- Attachment #1.1: Type: text/plain, Size: 584 bytes --]

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.

[-- Attachment #1.2: cleanup_spec --]
[-- Type: text/plain, Size: 1751 bytes --]

#!/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

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [devel] Re: I: specfile cleaner
  2001-01-14  1:20 [devel] I: specfile cleaner Dmitry V. Levin
@ 2001-01-16  1:56 ` Dmitry V. Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry V. Levin @ 2001-01-16  1:56 UTC (permalink / raw)
  To: devel


[-- Attachment #1.1: Type: text/plain, Size: 685 bytes --]

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.

[-- Attachment #1.2: cleanup_spec --]
[-- Type: text/plain, Size: 1858 bytes --]

#!/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

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-01-16  1:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-14  1:20 [devel] I: specfile cleaner Dmitry V. Levin
2001-01-16  1:56 ` [devel] " Dmitry V. Levin

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git