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.

44 lines
1.3 KiB

  1. #!/usr/bin/env bash
  2. set -e
  3. archive() {
  4. export TARBALL_NAME=$1
  5. export TARBALL_OUTDIR=$2
  6. # archive this repo
  7. cd "$(git rev-parse --show-toplevel)"
  8. git archive HEAD --format=tar --prefix="${TARBALL_NAME}/" \
  9. -o "${TARBALL_OUTDIR}/${TARBALL_NAME}.tar"
  10. # archive submodules
  11. git submodule update --init
  12. git submodule foreach --quiet 'git archive HEAD --format=tar \
  13. --prefix="${TARBALL_NAME}/${path}/" \
  14. -o "${TARBALL_OUTDIR}/${TARBALL_NAME}-submodule-${path}-${sha1}.tar"
  15. tar -n --concatenate --file="${TARBALL_OUTDIR}/${TARBALL_NAME}.tar" \
  16. "${TARBALL_OUTDIR}/${TARBALL_NAME}-submodule-${path}-${sha1}.tar"'
  17. gzip -c "${TARBALL_OUTDIR}/${TARBALL_NAME}.tar" > "${TARBALL_OUTDIR}/${TARBALL_NAME}.tar.gz"
  18. # clean-up
  19. git submodule foreach --quiet 'rm ${TARBALL_OUTDIR}/${TARBALL_NAME}-submodule-${path}-${sha1}.tar'
  20. rm "${TARBALL_OUTDIR}/${TARBALL_NAME}.tar"
  21. }
  22. TARGET_TARBALL_NAME=shadowsocks-libev
  23. TARGET_TARBALL_DIR=$(git rev-parse --show-toplevel)
  24. while getopts "n:o:" opt
  25. do
  26. case ${opt} in
  27. o)
  28. TARGET_TARBALL_DIR=$(readlink -f -- $OPTARG)
  29. ;;
  30. n)
  31. TARGET_TARBALL_NAME=$OPTARG
  32. ;;
  33. \?)
  34. exit 1
  35. ;;
  36. esac
  37. done
  38. archive "${TARGET_TARBALL_NAME}" "${TARGET_TARBALL_DIR}"