package.sh raw

   1  #!/usr/bin/env bash
   2  # Copyright (c) The Bitcoin Core developers
   3  # Distributed under the MIT software license, see the accompanying
   4  # file COPYING or https://opensource.org/license/mit.
   5  export LC_ALL=C
   6  set -e -o pipefail
   7  
   8  (
   9      cd "$DISTSRC"
  10  
  11      (
  12          cd installed
  13  
  14          case "$HOST" in
  15              *darwin*) ;;
  16              *)
  17                  # Split binaries from their debug symbols
  18                  {
  19                      find "${DISTNAME}/bin" "${DISTNAME}/libexec" -type f -executable -print0
  20                  } | xargs -0 -P"$JOBS" -I{} "${DISTSRC}/build/split-debug.sh" {} {} {}.dbg
  21                  ;;
  22          esac
  23  
  24          case "$HOST" in
  25              *mingw*)
  26                  cp "${DISTSRC}/doc/README_windows.txt" "${DISTNAME}/readme.txt"
  27                  ;;
  28              *linux*)
  29                  cp "${DISTSRC}/README.md" "${DISTNAME}/"
  30                  cp "${DISTSRC}/doc/INSTALL_linux.md" "${DISTNAME}/INSTALL.md"
  31                  ;;
  32          esac
  33  
  34          # copy over the example bitcoin.conf file. if contrib/devtools/gen-bitcoin-conf.sh
  35          # has not been run before buildling, this file will be a stub
  36          cp "${DISTSRC}/share/examples/bitcoin.conf" "${DISTNAME}/"
  37  
  38          cp -r "${DISTSRC}/share/rpcauth" "${DISTNAME}/share/"
  39  
  40          # Deterministically produce {non-,}debug binary tarballs ready
  41          # for release
  42          case "$HOST" in
  43              *mingw*)
  44                  find "${DISTNAME}" -not -name "*.dbg" -print0 \
  45                      | xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}"
  46                  find "${DISTNAME}" -not -name "*.dbg" \
  47                      | sort \
  48                      | zip -X@ "${OUTDIR}/${DISTNAME}-${HOST//x86_64-w64-mingw32/win64}-unsigned.zip" \
  49                      || ( rm -f "${OUTDIR}/${DISTNAME}-${HOST//x86_64-w64-mingw32/win64}-unsigned.zip" && exit 1 )
  50                  find "${DISTNAME}" -name "*.dbg" -print0 \
  51                      | xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}"
  52                  find "${DISTNAME}" -name "*.dbg" \
  53                      | sort \
  54                      | zip -X@ "${OUTDIR}/${DISTNAME}-${HOST//x86_64-w64-mingw32/win64}-debug.zip" \
  55                      || ( rm -f "${OUTDIR}/${DISTNAME}-${HOST//x86_64-w64-mingw32/win64}-debug.zip" && exit 1 )
  56                  ;;
  57              *linux*)
  58                  find "${DISTNAME}" -not -name "*.dbg" -print0 \
  59                      | sort --zero-terminated \
  60                      | tar --create --no-recursion --mode='u+rw,go+r-w,a+X' --null --files-from=- \
  61                      | gzip -9n > "${OUTDIR}/${DISTNAME}-${HOST}.tar.gz" \
  62                      || ( rm -f "${OUTDIR}/${DISTNAME}-${HOST}.tar.gz" && exit 1 )
  63                  find "${DISTNAME}" -name "*.dbg" -print0 \
  64                      | sort --zero-terminated \
  65                      | tar --create --no-recursion --mode='u+rw,go+r-w,a+X' --null --files-from=- \
  66                      | gzip -9n > "${OUTDIR}/${DISTNAME}-${HOST}-debug.tar.gz" \
  67                      || ( rm -f "${OUTDIR}/${DISTNAME}-${HOST}-debug.tar.gz" && exit 1 )
  68                  ;;
  69              *darwin*)
  70                  find "${DISTNAME}" -print0 \
  71                      | sort --zero-terminated \
  72                      | tar --create --no-recursion --mode='u+rw,go+r-w,a+X' --null --files-from=- \
  73                      | gzip -9n > "${OUTDIR}/${DISTNAME}-${HOST}-unsigned.tar.gz" \
  74                      || ( rm -f "${OUTDIR}/${DISTNAME}-${HOST}-unsigned.tar.gz" && exit 1 )
  75                  ;;
  76          esac
  77      )  # $DISTSRC/installed
  78  
  79      # Finally make tarballs for codesigning
  80      case "$HOST" in
  81          *mingw*)
  82              cp -rf --target-directory=. contrib/windeploy
  83              (
  84                  cd ./windeploy
  85                  mkdir -p unsigned
  86                  cp --target-directory=unsigned/ "${OUTDIR}/${DISTNAME}-win64-setup-unsigned.exe"
  87                  cp -r --target-directory=unsigned/ "${INSTALLPATH}"
  88                  find unsigned/ -name "*.dbg" -print0 \
  89                      | xargs -0r rm
  90                  find . -print0 \
  91                      | sort --zero-terminated \
  92                      | tar --create --no-recursion --mode='u+rw,go+r-w,a+X' --null --files-from=- \
  93                      | gzip -9n > "${OUTDIR}/${DISTNAME}-win64-codesigning.tar.gz" \
  94                      || ( rm -f "${OUTDIR}/${DISTNAME}-win64-codesigning.tar.gz" && exit 1 )
  95              )
  96              ;;
  97          *darwin*)
  98              cmake --build build --target deploy
  99              mv build/dist/bitcoin-macos-app.zip "${OUTDIR}/${DISTNAME}-${HOST}-unsigned.zip"
 100              mkdir -p "unsigned-app-${HOST}"
 101              cp  --target-directory="unsigned-app-${HOST}" \
 102                  contrib/macdeploy/detached-sig-create.sh
 103              mv --target-directory="unsigned-app-${HOST}" build/dist
 104              cp -r --target-directory="unsigned-app-${HOST}" "${INSTALLPATH}"
 105              (
 106                  cd "unsigned-app-${HOST}"
 107                  find . -print0 \
 108                      | sort --zero-terminated \
 109                      | tar --create --no-recursion --mode='u+rw,go+r-w,a+X' --null --files-from=- \
 110                      | gzip -9n > "${OUTDIR}/${DISTNAME}-${HOST}-codesigning.tar.gz" \
 111                      || ( rm -f "${OUTDIR}/${DISTNAME}-${HOST}-codesigning.tar.gz" && exit 1 )
 112              )
 113              ;;
 114      esac
 115  
 116  ) # $DISTSRC
 117  
 118  rm -rf "$ACTUAL_OUTDIR"
 119  mv --no-target-directory "$OUTDIR" "$ACTUAL_OUTDIR" \
 120      || ( rm -rf "$ACTUAL_OUTDIR" && exit 1 )
 121  
 122  (
 123      tmp="$(mktemp)"
 124      cd /outdir-base
 125      {
 126          echo "$GIT_ARCHIVE"
 127          find "$ACTUAL_OUTDIR" -type f
 128      } | xargs realpath --relative-base="$PWD" \
 129          | xargs sha256sum \
 130          | sort -k2 \
 131          > "$tmp";
 132      mv "$tmp" "$ACTUAL_OUTDIR"/SHA256SUMS.part
 133  )
 134