Browse Source

Improve pkg.sh script

 + Allow to create source archives without checking out, would be faster and
 simpler to use. The source commit is the first argument passed to the script,
 using HEAD if omitted.
Leo 9 years ago
parent
commit
1707c715a8
1 changed files with 15 additions and 4 deletions
  1. 15 4
      pkg.sh

+ 15 - 4
pkg.sh

@@ -1,5 +1,6 @@
-#!/bin/sh
+#!/bin/bash
 # A little script to create tarball, especially for Oasis2Opam
+# You may pass source commit as first argument, HEAD is used if omitted.
 
 echo "Start"
 
@@ -8,15 +9,25 @@ if ! [ -e dist ]; then
     mkdir dist
 fi
 
+# Target commit (TC) i.e. commit from which tarball is created.
+if [[ $1 = "" ]]; then
+  echo "No argument, using HEAD to create tarball."
+  TC=HEAD
+else
+  TC=$1
+fi
+TCID=`git rev-parse ${TC}`
+echo "Creating tarball from commit ${TCID} ($TC)."
+
 # If no tag, use commit SHA1
-id=`git describe --abbrev=10 --candidates=50 HEAD`
+id=`git describe --abbrev=10 --candidates=50 ${TCID}`
 name=oclaunch_${id}_source # _source emphasis the difference with binary tarballs
 
 echo "Writing in" $name".*"
-git archive HEAD --prefix=${name}/ --format=zip -o dist/${name}.zip -9
+git archive ${TCID} --prefix=${name}/ --format=zip -o dist/${name}.zip -9
 # Creating .xz .gz and .bz2 from tar archive
 tar_name=${name}.tar
-git archive HEAD --prefix=${name}/ --format=tar -o dist/${tar_name}
+git archive ${TCID} --prefix=${name}/ --format=tar -o dist/${tar_name}
 cd dist
 gzip -c9 < ${tar_name} >  ${tar_name}.gz
 bzip2 -c9 < ${tar_name} >  ${tar_name}.bz2