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

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

    From 8f214f525de8f252fdacfb8df606c1c09869ceb4 Mon Sep 17 00:00:00 2001
    From: Rusty Bird <rustybird@openmailbox.org>
    Date: Fri, 16 Sep 2016 10:18:54 +0000
    Subject: [PATCH] (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    | 15 +++++++--------
     gitian/build-helpers/re-dzip.sh | 18 +++++++-----------
     2 files changed, 14 insertions(+), 19 deletions(-)
    
    diff --git a/gitian/build-helpers/dzip.sh b/gitian/build-helpers/dzip.sh
    index 5772c8b..590c734 100755
    a b  
    1 #!/bin/sh
     1#!/bin/sh -e
    22# Crappy deterministic zip wrapper
    33export LC_ALL=C
    44
    55ZIPFILE=$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..f2e394a 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")
     6RE_DZIP=$(readlink -f -- "$(which -- "$0")")
     7PATH=$PATH:$(dirname "$RE_DZIP")
    68
    79mkdir 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 ..
     10unzip $UNZIPOPTS -d tmp_dzip -- "$1"
     11(cd tmp_dzip; dzip.sh ./"$ZIPFILE_BASENAME")
     12mv -- tmp_dzip/"$ZIPFILE_BASENAME" "$1"
    1713rm -rf tmp_dzip