pkg.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/bash
  2. # A little script to create tarball, especially for Oasis2Opam
  3. # You may pass source commit as first argument, HEAD is used if omitted.
  4. echo "Start"
  5. # If directory doesn't exist, create it
  6. if ! [ -e dist ]; then
  7. mkdir dist
  8. fi
  9. # Target commit (TC) i.e. commit from which tarball is created.
  10. if [[ $1 = "" ]]; then
  11. echo "No argument, using HEAD to create tarball."
  12. TC=HEAD
  13. else
  14. TC=$1
  15. fi
  16. TCID=`git rev-parse ${TC}`
  17. echo "Creating tarball from commit ${TCID} ($TC)."
  18. # If no tag, use commit SHA1
  19. id=`git describe --abbrev=10 --candidates=50 ${TCID}`
  20. name=oclaunch_${id}_source # _source emphasis the difference with binary tarballs
  21. echo "Writing in" $name".*"
  22. git archive ${TCID} --prefix=${name}/ --format=zip -o dist/${name}.zip -9
  23. # Creating .xz .gz and .bz2 from tar archive
  24. tar_name=${name}.tar
  25. git archive ${TCID} --prefix=${name}/ --format=tar \
  26. | tee dist/${tar_name} \
  27. | gzip -c9 > dist/${tar_name}.gz
  28. cd dist
  29. bzip2 -c9 < ${tar_name} > ${tar_name}.bz2
  30. xz -c9 < ${tar_name} > ${tar_name}.xz
  31. # Verification
  32. gzip -t < ${tar_name}.gz
  33. bzip2 -t < ${tar_name}.bz2
  34. xz -t < ${tar_name}.xz