You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

detached-sig-create.sh 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/sh
  2. # Copyright (c) 2014-2015 The Starwels developers
  3. # Distributed under the MIT software license, see the accompanying
  4. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
  5. set -e
  6. ROOTDIR=dist
  7. BUNDLE="${ROOTDIR}/Starwels-Qt.app"
  8. CODESIGN=codesign
  9. TEMPDIR=sign.temp
  10. TEMPLIST=${TEMPDIR}/signatures.txt
  11. OUT=signature-osx.tar.gz
  12. OUTROOT=osx
  13. if [ ! -n "$1" ]; then
  14. echo "usage: $0 <codesign args>"
  15. echo "example: $0 -s MyIdentity"
  16. exit 1
  17. fi
  18. rm -rf ${TEMPDIR} ${TEMPLIST}
  19. mkdir -p ${TEMPDIR}
  20. ${CODESIGN} -f --file-list ${TEMPLIST} "$@" "${BUNDLE}"
  21. grep -v CodeResources < "${TEMPLIST}" | while read i; do
  22. TARGETFILE="${BUNDLE}/`echo "${i}" | sed "s|.*${BUNDLE}/||"`"
  23. SIZE=`pagestuff "$i" -p | tail -2 | grep size | sed 's/[^0-9]*//g'`
  24. OFFSET=`pagestuff "$i" -p | tail -2 | grep offset | sed 's/[^0-9]*//g'`
  25. SIGNFILE="${TEMPDIR}/${OUTROOT}/${TARGETFILE}.sign"
  26. DIRNAME="`dirname "${SIGNFILE}"`"
  27. mkdir -p "${DIRNAME}"
  28. echo "Adding detached signature for: ${TARGETFILE}. Size: ${SIZE}. Offset: ${OFFSET}"
  29. dd if="$i" of="${SIGNFILE}" bs=1 skip=${OFFSET} count=${SIZE} 2>/dev/null
  30. done
  31. grep CodeResources < "${TEMPLIST}" | while read i; do
  32. TARGETFILE="${BUNDLE}/`echo "${i}" | sed "s|.*${BUNDLE}/||"`"
  33. RESOURCE="${TEMPDIR}/${OUTROOT}/${TARGETFILE}"
  34. DIRNAME="`dirname "${RESOURCE}"`"
  35. mkdir -p "${DIRNAME}"
  36. echo "Adding resource for: "${TARGETFILE}""
  37. cp "${i}" "${RESOURCE}"
  38. done
  39. rm ${TEMPLIST}
  40. tar -C "${TEMPDIR}" -czf "${OUT}" .
  41. rm -rf "${TEMPDIR}"
  42. echo "Created ${OUT}"