DEADSOFTWARE

update make-bootstrap.sh
[cpc.git] / make-bootstrap.sh
index e82d0a682d0d8edbb13eb361669e71c0f3c6aeb5..8eb3b66a0c0ede001442441700453f3366818651 100755 (executable)
@@ -9,11 +9,20 @@ set -e
 _exec="make-bootstrap.sh"
 _this="$(dirname "$(readlink -f "$0")")"
 _version="v0.2"
+_sign=false
 
 ###^^^^^^^^^^^###
 ### Functions ###
 ###___________###
 
+usage() {
+  echo "Usage: make-bootstrap.sh [options]"
+  echo "Options:"
+  echo "    -v version        Set build version"
+  echo "    -S                Sign build"
+  exit 2
+}
+
 make_bootstrap() {
   local _cpu="$1"
   local _target="$2"
@@ -24,6 +33,28 @@ make_bootstrap() {
     -type d -name 'CodeC' -prune -o -exec rm -rf {} +
 }
 
+error() {
+  echo "$_exec:" "$@"
+  exit 1
+}
+
+###^^^^^^^^^^^^^^^###
+### Parse options ###
+###_______________###
+
+while getopts v:Sh _name
+do
+  case "$_name" in
+    v) _version="$OPTARG" ;;
+    S) _sign=true ;;
+    h|?) usage ;;
+  esac
+done
+
+if [ -z "$_version" ] || echo "$_version" | grep " " > /dev/null; then
+  error "version not specified or contain spaces"
+fi
+
 ###^^^^^^^^^^^^^^^^^^^^###
 ### Prebuild C sources ###
 ###____________________###
@@ -34,6 +65,12 @@ make_bootstrap 486 cpfront linux
 make_bootstrap 486 cpfront cygwin
 make_bootstrap arm cpfront linux
 
+###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
+### Hack: remove temp files from v0.1 ###
+###___________________________________###
+
+find "$_this/bootstrap" -type f -name '.new*' -delete
+
 ###^^^^^^^^^^^^^^^^^^^^^^###
 ### Package dist sources ###
 ###______________________###
@@ -53,3 +90,11 @@ cp -rt "$_this/cpc-$_version" -- \
   "$_this/src" \
   "$_this/C"
 tar czf "cpc-$_version.src.tar.gz" "cpc-$_version"
+
+###^^^^^^^^^^^^^^^^###
+### Make signature ###
+###________________###
+
+if $_sign; then
+  gpg --armor --detach-sig "cpc-$_version.src.tar.gz"
+fi