mrrl

Minimal Reliable Reproducible Linux
git clone https://ccx.te2000.cz/git/mrrl
Log | Files | Refs | Submodules | README

build-commit (772B)


      1 #!/bin/sh -xe
      2 cd "$(dirname "$0")/.."
      3 
      4 usage() {
      5 	printf '%s\n' 'usage: build-commit <git-commit-hash> [targets]'
      6 }
      7 
      8 fatal_usage() {
      9 	printf '%s\n' >&2 "fatal: build-commit: $*"
     10 	usage
     11 	exit 100
     12 }
     13 
     14 fatal_e111() {
     15 	printf '%s\n' >&2 "fatal: $*"
     16 	exit 111
     17 }
     18 
     19 case $#-$1 in
     20 	(1-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]*)
     21 		;;
     22 	(1-*)
     23 		fatal_usage "invalid format of git commit hash"
     24 		;;
     25 	(0)
     26 		fatal_usage "invalid number of arguments: $#"
     27 		;;
     28 esac
     29 
     30 git fetch --all
     31 git submodule foreach git fetch --all
     32 
     33 # check we got known commit
     34 git show --stat=80 $1
     35 
     36 # erase local changes
     37 git restore .
     38 
     39 git checkout $1
     40 git submodule update --init
     41 if git submodule status --cached | grep '^[^ ]'; then
     42 	fatal_e111 "failed to get defined submodule states"
     43 fi
     44 
     45 shift
     46 exec make -rs "$@"