opkg

statically linked package installer
git clone anongit@rnpnr.xyz:opkg.git
Log | Files | Refs | Feed | Submodules | README | LICENSE

commit.sh (660B)


      1 set -e
      2 
      3 if [ "$#" != 4 ] ; then
      4 	echo 'usage: commit.sh repo branch tag out' >&2
      5 	exit 2
      6 fi
      7 
      8 repo=$1
      9 branch=$2
     10 tag=$3
     11 out=$4
     12 
     13 if commit=$(git -C "$repo" show-ref -s --verify "refs/heads/$branch" 2>/dev/null) ; then
     14 	oldtree=$(git -C "$repo" rev-parse --verify "$branch^{tree}")
     15 	newtree=$(git -C "$repo" rev-parse --verify "$tag^{tree}")
     16 	if [ "$oldtree" != "$newtree" ] ; then
     17 		set -- -p "$branch"
     18 		unset commit
     19 	fi
     20 else
     21 	set --
     22 	unset commit
     23 fi
     24 
     25 if [ -z "${commit+set}" ] ; then
     26 	commit=$(git -C "$repo" commit-tree -m "opkg $(git rev-parse --short=10 HEAD)" "$@" "$tag")
     27 	git -C "$repo" update-ref "refs/heads/$branch" "$commit"
     28 fi
     29 echo "$commit" >"$out"