[packages/adapter: 60/631] - -f switch for rm and mv in %pre/%post

glen glen at pld-linux.org
Mon Sep 12 19:39:29 CEST 2016


commit 472bd83fb064ff1ea1397c5eaa6302dcfffec2d2
Author: Sebastian Zagrodzki <sebek at zagrodzki.net>
Date:   Mon Jun 19 10:40:26 2000 +0000

    - -f switch for rm and mv in %pre/%post
    
    Changed files:
        adapter.awk -> 1.60

 adapter.awk | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)
---
diff --git a/adapter.awk b/adapter.awk
index ce1c6fa..7685cf0 100644
--- a/adapter.awk
+++ b/adapter.awk
@@ -176,11 +176,32 @@ defattr == 1 {
 }
 
 # Scripts
-/^%pre /, (/^[a-z]+$/ && !/^%pre /) { preamble = 0 }
-/^%preun/, (/^[a-z]+$/ && !/^%preun/) { preamble = 0 }
-/^%post /, (/^[a-z]+$/ && !/^%post /) {	preamble = 0 }
-/^%postun/, (/^[a-z]+$/ && !/^%postun/) { preamble = 0 }
-	
+script = 0
+/^%pre/, (/^[a-z]+$/ && !/^%pre/) { script = 1 }
+/^%preun/, (/^[a-z]+$/ && !/^%preun/) { script = 1 }
+/^%post/, (/^[a-z]+$/ && !/^%post/) {	script = 1 }
+/^%postun/, (/^[a-z]+$/ && !/^%postun/) { script = 1 }
+script == 1 {
+	preamble = 0
+	if ($1 ~ /^mv$/) {
+		if ($2 ~ /^-/)
+			sub(/-[A-Za-z0-9]+ /, "", $0)
+		sub($1, "mv -f")
+	}
+	if ($1 ~ /^rm$/) {
+		recursive = 0
+		if ($2 ~ /^-/) {
+			if (match($2, "r"))
+				recursive = 1
+			sub(/-[A-Za-z0-9]+ /, "", $0)
+		}
+		if (recursive)
+			sub($1, "rm -rf")
+		else
+			sub($1, "rm -f")
+	}
+}
+
 # %files section:
 /^%files/, (/^%[a-z \-]+$/ && !/^%files/) {
 	preamble = 0
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/adapter.git/commitdiff/6ca0126d4d0c8c79feb7db10b0a0fade0f3b8885



More information about the pld-cvs-commit mailing list