Author: glen                         Date: Fri Dec  1 11:09:18 2006 GMT
Module: SOURCES                       Tag: AC-branch
---- Log message:
- v0.28 copied from r1.337

---- Files affected:
SOURCES:
   adapter.awk (1.3 -> 1.3.6.1) 

---- Diffs:

================================================================
Index: SOURCES/adapter.awk
diff -u SOURCES/adapter.awk:1.3 SOURCES/adapter.awk:1.3.6.1
--- SOURCES/adapter.awk:1.3     Tue Jan  6 15:27:51 2004
+++ SOURCES/adapter.awk Fri Dec  1 12:09:12 2006
@@ -1,34 +1,61 @@
 #!/bin/awk -f
 #
-# This is adapter v0.27. Adapter adapts .spec files for PLD.
+# This is adapter v0.28. Adapter adapts .spec files for PLD Linux.
+# $Id$
 #
-# Copyright (C) 1999-2003 PLD-Team <[EMAIL PROTECTED]>
+# Copyright (C) 1999-2006 PLD-Team <[EMAIL PROTECTED]>
 # Authors:
 #      Michał Kuratczyk <[EMAIL PROTECTED]>
 #      Sebastian Zagrodzki <[EMAIL PROTECTED]>
 #      Tomasz Kłoczko <[EMAIL PROTECTED]>
-#      Artur Frysiak <[EMAIL PROTECTED]>
+#      Artur Frysiak <[EMAIL PROTECTED]>
 #      Michal Kochanowicz <[EMAIL PROTECTED]>
+#      Elan Ruusamä¤e <[EMAIL PROTECTED]>
+#
+# See cvs log adapter{,.awk} for list of contributors
+#
 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 
+# TODO
+# - parse ../PLD-doc/BuildRequires.txt and setup proper BR epoches?
+# - add "-nc" option to skip CVS interaction
+# - sort Summary(XX)
+# - sort Requires, BuildRequires
+# - check if %description (lang=C) contains 8bit
+# - desc wrapping is totally fucked up on global.spec,1.25, dosemu.spec,1.115-
+
 BEGIN {
-       preamble = 1            # Is it part of preamble? Default - yes
-       boc = 4                 # Beggining of %changelog
-       bod = 0                 # Beggining of %description
-       tw = 70                 # Descriptions width
-       
+       RPM_SECTIONS = 
"package|build|changelog|clean|description|install|post|posttrans|postun|pre|prep|pretrans|preun|triggerin|triggerpostun|triggerun|verifyscript|check"
+       SECTIONS = "^%(" RPM_SECTIONS ")"
+
+       PREAMBLE_TAGS = 
"(Summary|Name|Version|Release|Epoch|License|Group|URL|BuildArch|BuildRoot|Obsoletes|Conflicts|Provides|ExclusiveArch|ExcludeArch|Pre[Rr]eq|(Build)?Requires)"
+
+       preamble = 1    # Is it part of preamble? Default - yes
+       boc = 4                 # Beginning of %changelog
+       bod = 0                 # Beginning of %description
+       tw = 70                 # Descriptions width
+
+       b_idx = 0               # index of BR/R arrays
+    BR_count = 0   # number of additional BuildRequires
+
        # If variable removed, then 1 (for removing it from export)
        removed["LDFLAGS"] = 0
        removed["CFLAGS"] = 0
        removed["CXXFLAGS"] = 0
 
+       # get cvsaddress for changelog section
+       # using rpm macros as too lazy to add ~/.adapterrc parsing support.
+       "rpm --eval '%{?_cvsmaildomain}%{!?_cvsmaildomain:@pld-linux.org}'" | 
getline _cvsmaildomain
+       "rpm --eval '%{?_cvsmailfeedback}%{!?_cvsmailfeedback:PLD Team <[EMAIL 
PROTECTED]>}'" | getline _cvsmailfeedback
+
        # If 1, we are inside of comment block (started with /^#%/)
        comment_block = 0
-       
+
        # File with rpm groups
        "rpm --eval %_sourcedir" | getline groups_file
        groups_file = groups_file "/rpm.groups"
-       system("cd `rpm --eval %_sourcedir`; cvs up rpm.groups >/dev/null")
+       system("cd `rpm --eval %_sourcedir`; [ -f rpm.groups ] || cvs up 
rpm.groups >/dev/null")
+       system("[ -d ../PLD-doc ] && cd ../PLD-doc && ([ -f BuildRequires.txt ] 
|| cvs up BuildRequires.txt >/dev/null)");
 
        # Temporary file for changelog section
        changelog_file = ENVIRON["HOME"] "/tmp/adapter.changelog"
@@ -43,6 +70,30 @@
        "rpm --eval %_includedir" | getline includedir
        "rpm --eval %_mandir"   | getline mandir
        "rpm --eval %_infodir"  | getline infodir
+       "rpm --eval %_examplesdir"      | getline examplesdir
+       "rpm --eval %_defaultdocdir"    | getline docdir
+       "rpm --eval %_desktopdir" | getline desktopdir
+       "rpm --eval %_pixmapsdir" | getline pixmapsdir
+
+       "rpm --eval %perl_sitearch" | getline perl_sitearch
+       "rpm --eval %perl_archlib" | getline perl_archlib
+       "rpm --eval %perl_privlib" | getline perl_privlib
+       "rpm --eval %perl_vendorlib" | getline perl_vendorlib
+       "rpm --eval %perl_vendorarch" | getline perl_vendorarch
+       "rpm --eval %perl_sitelib" | getline perl_sitelib
+
+       "rpm --eval %py_sitescriptdir 2>/dev/null" | getline py_sitescriptdir
+       "rpm --eval %py_sitedir 2>/dev/null" | getline py_sitedir
+       "rpm --eval %py_scriptdir 2>/dev/null" | getline py_scriptdir
+
+       "rpm --eval %ruby_archdir" | getline ruby_archdir
+       "rpm --eval %ruby_ridir" | getline ruby_ridir
+       "rpm --eval %ruby_rubylibdir" | getline ruby_rubylibdir
+       "rpm --eval %ruby_sitearchdir" | getline ruby_sitearchdir
+       "rpm --eval %ruby_sitelibdir" | getline ruby_sitelibdir
+
+       "rpm --eval %php_pear_dir" | getline php_pear_dir
+       "rpm --eval %tmpdir" | getline tmpdir
 }
 
 # There should be a comment with CVS keywords on the first line of file.
@@ -57,13 +108,49 @@
 
 # If the latest line matched /%files/
 defattr == 1 {
-       if ($0 !~ /defattr/)    # If no %defattr
-               print "%defattr(644,root,root,755)"     # Add it
-       else
-               $0 = "%defattr(644,root,root,755)"      # Correct mistakes (if 
any)
+       if (ENVIRON["SKIP_DEFATTR"] != 1) {
+               if ($0 !~ /defattr/) {  # If no %defattr
+                       print "%defattr(644,root,root,755)"     # Add it
+               } else {
+                       $0 = "%defattr(644,root,root,755)"      # Correct 
mistakes (if any)
+               }
+       }
        defattr = 0
 }
 
+function b_makekey(a, b,       s) {
+       s = a "" b;
+       # kill bcond
+    gsub(/[#%]+{[!?]+[_a-zA-Z0-9]+:/, "", s);
+
+       # kill commented out items
+    gsub(/^#[ \t]*/, "", s);
+
+       # force order
+    gsub(/^Summary\(/, "11Summary(", s);
+    gsub(/^Summary/, "10Summary", s);
+    gsub(/^Name/, "2Name", s);
+    gsub(/^Version/, "3Version", s);
+    gsub(/^Release/, "4Release", s);
+    gsub(/^Epoch/, "5Epoch", s);
+    gsub(/^License/, "5License", s);
+    gsub(/^Group/, "6Group", s);
+    gsub(/^URL/, "7URL", s);
+
+    gsub(/^BuildRequires/, "B1BuildRequires", s);
+    gsub(/^BuildConflicts/, "B2BuildConflicts", s);
+    gsub(/^Provides/, "X1Provides", s);
+    gsub(/^Obsoletes/, "X2Obsoletes", s);
+    gsub(/^Conflicts/, "X3Conflicts", s);
+    gsub(/^BuildArch/, "X4BuildArch", s);
+    gsub(/^ExclusiveArch/, "X6ExclusiveArch", s);
+    gsub(/^ExcludeArch/, "X7ExcludeArch", s);
+    gsub(/^BuildRoot/, "X9BuildRoot", s);
+
+#      printf("%s -> %s\n", a""b, s);
+       return s;
+}
+
 # Comments
 /^#/ && (description == 0) {
        if (/This file does not like to be adapterized!/) {
@@ -76,22 +163,110 @@
 
        # Generally, comments are printed without touching
        sub(/[ \t]+$/, "")
-       print $0
-       next
+
+       if (/Source.*md5/) {
+               print $0
+               next
+       }
 }
 
-# Remove defining _applnkdir (this macro has been included in rpm-3.0.4)
 /^%define/ {
-       if ($2 == "_applnkdir")
+       # Remove defining _applnkdir (this macro has been included in rpm-3.0.4)
+       if ($2 == "_applnkdir") {
                next
-       if ($2 == "date")
+       }
+       if ($2 == "date") {
                date = 1
+               if (did_files == 0) {
+                       print "%files"
+                       print ""
+                       did_files = 1
+               }
+       }
+
+       # Do not add %define of _prefix if it already is.
+       if ($2 ~ /^_prefix/) {
+               sub("^"prefix, $3, bindir)
+               sub("^"prefix, $3, sbindir)
+               sub("^"prefix, $3, libdir)
+               sub("^"prefix, $3, datadir)
+               sub("^"prefix, $3, includedir)
+               prefix = $3
+       }
+
+       if ($2 ~ /_bindir/ && !/_sbindir/)
+               bindir = $3
+       if ($2 ~ /_sbindir/)
+               sbindir = $3
+       if ($2 ~ /_libdir/) {
+               if ($3 ~ /^%\(/) {
+                       # TODO: should escape for latter checks like: ($c ~ 
sysconfdir "/{?cron.")
+                       libdir = "%%%%%%%%%%%%%%"
+               } else {
+                       libdir = $3
+               }
+       }
+       if ($2 ~ /_sysconfdir/) {
+               if ($3 ~ /^%\(/) {
+                       # TODO: should escape for latter checks like: ($c ~ 
sysconfdir "/{?cron.")
+                       sysconfdir = "%%%%%%%%%%%%%%"
+               } else {
+                       sysconfdir = $3
+               }
+       }
+       if ($2 ~ /_datadir/) {
+               if ($3 ~ /^%\(/) {
+                       # TODO: should escape for latter checks like: ($c ~ 
sysconfdir "/{?cron.")
+                       datadir = "%%%%%%%%%%%%%%"
+               } else {
+                       datadir = $3
+               }
+       }
+       if ($2 ~ /_includedir/)
+               includedir = $3
+       if ($2 ~ /_mandir/)
+               mandir = $3
+       if ($2 ~ /_infodir/)
+               infodir = $3
+       if ($2 ~ /_docdir/)
+               docdir = $3
+
+       # version related macros
+       if ($2 ~ /^_beta$/)
+               _beta = $3
+       if ($2 ~ /^_rc$/)
+               _rc = $3
+       if ($2 ~ /^_pre$/)
+               _pre = $3
+       if ($2 ~ /^_snap$/)
+               _snap = $3
+
+       # these are used usually when adapterizing external spec
+       if ($2 ~ /^name$/)
+               name = $3
+       if ($2 ~ /^version$/)
+               version = $3
+       if ($2 ~ /^release$/)
+               release = $3
+
+       if ($2 ~ /^mod_name$/)
+               mod_name = $3
+
+       sub(/[ \t]+$/, "");
+       # do nothing further, otherwise adapter thinks we're at preamble
+       print
+       next
+}
+
+# Obsolete
+/^%include.*\/usr\/lib\/rpm\/macros\.python$/ {
+       next
 }
 
 ################
 # %description #
 ################
-/^%description/, (/^%[a-z]+/ && !/^%description/) {
+/^%description/, (!/^%description/ && $0 ~ SECTIONS) {
        preamble = 0
 
        if (/^%description/) {
@@ -100,16 +275,8 @@
                format_indent = -1
        }
 
-       # Define _prefix and _mandir if it is X11 application
-#      if (/^%description$/ && x11 == 1) {
-#              print "%define\t\t_prefix\t\t/usr/X11R6"
-#              print "%define\t\t_mandir\t\t%{_prefix}/man\n"
-#              prefix = "/usr/X11R6"
-#              x11 = 2
-#      }
-       
        # Format description
-       if (description == 1 && !/^%[a-z]+/ && !/^%description/) {
+       if (ENVIRON["SKIP_DESC"] != 1 && description == 1 && !/^%[a-z]+/ && 
!/^%description/) {
                if (/^[ \t]*$/) {
                        format_flush(format_line, format_indent)
                        print ""
@@ -117,15 +284,15 @@
                        format_indent = -1
                } else if (/^[ \t]*[-\*][ \t]*/) {
                        format_flush(format_line, format_indent)
-                       match($0, /^[ \t]*/)    
+                       match($0, /^[ \t]*/)
                        format_indent = RLENGTH
                        match($0, /^[ \t]*[-\*][ \t]/)
                        format_line = substr($0, RLENGTH)
-               } else 
+               } else
                        format_line = format_line " " $0
                next
        }
- 
+
        if (/^%[a-z]+/ && (!/^%description/ || bod == 2)) {
                if (NF > 3 && $2 == "-l") {
                        ll = $1
@@ -148,22 +315,58 @@
 #########
 # %prep #
 #########
-/^%prep/, (/^%[a-z]+$/ && !/^%prep/) {
+/^%prep/, (!/^%prep/ && $0 ~ SECTIONS) {
        preamble = 0
-       
+       did_prep = 1
+
+       use_macros()
+
        # Add '-q' to %setup
-       if (/^%setup/ && !/-q/)
+       if (/^%setup/ && !/-q/) {
                sub(/^%setup/, "%setup -q")
+       }
+
+       if (/^%setup/ && name != "setup") {
+               $0 = fixedsub(name, "%{name}", $0);
+               $0 = fixedsub(version, "%{version}", $0);
+               if (_beta) {
+                       $0 = fixedsub(_beta, "%{_beta}", $0);
+               }
+               if (_rc) {
+                       $0 = fixedsub(_rc, "%{_rc}", $0);
+               }
+               if (_pre) {
+                       $0 = fixedsub(_pre, "%{_pre}", $0);
+               }
+               if (_snap) {
+                       $0 = fixedsub(_snap, "%{_snap}", $0);
+               }
+       }
+
+       if (/^%setup/ && /-n %{name}-%{version}( |$)/) {
+               $0 = fixedsub(" -n %{name}-%{version}", "", $0)
+       }
+    sub("^%patch ", "%patch0 ");
+
+       # invalid in %prep
+       sub("^rm -rf \$RPM_BUILD_ROOT.*", "");
 }
 
 ##########
 # %build #
 ##########
-/^%build/, (/^%[a-z]+$/ && !/^%build/) {
+/^%build/, (!/^%build/ && $0 ~ SECTIONS) {
        preamble = 0
 
+       if (did_prep == 0) {
+               print "%prep"
+               print ""
+               did_prep = 1
+       }
+
        use_macros()
-       
+       use_tabs()
+
        if (/^automake$/)
                sub(/$/, " -a -c")
 
@@ -190,7 +393,7 @@
        if (/CXXFLAGS=/)
                if (cflags("CXXFLAGS") == 0)
                        next
-       
+
        if (/^export /) {
                if (removed["LDFLAGS"])
                        sub(" LDFLAGS", "")
@@ -202,24 +405,53 @@
                if (/^export[ ]*$/)
                        next
        }
-                       
+
+       # quote CC
+       if (/CC=%{__cc} /) {
+               sub("CC=%{__cc}", "CC=\"%{__cc}\"")
+       }
+       
+       # use PLD Linux macros
+       $0 = fixedsub("glib-gettextize --copy --force","%{__glib_gettextize}", 
$0);
+       $0 = fixedsub("intltoolize --copy --force", "%{__intltoolize}", $0);
+       $0 = fixedsub("automake --add-missing --copy", "%{__automake}", $0);
+       $0 = fixedsub("automake -a --foreign --copy", "%{__automake}", $0);
+       $0 = fixedsub("automake -a -c --foreign", "%{__automake}", $0);
+       $0 = fixedsub("libtoolize --force --automake --copy", 
"%{__libtoolize}", $0);
+       $0 = fixedsub("libtoolize -c -f --automake", "%{__libtoolize}", $0);
+
+       sub(/^aclocal$/, "%{__aclocal}");
+       sub(/^autoheader$/, "%{__autoheader}");
+       sub(/^autoconf$/, "%{__autoconf}");
+       sub(/^automake$/, "%{__automake}");
+
+       # atrpms
+       $0 = fixedsub("%perl_configure", "%{__perl} Makefile.PL 
\\\n\tINSTALLDIRS=vendor", $0);
+       $0 = fixedsub("%perl_makecheck", "%{?with_tests:%{__make} test}", $0);
 }
 
 ##########
 # %clean #
 ##########
-/^%clean/, (/^%[a-z]+$/ && !/^%clean/) {
+/^%clean/, (!/^%clean/ && $0 ~ SECTIONS) {
        did_clean = 1
+
+    use_macros()
 }
 
 ############
 # %install #
 ############
-/^%install/, (/^%[a-z]+$/ && !/^%install/) {
-       
+/^%install/, (!/^%install/ && $0 ~ SECTIONS) {
+
        preamble = 0
-       
-       if (/^[ \t]*rm([ \t]+-[rf]+)*[ \t]+\${?RPM_BUILD_ROOT}?/ && 
did_rmroot==0) {
+
+       # foreign rpms
+       sub("^%{__rm} -rf %{buildroot}", "rm -rf $RPM_BUILD_ROOT")
+    sub("%buildroot", "$RPM_BUILD_ROOT");
+    sub("%{buildroot}", "$RPM_BUILD_ROOT");
+
+       if (/^[ \t]*rm([ \t]+-[rf]+)*[ 
\t]+(\${?RPM_BUILD_ROOT}?|%{?buildroot}?)/ && did_rmroot==0) {
                did_rmroot=1
                print "rm -rf $RPM_BUILD_ROOT"
                next
@@ -229,53 +461,68 @@
                print "rm -rf $RPM_BUILD_ROOT"
                did_rmroot=1
        }
-       
+
+    if (tmpdir) {
+        buildroot = tmpdir "/" name "-" version "-root-" ENVIRON["USER"]
+               gsub(buildroot, "$RPM_BUILD_ROOT")
+    }
+
+    if (!/%{_lib}/) {
+        sub("\$RPM_BUILD_ROOT/%", "$RPM_BUILD_ROOT%")
+    }
+
        use_macros()
-       
+
        # 'install -d' instead 'mkdir -p'
        if (/mkdir -p/)
                sub(/mkdir -p/, "install -d")
-               
+
+       # cp -a already implies cp -r
+    sub(/^cp -ar/, "cp -a")
+
        # No '-u root' or '-g root' for 'install'
        if (/^install/ && /-[ug][ \t]*root/)
                gsub(/-[ug][ \t]*root /, "")
-       
-       if (/^install/ && /-m[ \t]*644/)
-               gsub(/-m[ \t]*644 /, "")
-       
+
+       if (/^install/ && /-m[ \t]*[0-9]+/)
+               gsub(/-m[ \t]*[0-9]+ /, "")
+
        # No lines contain 'chown' or 'chgrp' if owner/group is 'root'
        if (($1 ~ /chown/ && $2 ~ /root\.root/) || ($1 ~ /chgrp/ && $2 ~ 
/root/))
                next
-       
+
        # No lines contain 'chmod' if it sets the modes to '644'
        if ($1 ~ /chmod/ && $2 ~ /644/)
                next
+
+       # atrpms
+       $0 = fixedsub("%perl_makeinstall", "%{__make} pure_install 
\\\n\tDESTDIR=$RPM_BUILD_ROOT", $0);
 }
 
 ##########
 # %files #
 ##########
-/^%files/, (/^%[a-z \-]+$/ && !/^%files/) {
+/^%files/, (!/^%files/ && $0 ~ SECTIONS) {
        preamble = 0
-       
+       did_files = 1
+
        if ($0 ~ /^%files/)
                defattr = 1
-       
-       use_macros()
+
        use_files_macros()
 }
 
 ##############
 # %changelog #
 ##############
-/^%changelog/, (/^%[a-z]+$/ && !/^%changelog/) {
+/^%changelog/, (!/^%changelog/ && $0 ~ SECTIONS) {
        preamble = 0
        has_changelog = 1
        skip = 0
        # There should be some CVS keywords on the first line of %changelog.
        if (boc == 3) {
-               if (!/PLD Team/)
-                       print "* %{date} PLD Team <[EMAIL PROTECTED]>" > 
changelog_file
+               if ($0 !~ _cvsmailfeedback)
+                       print "* %{date} " _cvsmailfeedback > changelog_file
                else
                        skip = 1
                boc = 2
@@ -283,7 +530,7 @@
        if (boc == 2 && !skip) {
                if (!/All persons listed below/) {
                        printf "All persons listed below can be reached at " > 
changelog_file
-                       print "<cvs_login>@pld-linux.org\n" > changelog_file
+                       print "<cvs_login>" _cvsmaildomain "\n" > changelog_file
                } else
                        skip = 1
                boc = 1
@@ -316,17 +563,62 @@
 ###########
 # SCRIPTS #
 ###########
-/^%pre/, (/^%[a-z]+$/ && !/^%pre/) {
+/^%pre/, (!/^%pre/ && $0 ~ SECTIONS) {
        preamble = 0
+
+       if (gsub("/usr/sbin/useradd", "%useradd")) {
+               sub(" 2> /dev/null \|\| :", "");
+               sub(" >/dev/null 2>&1 \|\|:", "");
+       }
+
+       # %useradd and %groupadd may not be wrapped
+       if (/%(useradd|groupadd).*\\$/) {
+               a = $0; getline;
+               sub(/^[\s\t]*/, "");
+               $0 = substr(a, 1, length(a) - 1) $0;
+       }
+       use_script_macros()
 }
-/^%post/, (/^%[a-z]+$/ && !/^%post/) {
+
+/^%post/, (!/^%post/ && $0 ~ SECTIONS) {
        preamble = 0
+       use_macros()
 }
-/^%preun/, (/^%[a-z]+$/ && !/^%preun/) {
+/^%preun/, (!/^%preun/ && $0 ~ SECTIONS) {
        preamble = 0
+       use_script_macros()
 }
-/^%postun/, (/^%[a-z]+$/ && !/^%postun/) {
+/^%postun/, (!/^%postun/ && $0 ~ SECTIONS) {
        preamble = 0
+       use_script_macros()
+}
+/^%triggerin/, (!/^%triggerin/ && $0 ~ SECTIONS) {
+       preamble = 0
+       use_script_macros()
+}
+/^%triggerun/, (!/^%triggerun/ && $0 ~ SECTIONS) {
+       preamble = 0
+       use_script_macros()
+}
+/^%triggerpostun/, (!/^%triggerpostun/ && $0 ~ SECTIONS) {
+       preamble = 0
+       use_script_macros()
+}
+/^%pretrans/, (!/^%pretrans/ && $0 ~ SECTIONS) {
+       preamble = 0
+       use_script_macros()
+}
+/^%posttrans/, (!/^%posttrans/ && $0 ~ SECTIONS) {
+       preamble = 0
<<Diff was trimmed, longer than 597 lines>>

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/adapter.awk?r1=1.3&r2=1.3.6.1&f=u

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to