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 to generic-build-script (updated to cvs 1.4)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I "backported" the changed I was already using in my latest packages the
full diff is in attach (trying to avoid the mailer change it I'm using
an extension DIFFERENT from .txt or anything that could be interpreted
as text/plain...).

Problems "solved" by this patch:
* original script doesn't manage the case the source is neither .tar.gz
nor .tar.bz2 (most times it will be .tgz in that case)
* postinstall directory is created in the binary package also if it is empty

and now the "unuseful" ones:
* original script has trailing spaces on many lines
* original script has funny use of tabs characters in the last "case"

it also adds a *completely optional* package signing option: to be
activated SIG must be defined on call (like "SIG=1 ./scriptname.sh all")

Here goes the comment:

| @@ -3,8 +3,8 @@
|  tdir=`echo "$0" | sed 's%[\\/][^\\/][^\\/]*$%%'`
|  test "x$tdir" = "x$0" && tdir=.
|  scriptdir=`cd $tdir; pwd`
| -# find src directory.
| -# If scriptdir ends in SPECS, then topdir is $scriptdir/..
| +# find src directory.
| +# If scriptdir ends in SPECS, then topdir is $scriptdir/..
|  # If scriptdir ends in CYGWIN-PATCHES, then topdir is $scriptdir/../..
|  # Otherwise, we assume that topdir = scriptdir
|  topdir1=`echo ${scriptdir} | sed 's%/SPECS$%%'`

Just some "trailing spaces stripping" paranoia.
I hate 'em ;-)

|  export FULLPKG=${PKG}-${VER}-${REL}
|
|  # determine correct decompression option and tarball filename
| -if [ -e ${PKG}-${VER}.tar.gz ] ; then
| -  export opt_decomp=z
| -  export src_orig_pkg_ext=gz
| -elif [ -e ${PKG}-${VER}.tar.bz2 ] ; then
| +export BASEPKG=${PKG}-${VER}
| +if [ -e ${BASEPKG}.tar.bz2 ] ; then
|    export opt_decomp=j
| -  export src_orig_pkg_ext=bz2
| +  export src_orig_pkg_name=${BASEPKG}.tar.bz2
| +elif [ -e ${BASEPKG}.tar.gz ] ; then
| +  export opt_decomp=z
| +  export src_orig_pkg_name=${BASEPKG}.tar.gz
| +elif [ -e ${BASEPKG}.tgz ] ; then
| +  export opt_decomp=z
| +  export src_orig_pkg_name=${BASEPKG}.tgz
| +elif [ -e ${BASEPKG}.tar ] ; then
| +  export opt_decomp=
| +  export src_orig_pkg_name=${BASEPKG}.tar
| +else
| +  echo Cannot find original package.
| +  exit 1
|  fi
|
| -export src_orig_pkg_name=${PKG}-${VER}.tar.${src_orig_pkg_ext}
| +# determine correct names for generated files
|  export src_pkg_name=${FULLPKG}-src.tar.bz2
|  export src_patch_name=${FULLPKG}.patch
|  export bin_pkg_name=${FULLPKG}.tar.bz2

Seems a little more general to me.
Moreover the past script had the "problem" if not having a "else" case,
so if neither .tar.gz nor .tar.bz2 was found it would have continued
with errors.

|    (cd ${topdir} && \
|    tar xv${opt_decomp}f ${src_orig_pkg} ; \
|    cd ${topdir} && \
| -  patch -p0 < ${src_patch}
| +  patch -p0 < ${src_patch}
|    && mkdirs )
|  }
|  conf() {

Again, trailing spaces paranoia.

|    --srcdir=${srcdir} --prefix=${prefix} \
|    --exec-prefix=${prefix} --sysconfdir=${sysconfdir} \
|    --libdir=${prefix}/lib --includedir=${prefix}/include \
|    --libexecdir='${sbindir}' --localstatedir=/var \
| -  --datadir='${prefix}/share'
| -)
| +  --datadir='${prefix}/share' )
|  }
|  build() {
|    (cd ${objdir} && \

"all the other closed parens are in line" consistency paranoia.

| @@ -107,9 +115,6 @@
|    if [ ! -d ${instdir}${prefix}/share/doc/Cygwin ]; then \
|      mkdir -p ${instdir}${prefix}/share/doc/Cygwin ; \
|    fi && \
| -  if [ ! -d ${instdir}${sysconfdir}/postinstall ]; then \
| -    mkdir -p ${instdir}${sysconfdir}/postinstall ; \
| -  fi && \
|    templist=""; \
|    for f in ${srcdir}/ANNOUNCE ${srcdir}/CHANGES ${srcdir}/INSTALL \
|             ${srcdir}/KNOWNBUG ${srcdir}/LICENSE ${srcdir}/README \
| @@ -132,14 +137,16 @@
|      fi ;\
|    fi ;\
|    if [ -f ${srcdir}/CYGWIN-PATCHES/postinstall.sh ] ; then \
| -  /usr/bin/install -m 755 ${srcdir}/CYGWIN-PATCHES/postinstall.sh \
| +    if [ ! -d ${instdir}${sysconfdir}/postinstall ]; then \
| +      mkdir -p ${instdir}${sysconfdir}/postinstall ; \
| +    fi && \
| +    /usr/bin/install -m 755 ${srcdir}/CYGWIN-PATCHES/postinstall.sh \
|        ${instdir}${sysconfdir}/postinstall/${PKG}.sh
|    fi )
|  }
|  strip() {
|    (cd ${instdir} && \
| -  find . -name "*.dll" | xargs strip > /dev/null 2>&1
| -  find . -name "*.exe" | xargs strip > /dev/null 2>&1
| +  find . -name "*.dll" -or -name "*.exe" | xargs strip > /dev/null 2>&1
|    true )
|  }
|  pkg() {

So that postinstall directory is created only if needed.

|  strip() {
|    (cd ${instdir} && \
| -  find . -name "*.dll" | xargs strip > /dev/null 2>&1
| -  find . -name "*.exe" | xargs strip > /dev/null 2>&1
| +  find . -name "*.dll" -or -name "*.exe" | xargs strip > /dev/null 2>&1
|    true )
|  }
|  pkg() {

"let's save one line and two command execution" paranoia.

|  spkg() {
|    (mkpatch && \
| +  if [ "${SIG}" ]; then name=${srcinstdir}/${src_patch_name}
text="PATCH" sigfile; fi && \
|    cp ${src_orig_pkg} ${srcinstdir}/${src_orig_pkg_name} && \
| +  if [ -e ${src_orig_pkg}.sig ]; then cp ${src_orig_pkg}.sig
${srcinstdir}/; fi && \
|    cp $0 ${srcinstdir}/`basename $0` && \
| +  if [ \( "${SIG}" \) -a \( -e $0.sig \) ]; then cp $0.sig
${srcinstdir}/; fi && \
|    cd ${srcinstdir} && \
|    tar cvjf ${src_pkg} * )
|  }

Part of my "optional package signature by mantainer".
(used only when env SIG is defined)

|  finish() {
| -  rm -rf ${srcdir}
| +  rm -rf ${srcdir}
| +}

Space paranoia.

| +sigfile() {
| +  if [ \( "${SIG}" \) -a \( -e $name \) -a \( \( ! -e $name.sig \) -o
\( $name -nt $name.sig \) \) ]; then \
| +    if [ -x /usr/bin/gpg ]; then \
| +      echo "$text signature need to be updated"; \
| +      /usr/bin/gpg --detach-sign $name; \
| +    else \
| +      echo "You need the gnupg package installed in order to make
signatures."; \
| +    fi; \
| +  fi;
| +}
| +checksig() {
| +  if [ -x /usr/bin/gpg ]; then \
| +    if [ -e $0.sig ]; then \
| +      echo "SCRIPT signature follows:"; \
| +      /usr/bin/gpg --verify $0.sig $0; \
| +    else \
| +      echo "SCRIPT signature missing."; \
| +    fi; \
| +    if [ -e ${src_orig_pkg}.sig ]; then \
| +      echo "ORIGINAL PACKAGE signature follows:"; \
| +      /usr/bin/gpg --verify ${src_orig_pkg}.sig ${src_orig_pkg}; \
| +    else \
| +      echo "ORIGINAL PACKAGE signature missing."; \
| +    fi; \
| +    if [ -e ${src_patch}.sig ]; then \
| +      echo "PATCH signature follows:"; \
| +      /usr/bin/gpg --verify ${src_patch}.sig ${src_patch}; \
| +    else \
| +      echo "PATCH signature missing."; \
| +    fi; \
| +  else
| +    echo "You need the gnupg package installed in order to check
signatures."; \
| +  fi;
|  }

Actual functions that check and/or update a specific file signature.

|  case $1 in
| -  prep)	prep ; STATUS=$? ;;
| +  prep)		prep ; STATUS=$? ;;
|    mkdirs)	mkdirs; STATUS=$? ;;
| -  conf)	conf ; STATUS=$? ;;
| +  conf)		conf ; STATUS=$? ;;
|    build)	build ; STATUS=$? ;;
|    check)	check ; STATUS=$? ;;
|    clean)	clean ; STATUS=$? ;;
|    install)	install ; STATUS=$? ;;
|    strip)	strip ; STATUS=$? ;;
|    package)	pkg ; STATUS=$? ;;
| -  pkg)	pkg ; STATUS=$? ;;
| +  pkg)		pkg ; STATUS=$? ;;
|    mkpatch)	mkpatch ; STATUS=$? ;;
| -  src-package)	spkg ; STATUS=$? ;;
| -  spkg)	spkg ; STATUS=$? ;;
| -  finish) finish ; STATUS=$? ;;
| -  all) prep && conf && build && install && \
| -     strip && pkg && spkg && finish ; \
| -	  STATUS=$? ;;
| +  src-package)	name=$0 text="SCRIPT" sigfile; spkg ; STATUS=$? ;;
| +  spkg)		name=$0 text="SCRIPT" sigfile; spkg ; STATUS=$? ;;
| +  finish)	finish ; STATUS=$? ;;
| +  checksig)	checksig ; STATUS=$? ;;
| +  all)		prep && conf && build && install && \
| +		strip && pkg && spkg && finish ; \
| +		STATUS=$? ;;
|    *) echo "Error: bad arguments" ; exit 1 ;;
|  esac

Final part of "signature patch".

Any comment?

BTW: does explicit "host and" "target" have a real usefullness? I have
found at least a package (which uses a *fairly old* autoconf and
automake) that breaks using it: it tries to use i686-pc-cygwin-gcc
instead of gcc and then says "compiler not supported".
I guess that anyhow packages are meant to be created from cygwin, so
host and target would be the default...
(ok ok, I guess someone of you out there has got a Linux or a FreeBSD
used to cross-compile packages...)

C ya,
~  Lapo

- --
Lapo 'Raist' Luchini
lapo@lapo.it (PGP & X.509 keys available)
http://www.lapo.it (ICQ UIN: 529796)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAj9P2fQACgkQaJiCLMjyUvtJFwCgyGsYBcT5ZhwakEOG6OYMATrc
aksAn0tM4eaQmcxLFiIudjjNVQK+lsjV
=2YSr
-----END PGP SIGNATURE-----
--- templates/generic-build-script	2003-08-30 00:29:06.755245600 +0200
+++ generic.sh	2003-08-30 00:37:25.044866800 +0200
@@ -3,8 +3,8 @@
 tdir=`echo "$0" | sed 's%[\\/][^\\/][^\\/]*$%%'`
 test "x$tdir" = "x$0" && tdir=.
 scriptdir=`cd $tdir; pwd`
-# find src directory.  
-# If scriptdir ends in SPECS, then topdir is $scriptdir/.. 
+# find src directory.
+# If scriptdir ends in SPECS, then topdir is $scriptdir/..
 # If scriptdir ends in CYGWIN-PATCHES, then topdir is $scriptdir/../..
 # Otherwise, we assume that topdir = scriptdir
 topdir1=`echo ${scriptdir} | sed 's%/SPECS$%%'`
@@ -26,15 +26,25 @@
 export FULLPKG=${PKG}-${VER}-${REL}
 
 # determine correct decompression option and tarball filename
-if [ -e ${PKG}-${VER}.tar.gz ] ; then
-  export opt_decomp=z
-  export src_orig_pkg_ext=gz
-elif [ -e ${PKG}-${VER}.tar.bz2 ] ; then
+export BASEPKG=${PKG}-${VER}
+if [ -e ${BASEPKG}.tar.bz2 ] ; then
   export opt_decomp=j
-  export src_orig_pkg_ext=bz2
+  export src_orig_pkg_name=${BASEPKG}.tar.bz2
+elif [ -e ${BASEPKG}.tar.gz ] ; then
+  export opt_decomp=z
+  export src_orig_pkg_name=${BASEPKG}.tar.gz
+elif [ -e ${BASEPKG}.tgz ] ; then
+  export opt_decomp=z
+  export src_orig_pkg_name=${BASEPKG}.tgz
+elif [ -e ${BASEPKG}.tar ] ; then
+  export opt_decomp=
+  export src_orig_pkg_name=${BASEPKG}.tar
+else
+  echo Cannot find original package.
+  exit 1
 fi
 
-export src_orig_pkg_name=${PKG}-${VER}.tar.${src_orig_pkg_ext}
+# determine correct names for generated files
 export src_pkg_name=${FULLPKG}-src.tar.bz2
 export src_patch_name=${FULLPKG}.patch
 export bin_pkg_name=${FULLPKG}.tar.bz2
@@ -68,7 +78,7 @@
   (cd ${topdir} && \
   tar xv${opt_decomp}f ${src_orig_pkg} ; \
   cd ${topdir} && \
-  patch -p0 < ${src_patch} 
+  patch -p0 < ${src_patch}
   && mkdirs )
 }
 conf() {
@@ -78,10 +88,8 @@
   --srcdir=${srcdir} --prefix=${prefix} \
   --exec-prefix=${prefix} --sysconfdir=${sysconfdir} \
   --libdir=${prefix}/lib --includedir=${prefix}/include \
   --libexecdir='${sbindir}' --localstatedir=/var \
-  --datadir='${prefix}/share'
-)
+  --datadir='${prefix}/share' )
 }
 build() {
   (cd ${objdir} && \
@@ -107,9 +115,6 @@
   if [ ! -d ${instdir}${prefix}/share/doc/Cygwin ]; then \
     mkdir -p ${instdir}${prefix}/share/doc/Cygwin ; \
   fi && \
-  if [ ! -d ${instdir}${sysconfdir}/postinstall ]; then \
-    mkdir -p ${instdir}${sysconfdir}/postinstall ; \
-  fi && \
   templist=""; \
   for f in ${srcdir}/ANNOUNCE ${srcdir}/CHANGES ${srcdir}/INSTALL \
            ${srcdir}/KNOWNBUG ${srcdir}/LICENSE ${srcdir}/README \
@@ -132,14 +137,16 @@
     fi ;\
   fi ;\
   if [ -f ${srcdir}/CYGWIN-PATCHES/postinstall.sh ] ; then \
-  /usr/bin/install -m 755 ${srcdir}/CYGWIN-PATCHES/postinstall.sh \
+    if [ ! -d ${instdir}${sysconfdir}/postinstall ]; then \
+      mkdir -p ${instdir}${sysconfdir}/postinstall ; \
+    fi && \
+    /usr/bin/install -m 755 ${srcdir}/CYGWIN-PATCHES/postinstall.sh \
       ${instdir}${sysconfdir}/postinstall/${PKG}.sh
   fi )
 }
 strip() {
   (cd ${instdir} && \
-  find . -name "*.dll" | xargs strip > /dev/null 2>&1
-  find . -name "*.exe" | xargs strip > /dev/null 2>&1
+  find . -name "*.dll" -or -name "*.exe" | xargs strip > /dev/null 2>&1
   true )
 }
 pkg() {
@@ -158,32 +165,70 @@
 }
 spkg() {
   (mkpatch && \
+  if [ "${SIG}" ]; then name=${srcinstdir}/${src_patch_name} text="PATCH" sigfile; fi && \
   cp ${src_orig_pkg} ${srcinstdir}/${src_orig_pkg_name} && \
+  if [ -e ${src_orig_pkg}.sig ]; then cp ${src_orig_pkg}.sig ${srcinstdir}/; fi && \
   cp $0 ${srcinstdir}/`basename $0` && \
+  if [ \( "${SIG}" \) -a \( -e $0.sig \) ]; then cp $0.sig ${srcinstdir}/; fi && \
   cd ${srcinstdir} && \
   tar cvjf ${src_pkg} * )
 }
 finish() {
-  rm -rf ${srcdir} 
+  rm -rf ${srcdir}
+}
+sigfile() {
+  if [ \( "${SIG}" \) -a \( -e $name \) -a \( \( ! -e $name.sig \) -o \( $name -nt $name.sig \) \) ]; then \
+    if [ -x /usr/bin/gpg ]; then \
+      echo "$text signature need to be updated"; \
+      /usr/bin/gpg --detach-sign $name; \
+    else \
+      echo "You need the gnupg package installed in order to make signatures."; \
+    fi; \
+  fi;
+}
+checksig() {
+  if [ -x /usr/bin/gpg ]; then \
+    if [ -e $0.sig ]; then \
+      echo "SCRIPT signature follows:"; \
+      /usr/bin/gpg --verify $0.sig $0; \
+    else \
+      echo "SCRIPT signature missing."; \
+    fi; \
+    if [ -e ${src_orig_pkg}.sig ]; then \
+      echo "ORIGINAL PACKAGE signature follows:"; \
+      /usr/bin/gpg --verify ${src_orig_pkg}.sig ${src_orig_pkg}; \
+    else \
+      echo "ORIGINAL PACKAGE signature missing."; \
+    fi; \
+    if [ -e ${src_patch}.sig ]; then \
+      echo "PATCH signature follows:"; \
+      /usr/bin/gpg --verify ${src_patch}.sig ${src_patch}; \
+    else \
+      echo "PATCH signature missing."; \
+    fi; \
+  else
+    echo "You need the gnupg package installed in order to check signatures."; \
+  fi;
 }
 case $1 in
-  prep)	prep ; STATUS=$? ;;
+  prep)		prep ; STATUS=$? ;;
   mkdirs)	mkdirs; STATUS=$? ;;
-  conf)	conf ; STATUS=$? ;;
+  conf)		conf ; STATUS=$? ;;
   build)	build ; STATUS=$? ;;
   check)	check ; STATUS=$? ;;
   clean)	clean ; STATUS=$? ;;
   install)	install ; STATUS=$? ;;
   strip)	strip ; STATUS=$? ;;
   package)	pkg ; STATUS=$? ;;
-  pkg)	pkg ; STATUS=$? ;;
+  pkg)		pkg ; STATUS=$? ;;
   mkpatch)	mkpatch ; STATUS=$? ;;
-  src-package)	spkg ; STATUS=$? ;;
-  spkg)	spkg ; STATUS=$? ;;
-  finish) finish ; STATUS=$? ;;
-  all) prep && conf && build && install && \
-     strip && pkg && spkg && finish ; \
-	  STATUS=$? ;;
+  src-package)	name=$0 text="SCRIPT" sigfile; spkg ; STATUS=$? ;;
+  spkg)		name=$0 text="SCRIPT" sigfile; spkg ; STATUS=$? ;;
+  finish)	finish ; STATUS=$? ;;
+  checksig)	checksig ; STATUS=$? ;;
+  all)		prep && conf && build && install && \
+		strip && pkg && spkg && finish ; \
+		STATUS=$? ;;
   *) echo "Error: bad arguments" ; exit 1 ;;
 esac
 exit ${STATUS}

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