Ticket #20147: v2-0001-re-dzip.sh-various-improvements.patch

File v2-0001-re-dzip.sh-various-improvements.patch, 2.3 KB (added by rustybird, 3 years ago)
  • gitian/build-helpers/dzip.sh

    From e137947f9b46e3e89351d0d5dbf5f89999de41b1 Mon Sep 17 00:00:00 2001
    From: Rusty Bird <rustybird@openmailbox.org>
    Date: Wed, 21 Sep 2016 12:05:39 +0000
    Subject: [PATCH v2] (re-)dzip.sh: various improvements
    
    - Don't ignore errors
    - Quote $@ and $1
    - Work with absolute filenames and filenames starting with a dash
    - Pass many files per chmod invocation (much faster)
    - Pass $UNZIPOPTS, like $ZIPOPTS
    - Reuse dzip.sh in re-dzip.sh
    
    The (re)generated zip files are identical.
    ---
     gitian/build-helpers/dzip.sh    | 17 ++++++++---------
     gitian/build-helpers/re-dzip.sh | 23 ++++++++++-------------
     2 files changed, 18 insertions(+), 22 deletions(-)
    
    diff --git a/gitian/build-helpers/dzip.sh b/gitian/build-helpers/dzip.sh
    index 5772c8b..64fcdca 100755
    a b  
    1 #!/bin/sh
     1#!/bin/sh -e
    22# Crappy deterministic zip wrapper
    33export LC_ALL=C
    44
    5 ZIPFILE=$1
     5ZIPFILE=${1:?}
    66shift
    77
    8 [ -n "$REFERENCE_DATETIME" ] && \
    9         find $@ -exec touch --date="$REFERENCE_DATETIME" {} \;
    10 
    11 find $@ -executable -exec chmod 700 {} \;
    12 find $@ ! -executable -exec chmod 600 {} \;
    13 
    14 find $@ | sort | zip $ZIPOPTS -X -@ "$ZIPFILE"
     8if [ -n "$REFERENCE_DATETIME" ]; then
     9        find "$@" -exec touch --date="$REFERENCE_DATETIME" -- {} +
     10fi
     11find "$@"   -executable -exec chmod 700 {} +
     12find "$@" ! -executable -exec chmod 600 {} +
     13find "$@" | sort | zip $ZIPOPTS -X -@ "$ZIPFILE"
  • gitian/build-helpers/re-dzip.sh

    diff --git a/gitian/build-helpers/re-dzip.sh b/gitian/build-helpers/re-dzip.sh
    index 27828e9..58942c4 100755
    a b  
    1 #!/bin/sh
     1#!/bin/sh -e
    22# Crappy deterministic zip repackager
    33export LC_ALL=C
    44
    5 ZIPFILE=`basename $1`
     5ZIPFILE_BASENAME=$(basename -- "${1:?}")
     6TEMPDIR=tmp-re-dzip-$$
     7RE_DZIP=$(readlink -f -- "$(which -- "$0")")
     8PATH=$PATH:$(dirname "$RE_DZIP")
    69
    7 mkdir tmp_dzip
    8 cd tmp_dzip
    9 unzip ../$1
    10 [ -n "$REFERENCE_DATETIME" ] && \
    11         find . -exec touch --date="$REFERENCE_DATETIME" {} \;
    12 find . -executable -exec chmod 700 {} \;
    13 find . ! -executable -exec chmod 600 {} \;
    14 find . | sort | zip $ZIPOPTS -X -@ $ZIPFILE
    15 mv $ZIPFILE ../$1
    16 cd ..
    17 rm -rf tmp_dzip
     10mkdir "$TEMPDIR"
     11unzip $UNZIPOPTS -d "$TEMPDIR" -- "$1"
     12(cd "$TEMPDIR"; dzip.sh ./"$ZIPFILE_BASENAME" .)
     13mv -- "$TEMPDIR"/"$ZIPFILE_BASENAME" "$1"
     14rm -rf "$TEMPDIR"