alicelinux

A lightweight musl + clang/llvm + libressl + busybox distro
git clone https://codeberg.org/emmett1/alicelinux
Log | Files | Refs | README | LICENSE

git (934B)


      1 #!/bin/sh
      2 #
      3 # /etc/ports/drivers/git: git driver script for ports(8)
      4 #
      5 
      6 if [ $# -ne 1 ]; then
      7 	echo "usage: $0 <file>" >&2
      8 	exit 1
      9 fi
     10 
     11 . $1
     12 
     13 if [ -z "$URL" ]; then
     14 	echo "URL not set in '$1'" >&2
     15 	exit 2
     16 fi
     17 if [ -z "$NAME" ]; then
     18 	echo "NAME not set in '$1'" >&2
     19 	exit 2
     20 fi
     21 if [ -z "$BRANCH" ]; then
     22 	echo "BRANCH not set in '$1'" >&2
     23 	exit 2
     24 fi
     25 
     26 REPOSITORY="$PORTS_DIR/$NAME"
     27 if [ -n "$LOCAL_REPOSITORY" ]; then
     28 	REPOSITORY="$LOCAL_REPOSITORY"
     29 fi
     30 
     31 echo "Fetching updates from $URL"
     32 echo "Updating collection $NAME"
     33 
     34 cd "$REPOSITORY" 2> "/dev/null"
     35 
     36 if [ $? -lt 1 ]; then
     37 	git checkout -q "$BRANCH"
     38 	git fetch -q
     39 	git diff --pretty=format: --name-status "$BRANCH" origin/"$BRANCH" | sed "s/M\t/ Edit /g; s/A\t/ Checkout /g; s/D\t/ Delete /g" | sort
     40 	git clean -q -f
     41 	git reset -q --hard origin/"$BRANCH"
     42 else
     43 	git clone -q -b "$BRANCH" "$URL" "$REPOSITORY"
     44 	ls -1 $REPOSITORY | sed "s/^/ Checkout /"
     45 fi
     46 
     47 echo "Finished successfully"