Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

detached-sig-apply.sh 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. UNSIGNED="$1"
  7. SIGNATURE="$2"
  8. ARCH=x86_64
  9. ROOTDIR=dist
  10. TEMPDIR=signed.temp
  11. OUTDIR=signed-app
  12. if [ -z "$UNSIGNED" ]; then
  13. echo "usage: $0 <unsigned app> <signature>"
  14. exit 1
  15. fi
  16. if [ -z "$SIGNATURE" ]; then
  17. echo "usage: $0 <unsigned app> <signature>"
  18. exit 1
  19. fi
  20. rm -rf ${TEMPDIR} && mkdir -p ${TEMPDIR}
  21. tar -C ${TEMPDIR} -xf ${UNSIGNED}
  22. cp -rf "${SIGNATURE}"/* ${TEMPDIR}
  23. if [ -z "${PAGESTUFF}" ]; then
  24. PAGESTUFF=${TEMPDIR}/pagestuff
  25. fi
  26. if [ -z "${CODESIGN_ALLOCATE}" ]; then
  27. CODESIGN_ALLOCATE=${TEMPDIR}/codesign_allocate
  28. fi
  29. find ${TEMPDIR} -name "*.sign" | while read i; do
  30. SIZE=`stat -c %s "${i}"`
  31. TARGET_FILE="`echo "${i}" | sed 's/\.sign$//'`"
  32. echo "Allocating space for the signature of size ${SIZE} in ${TARGET_FILE}"
  33. ${CODESIGN_ALLOCATE} -i "${TARGET_FILE}" -a ${ARCH} ${SIZE} -o "${i}.tmp"
  34. OFFSET=`${PAGESTUFF} "${i}.tmp" -p | tail -2 | grep offset | sed 's/[^0-9]*//g'`
  35. if [ -z ${QUIET} ]; then
  36. echo "Attaching signature at offset ${OFFSET}"
  37. fi
  38. dd if="$i" of="${i}.tmp" bs=1 seek=${OFFSET} count=${SIZE} 2>/dev/null
  39. mv "${i}.tmp" "${TARGET_FILE}"
  40. rm "${i}"
  41. echo "Success."
  42. done
  43. mv ${TEMPDIR}/${ROOTDIR} ${OUTDIR}
  44. rm -rf ${TEMPDIR}
  45. echo "Signed: ${OUTDIR}"