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]

generic template script (proposed patch on 1.9)


 # 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


Original script has a flaw: if no .tar.gz nor .tar.bz2 are found, it happily continues wihtout defining values.
I also added support for a bunch more package types, but the important parte is the last else imho.


@@ -103,8 +108,7 @@
rm -f ${instdir}${f} ; \
fi ;\
done &&\
- for d in ${prefix}/share/doc/${PKG}-${VER} ${prefix}/share/doc/Cygwin \
- ${sysconfdir}/postinstall ; do
+ for d in ${prefix}/share/doc/${PKG}-${VER} ${prefix}/share/doc/Cygwin ; do
if [ ! -d ${instdir}${d} ] ; then
mkdir -p ${instdir}${d} ;\
fi ;\
@@ -131,14 +135,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 )
}

It is useful IMHO to have the postinstall directory created automatically only if there actualyl is a postinstall script to install there.
This way the script must be modified less by mantainers to reflect the fact that their package doesn't have a postinstall script (to avoid the empty dir).


 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 )
 }

xargs already accepts a huge number of parameters, then why dividing them in two?


The rest is just some whitespace changes and my usual "digital signature" patch.

Lapo

--
Lapo 'Raist' Luchini
lapo@lapo.it (PGP & X.509 keys available)
http://www.lapo.it (ICQ UIN: 529796)

--- templates/generic-build-script	2003-12-05 10:50:37.275959700 +0100
+++ generic.sh	2003-12-05 11:05:19.710665700 +0100
@@ -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,14 +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
 
+# determine correct names for generated files
 export src_orig_pkg_name=${PKG}-${VER}.tar.${src_orig_pkg_ext}
 export src_pkg_name=${FULLPKG}-src.tar.bz2
 export src_patch_name=${FULLPKG}.patch
@@ -48,10 +59,6 @@
 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
-target=i686-pc-cygwin
 prefix=/usr
 sysconfdir=/etc
 MY_CFLAGS="-O2"
@@ -68,7 +75,7 @@
   (cd ${topdir} && \
   tar xv${opt_decomp}f ${src_orig_pkg} ; \
   cd ${topdir} && \
-  patch -p0 < ${src_patch} 
+  patch -p0 < ${src_patch}
   && mkdirs )
 }
 conf() {
@@ -80,8 +87,7 @@
   --libdir=${prefix}/lib --includedir=${prefix}/include \
   --mandir=${prefix}/share/man --infodir=${prefix}/share/info \
   --libexecdir='${sbindir}' --localstatedir=/var \
-  --datadir='${prefix}/share'
-)
+  --datadir='${prefix}/share' )
 }
 build() {
   (cd ${objdir} && \
@@ -103,8 +109,7 @@
       rm -f ${instdir}${f} ; \
     fi ;\
   done &&\
-  for d in ${prefix}/share/doc/${PKG}-${VER} ${prefix}/share/doc/Cygwin \
-           ${sysconfdir}/postinstall ; do
+  for d in ${prefix}/share/doc/${PKG}-${VER} ${prefix}/share/doc/Cygwin ; do
     if [ ! -d ${instdir}${d} ] ; then
       mkdir -p ${instdir}${d} ;\
     fi ;\
@@ -131,14 +136,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 )
 }
 list() {
@@ -163,33 +170,73 @@
 }
 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` && \
+  name=$0 text="SCRIPT" sigfile && \
+  if [ "${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"; \
+      rm -f $name.sig; \
+      /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=$? ;;
-  list)	list ; STATUS=$? ;;
+  list)		list ; 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=$? ;;
+  spkg)		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]