This is the mail archive of the cygwin-apps@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch for generic readme and generic-build script to automatically generate pkg data and file listings


All,

I am re-submitting this again ...

Based on the 1.8 version of the generic build script I would like to submit
this patch, which would allow package maintainers
to automatically update the distribution READMEs when they do a build.

FYI ... Contents of attached patch ...
<patch>
diff -ur Original/generic-build-script New/generic-build-script
--- Original/generic-build-script	2003-10-26 23:14:08.000000000 -0600
+++ New/generic-build-script	2003-11-21 17:30:10.750328000 -0600
@@ -24,6 +24,7 @@
 export VER=`echo $tscriptname | sed -e "s/${PKG}\-//" -e 's/\-[^\-]*$//'`
 export REL=`echo $tscriptname | sed -e "s/${PKG}\-${VER}\-//"`
 export FULLPKG=${PKG}-${VER}-${REL}
+export NEWVER="" # Place Holder for 'newer' version number

 # determine correct decompression option and tarball filename
 if [ -e ${PKG}-${VER}.tar.gz ] ; then
@@ -48,6 +49,7 @@
 export instdir=${srcdir}/.inst
 export srcinstdir=${srcdir}/.sinst
 export checkfile=${topdir}/${FULLPKG}.check
+
 # run on
 host=i686-pc-cygwin
 # if this package creates binaries, they run on
@@ -57,6 +59,8 @@
 MY_CFLAGS="-O2"
 MY_LDFLAGS=

+export
ThePackageReadMeFile="${instdir}${prefix}/share/doc/Cygwin/${PKG}-${VER}.REA
DME"
+
 mkdirs() {
   (cd ${topdir} && \
   rm -fr ${objdir} ${instdir} ${srcinstdir} && \
@@ -123,11 +127,11 @@
   fi && \
   if [ -f ${srcdir}/CYGWIN-PATCHES/${PKG}.README ]; then \
     /usr/bin/install -m 644 ${srcdir}/CYGWIN-PATCHES/${PKG}.README \
-      ${instdir}${prefix}/share/doc/Cygwin/${PKG}-${VER}.README ; \
+      "${ThePackageReadMeFile}" ; \
   else \
     if [ -f ${srcdir}/CYGWIN-PATCHES/README ]; then \
       /usr/bin/install -m 644 ${srcdir}/CYGWIN-PATCHES/README \
-        ${instdir}${prefix}/share/doc/Cygwin/${PKG}-${VER}.README ; \
+      "${ThePackageReadMeFile}" ; \
     fi ;\
   fi ;\
   if [ -f ${srcdir}/CYGWIN-PATCHES/postinstall.sh ] ; then \
@@ -142,9 +146,23 @@
   true )
 }
 list() {
-  (cd ${instdir} && \
-  find . -name "*" ! -type d | sed 's/\.\/\(.*\)/\1/'
-  true )
+  if [ -s "${ThePackageReadMeFile}" ]
+  then
+     TmpPackageReadMe="/tmp/$(/usr/bin/basename "${ThePackageReadMeFile}")"
+     (cd ${instdir} &&                                                  \
+      find . -name "*" | sed 's/\.\/\(.*\)/  \/\1/' |                   \
+      sed    -e "s#%PKG%#${PKG}#g"                                      \
+             -e "s#%VER%#${VER}#g"                                      \
+             -e "s#%REL%#${REL}#g"                                      \
+             -e "s#%NEWER_VER%#${NEWVER}#g"                             \
+             -e '\|%THEFILES%| e /usr/bin/cat -'                        \
+             -e '\|%THEFILES%| d'                                       \
+             "${ThePackageReadMeFile}" >                                \
+             "${TmpPackageReadMe}"         &&                           \
+      mv -f  "${TmpPackageReadMe}"                                      \
+             "${ThePackageReadMeFile}"     &&                           \
+      true )
+  fi
 }
 pkg() {
   (cd ${instdir} && \
@@ -188,7 +206,7 @@
   spkg)	spkg ; STATUS=$? ;;
   finish) finish ; STATUS=$? ;;
   all) prep && conf && build && install && \
-     strip && pkg && spkg && finish ; \
+     strip && list && pkg && spkg && finish ; \
 	  STATUS=$? ;;
   *) echo "Error: bad arguments" ; exit 1 ;;
 esac
diff -ur Original/generic-readme New/generic-readme
--- Original/generic-readme	2003-09-12 12:36:02.000000000 -0500
+++ New/generic-readme	2003-11-17 17:24:44.467372800 -0600
@@ -1,4 +1,4 @@
-<package name>
+%PKG%
 ------------------------------------------
 <short description, 2 or 3 lines>

@@ -21,36 +21,36 @@
 ------------------------------------

 Build instructions:
-  unpack <PKG>-VER-REL-src.tar.bz2
+  unpack %PKG%-%VER%-%REL%-src.tar.bz2
     if you use setup to install this src package, it will be
 	 unpacked under /usr/src automatically
   cd /usr/src
-  ./<PKG>-VER-REL.sh all
+  ./%PKG%-%VER%-%REL%.sh all

 This will create:
-  /usr/src/<PKG>-VER-REL.tar.bz2
-  /usr/src/<PKG>-VER-REL-src.tar.bz2
+  /usr/src/%PKG%-%VER%-%REL%.tar.bz2
+  /usr/src/%PKG%-%VER%-%REL%-src.tar.bz2

 -------------------------------------------

 Files included in the binary distro

   /usr/bin/...
-  /usr/share/doc/<PKG>-<VER>/AUTHORS
-  /usr/share/doc/<PKG>-<VER>/...
-  /usr/share/doc/Cygwin/<PKG>-<VER>.README
+  /usr/share/doc/%PKG%-%VER%/AUTHORS
+  /usr/share/doc/Cygwin/%PKG%-%VER%.README
   /usr/share/man/man1/...
   /usr/share/info/...
-  /etc/postinstall/<PKG>.sh
+  /etc/postinstall/%PKG%.sh
+%THEFILES%

 ------------------

 Port Notes:

------ version <newer VER> -----
+----- version %NEWER_VER% -----
 Other information

------ version <VER> -----
+----- version %VER% -----
 Initial release

</patch>

Essentially -
1/ The option "all" does not call "list". The fix in the patch does.
2/ The patches to both file let the PKG, VER, and REL variables in the
README be automatically be filled in by the script -
   then maintainers won't have to manually do this.
3/ This patch fulfills the wish to have the file names be automatically be
placed in the README prior to binary/src build
   releases. The 1.8 version heads in that direction, but the functionality
isn't there.
4/ I have defined a NEWVER variable to handle the <newer REL> part of the
original README
5/ Defined a new export variable: 'ThePackageReadMeFile' which defines the
Package README file name
   (saves defining it twice) - both 'list' and 'install' use it
6/ I haven't renamed the routine "list", which it should be since it is a
"package" readme editor
7/ Note: the e sed command (quoting the man page for sed):

   Extended sed command:

   `e [COMMAND]'
     This command allows one to pipe input from a shell command into
     pattern space.  Without parameters, the `e' command executes the
     command that is found in pattern space and replaces the pattern
     space with the output; a trailing new-line is suppressed.

     If a parameter is specified, instead, the `e' command interprets
     it as a command and sends it to the output stream (like `r' does).
     The command can run across multiple lines, all but the last
     ending with a back-slash.

     In both cases, the results are undefined if the command to be
     executed contains a NUL character.

8/ To prevent using sed's -i option (see the message from Igor
http://cygwin.com/ml/cygwin/2003-11/msg01067.html -
   this should mitigate Igor's concerns). I store the /usr/bin/basename of
the Readme file into a variable which allows the script to
   generate a temporary readme file (/tmp/%PKG%.README)

   Then I do an [effective]:
   "mv -f /tmp/%PKG%.README /usr/share/doc/Cygwin/%PKG%.README"

   operation. I do NOT write the temp file in the /usr/share/doc/Cygwin/
directory since this will lead to a very subtle problem:
   The files listed would show two entries instead of one for the README,
e.g.,
      /usr/share/doc/Cygwin/%PKG%.README
      /usr/share/doc/Cygwin/%PKG%.README.tmp

    which is not what we want.

For further [past] postings see items
http://cygwin.com/ml/cygwin/2003-11/msg01067.html and
http://cygwin.com/ml/cygwin/2003-11/msg00700.html

for details.

_____________________________________________________
Alan Miles
ICQ#: 171006836
More ways to contact me: http://wwp.icq.com/171006836
_____________________________________________________

Attachment: packaging_templates.diff
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]