Commit Diff


commit - b39f351abea85b29012c34e4fdc8b97fb800260a
commit + 5b08f77f4fec3950ac79386cf93a899b5a2108dd
blob - 5e89f159ae1555784ddb6d408d2165b101b601e1
blob + 2a06704ae66304b6080f97d7666a9398fc469af8
--- scripts/local-port
+++ scripts/local-port
@@ -14,7 +14,7 @@
 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-# Stage the current clean Git commit as a checksummed local OpenBSD port.
+# Stage the current clean Git/Got commit as a checksummed local OpenBSD port.
 # Packaging and installation deliberately remain bsd.port.mk operations.
 
 set -eu
@@ -99,14 +99,38 @@ case "$port_dir" in
 *)	die "local port path must end in /mystuff/productivity/fugu" ;;
 esac
 
-git_root=$(git -C "$root" rev-parse --show-toplevel 2>/dev/null) ||
-    die "$root is not a Git working tree"
-[ "$git_root" = "$root" ] || die "$root is not the Git working-tree root"
-if [ -n "$(git -C "$root" status --porcelain --untracked-files=normal)" ]; then
-	die "working tree is not clean; commit or remove every change first"
+archive_commit()
+{
+	git -C "$root" archive --format=tar.gz --prefix="${distname}/" \
+	    -o "$archive_tmp" "$commit"
+}
+
+if git_root=$(git -C "$root" rev-parse --show-toplevel 2>/dev/null); then
+	[ "$git_root" = "$root" ] || die "$root is not the Git working-tree root"
+	if [ -n "$(git -C "$root" status --porcelain --untracked-files=normal)" ]; then
+		die "working tree is not clean; commit or remove every change first"
+	fi
+	commit=$(git -C "$root" rev-parse --verify HEAD) ||
+	    die "cannot resolve the current commit"
+elif [ -d "$root/.got" ]; then
+	command -v got >/dev/null 2>&1 || die "got is not installed"
+	[ "$(cat "$root/.got/path-prefix")" = / ] ||
+	    die "$root is not a whole-tree Got checkout"
+	if [ -n "$(cd "$root" && got status)" ]; then
+		die "working tree is not clean; commit or remove every change first"
+	fi
+	commit=$(cat "$root/.got/base-commit") ||
+	    die "cannot resolve the current commit"
+	repo=$(cat "$root/.got/repository") ||
+	    die "cannot resolve the Got repository"
+	archive_commit()
+	{
+		git --git-dir="$repo" archive --format=tar.gz \
+		    --prefix="${distname}/" -o "$archive_tmp" "$commit"
+	}
+else
+	die "$root is not a Git or Got working tree"
 fi
-commit=$(git -C "$root" rev-parse --verify HEAD) ||
-    die "cannot resolve the current commit"
 
 port_parent=${port_dir%/fugu}
 install -d "$port_parent" ||
@@ -157,8 +181,7 @@ esac
 tmp=$(mktemp -d /tmp/fugu-local-port.XXXXXXXXXX) ||
     die "cannot create a temporary directory"
 archive_tmp=$tmp/$archive
-git -C "$root" archive --format=tar.gz --prefix="${distname}/" \
-    -o "$archive_tmp" "$commit" || die "cannot archive $commit"
+archive_commit || die "cannot archive $commit"
 digest=$(sha256 -q "$archive_tmp") || die "cannot checksum $archive_tmp"
 
 if [ ! -d "$fulldistdir" ]; then