Compare commits

...

2 Commits

Author SHA1 Message Date
petru 43c8d014e8 Modified - [scripts] [configure] [git-lfs] Added conditional Git LFS setup to configure.sh when repository LFS hooks are installed.
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
release-tag-version / binary (push) Has been cancelled
release-tag-version / container (push) Has been cancelled
- 1 - I updated `.configure.sh` so repositories that already have Git LFS hook scripts in `.git/hooks` now treat `git-lfs` as a required dependency during verification, install the `git-lfs` system package on supported package managers, and run `git lfs install --local` during non-verify setup.

(cherry picked from commit b66ec8c19d)
2026-05-20 00:32:29 +03:00
petru c2a0fe8c51 Modified - [scripts] [smart-build] [darwin] Added macOS amd64/arm64 smart-build support, including SQLite-aware Docker-host handling for containerized workspaces.
- 1 - I updated `smart-build.sh` so its interactive architecture menu now offers `macos-amd64`, `macos-arm64`, and includes both Darwin targets in `All Arch`, while preserving the existing `darwin` artifact naming in `dist/`.
- 2 - I added a dedicated Darwin SQLite build path in `smart-build.sh` that routes macOS `bindata sqlite sqlite_unlock_notify` builds through `make release-darwin`, and I updated `Makefile` to make `release-darwin` configurable through `DARWIN_ARCHS` so helper scripts can request only `darwin-10.12/amd64` or `darwin-10.12/arm64`.
- 3 - I hardened the Darwin SQLite flow in `smart-build.sh` for `code-server`-style containerized workspaces by distinguishing between a missing Docker CLI and an unreachable Docker daemon, by validating that the host Docker daemon can see the same mounted repository `go.mod` path as the current workspace, and by moving the temporary release output under `dist/` instead of `/tmp`.
- 4 - I added `SMART_BUILD_DARWIN_HOST_REPO_PATH` support to `smart-build.sh` so Darwin SQLite builds can be redirected to a host-visible repository mount path when the interactive workspace path inside the container differs from the real host path used by the Docker daemon.

(cherry picked from commit 06e5bd7f46)
2026-05-20 00:30:57 +03:00
4 changed files with 199 additions and 22 deletions
+10 -1
View File
@@ -800,4 +800,13 @@ History search guidance:
159 - [2026-05-17 17:13:47] - v1.26.0-by-petru - Type: Modified - [update] Added v1.26.1 original Gitea commits 159 - [2026-05-17 17:13:47] - v1.26.0-by-petru - Type: Modified - [update] Added v1.26.1 original Gitea commits
160 - [2026-05-17 17:13:47] - v1.26.1-by-petru - Type: Modified - [docs] [changelog] [github-links] Added explicit GitHub links for the remaining bare PR references in `CHANGELOG.md` for the `v1.26.1-by-petru` release notes. 160 - [2026-05-17 17:13:47] - v1.26.1-by-petru - Type: Modified - [docs] [changelog] [github-links] Added explicit GitHub links for the remaining bare PR references in `CHANGELOG.md` for the `v1.26.1-by-petru` release notes.
- 1 - I updated the remaining bare `#NNNNN` pull-request references in `CHANGELOG.md` so they now point directly to `https://github.com/go-gitea/gitea/pull/...`, without folding this tag-specific changelog cleanup into the earlier generic changelog-link conversion entry. - 1 - I updated the remaining bare `#NNNNN` pull-request references in `CHANGELOG.md` so they now point directly to `https://github.com/go-gitea/gitea/pull/...`, without folding this tag-specific changelog cleanup into the earlier generic changelog-link conversion entry.
161 - [2026-05-19 21:31:45] - v1.27.0-dev-172-g3a6684178a - Type: Modified - [scripts] [smart-build] [darwin] Added macOS amd64/arm64 smart-build support, including SQLite-aware Docker-host handling for containerized workspaces.
- 1 - I updated `smart-build.sh` so its interactive architecture menu now offers `macos-amd64`, `macos-arm64`, and includes both Darwin targets in `All Arch`, while preserving the existing `darwin` artifact naming in `dist/`.
- 2 - I added a dedicated Darwin SQLite build path in `smart-build.sh` that routes macOS `bindata sqlite sqlite_unlock_notify` builds through `make release-darwin`, and I updated `Makefile` to make `release-darwin` configurable through `DARWIN_ARCHS` so helper scripts can request only `darwin-10.12/amd64` or `darwin-10.12/arm64`.
- 3 - I hardened the Darwin SQLite flow in `smart-build.sh` for `code-server`-style containerized workspaces by distinguishing between a missing Docker CLI and an unreachable Docker daemon, by validating that the host Docker daemon can see the same mounted repository `go.mod` path as the current workspace, and by moving the temporary release output under `dist/` instead of `/tmp`.
- 4 - I added `SMART_BUILD_DARWIN_HOST_REPO_PATH` support to `smart-build.sh` so Darwin SQLite builds can be redirected to a host-visible repository mount path when the interactive workspace path inside the container differs from the real host path used by the Docker daemon.
161 - [2026-05-19 23:43:29] - v1.27.0-dev-172-g06e5bd7f46 - Type: Modified - [scripts] [configure] [git-lfs] Added conditional Git LFS setup to `configure.sh` when repository LFS hooks are installed.
- 1 - I updated `.configure.sh` so repositories that already have Git LFS hook scripts in `.git/hooks` now treat `git-lfs` as a required dependency during verification, install the `git-lfs` system package on supported package managers, and run `git lfs install --local` during non-verify setup.
+38
View File
@@ -68,6 +68,7 @@ This script prepares the local machine for the Gitea build used in this tree.
It can install or verify: It can install or verify:
- the required system build packages, including gcc, make, git, pkg-config, - the required system build packages, including gcc, make, git, pkg-config,
and the SQLite/PAM libraries; and the SQLite/PAM libraries;
- git-lfs when this repository has Git LFS hooks installed;
- Go $GO_VERSION, as required by go.mod; - Go $GO_VERSION, as required by go.mod;
- Node $NODE_VERSION and pnpm $PNPM_VERSION, as required by package.json; - Node $NODE_VERSION and pnpm $PNPM_VERSION, as required by package.json;
- frontend dependencies with pnpm install --frozen-lockfile; - frontend dependencies with pnpm install --frozen-lockfile;
@@ -149,6 +150,21 @@ command_exists() {
command -v "$1" >/dev/null 2>&1 command -v "$1" >/dev/null 2>&1
} }
repo_has_git_lfs_hooks() {
local hook
for hook in pre-push post-checkout post-commit post-merge; do
[ -f "$SCRIPT_DIR/.git/hooks/$hook" ] || continue
if grep -q 'git-lfs' "$SCRIPT_DIR/.git/hooks/$hook"; then
return 0
fi
done
return 1
}
repo_requires_git_lfs() {
repo_has_git_lfs_hooks
}
run_as_root() { run_as_root() {
if [ "$(id -u)" -eq 0 ]; then if [ "$(id -u)" -eq 0 ]; then
"$@" "$@"
@@ -227,6 +243,7 @@ install_system_packages() {
xz-utils xz-utils
zip zip
) )
repo_requires_git_lfs && packages+=(git-lfs)
if [ "$WITH_CROSS_CGO" -eq 1 ]; then if [ "$WITH_CROSS_CGO" -eq 1 ]; then
packages+=( packages+=(
gcc-arm-linux-gnueabihf gcc-arm-linux-gnueabihf
@@ -267,6 +284,7 @@ install_system_packages() {
xz xz
zip zip
) )
repo_requires_git_lfs && packages+=(git-lfs)
run_as_root dnf install -y "${packages[@]}" run_as_root dnf install -y "${packages[@]}"
[ "$WITH_CROSS_CGO" -eq 0 ] || warn "Cross-CGO package setup is only automated for apt-based systems." [ "$WITH_CROSS_CGO" -eq 0 ] || warn "Cross-CGO package setup is only automated for apt-based systems."
return return
@@ -299,6 +317,7 @@ install_system_packages() {
xz xz
zip zip
) )
repo_requires_git_lfs && packages+=(git-lfs)
run_as_root yum install -y "${packages[@]}" run_as_root yum install -y "${packages[@]}"
[ "$WITH_CROSS_CGO" -eq 0 ] || warn "Cross-CGO package setup is only automated for apt-based systems." [ "$WITH_CROSS_CGO" -eq 0 ] || warn "Cross-CGO package setup is only automated for apt-based systems."
return return
@@ -329,6 +348,7 @@ install_system_packages() {
xz xz
zip zip
) )
repo_requires_git_lfs && packages+=(git-lfs)
run_as_root pacman -Sy --needed --noconfirm "${packages[@]}" run_as_root pacman -Sy --needed --noconfirm "${packages[@]}"
[ "$WITH_CROSS_CGO" -eq 0 ] || warn "Cross-CGO package setup is only automated for apt-based systems." [ "$WITH_CROSS_CGO" -eq 0 ] || warn "Cross-CGO package setup is only automated for apt-based systems."
return return
@@ -361,6 +381,7 @@ install_system_packages() {
xz xz
zip zip
) )
repo_requires_git_lfs && packages+=(git-lfs)
run_as_root zypper install -y "${packages[@]}" run_as_root zypper install -y "${packages[@]}"
[ "$WITH_CROSS_CGO" -eq 0 ] || warn "Cross-CGO package setup is only automated for apt-based systems." [ "$WITH_CROSS_CGO" -eq 0 ] || warn "Cross-CGO package setup is only automated for apt-based systems."
return return
@@ -484,6 +505,16 @@ install_frontend_deps() {
pnpm install --frozen-lockfile pnpm install --frozen-lockfile
} }
configure_git_lfs() {
repo_requires_git_lfs || return
log "Configuring Git LFS"
command_exists git-lfs || die "git-lfs is required for this repository but is not installed."
cd "$SCRIPT_DIR"
git lfs install --local >/dev/null
}
configure_cross_cgo() { configure_cross_cgo() {
[ "$WITH_CROSS_CGO" -eq 1 ] || return [ "$WITH_CROSS_CGO" -eq 1 ] || return
@@ -528,6 +559,9 @@ verify_environment() {
missing+=("$command_name") missing+=("$command_name")
fi fi
done done
if repo_requires_git_lfs && ! command_exists git-lfs; then
missing+=("git-lfs")
fi
if command_exists go; then if command_exists go; then
local found_go local found_go
@@ -592,6 +626,9 @@ verify_environment() {
printf 'Node: %s\n' "$(node --version)" printf 'Node: %s\n' "$(node --version)"
printf 'pnpm: %s\n' "$(pnpm --version)" printf 'pnpm: %s\n' "$(pnpm --version)"
printf 'gcc: %s\n' "$(gcc --version | head -n 1)" printf 'gcc: %s\n' "$(gcc --version | head -n 1)"
if repo_requires_git_lfs; then
printf 'git-lfs: %s\n' "$(git lfs version)"
fi
if [ -d "$SCRIPT_DIR/node_modules" ]; then if [ -d "$SCRIPT_DIR/node_modules" ]; then
printf 'node_modules: present\n' printf 'node_modules: present\n'
else else
@@ -652,6 +689,7 @@ fi
if [ "$VERIFY_ONLY" -eq 0 ]; then if [ "$VERIFY_ONLY" -eq 0 ]; then
[ "$INSTALL_SYSTEM" -eq 0 ] || install_system_packages [ "$INSTALL_SYSTEM" -eq 0 ] || install_system_packages
configure_git_lfs
[ "$INSTALL_GO" -eq 0 ] || install_go [ "$INSTALL_GO" -eq 0 ] || install_go
[ "$INSTALL_NODE" -eq 0 ] || install_node_and_pnpm [ "$INSTALL_NODE" -eq 0 ] || install_node_and_pnpm
configure_cross_cgo configure_cross_cgo
+149 -20
View File
@@ -16,6 +16,73 @@ resolve_build_ref() {
git describe --tags --exact-match 2>/dev/null || git describe --tags --always git describe --tags --exact-match 2>/dev/null || git describe --tags --always
} }
require_docker_for_darwin_sqlite() {
if ! command -v docker > /dev/null 2>&1; then
echo "❌ Docker is required for macOS SQLite cross-builds."
echo " Install the Docker CLI in this environment, or use the non-SQLite macOS build option."
echo " If you are running inside a code-server container, also mount the host Docker socket."
exit 1
fi
if ! docker info > /dev/null 2>&1; then
echo "❌ Docker is installed but the daemon is not reachable."
echo " Start Docker, or expose the host Docker daemon to this container."
echo " For a code-server container, mount /var/run/docker.sock from the host."
if [ -n "${DOCKER_HOST:-}" ]; then
echo " Current DOCKER_HOST: ${DOCKER_HOST}"
else
echo " Current DOCKER_HOST is unset."
fi
exit 1
fi
}
resolve_xgo_image() {
local xgo_version
xgo_version="$(awk '$1 == "XGO_VERSION" { print $3; exit }' Makefile 2>/dev/null)"
if [ -z "$xgo_version" ]; then
xgo_version="go-1.25.x"
fi
printf 'ghcr.io/techknowlogick/xgo:%s' "$xgo_version"
}
resolve_darwin_sqlite_repo_root() {
local override_path
override_path="${SMART_BUILD_DARWIN_HOST_REPO_PATH:-}"
if [ -z "$override_path" ]; then
pwd -P
return
fi
if [ ! -d "$override_path" ] || [ ! -f "$override_path/go.mod" ]; then
echo "❌ SMART_BUILD_DARWIN_HOST_REPO_PATH is set, but the path is not usable in this container:"
echo " $override_path"
echo " Mount the host repository path into the container at the same absolute path, then retry."
exit 1
fi
printf '%s' "$override_path"
}
validate_repo_bind_mount_for_darwin_sqlite() {
local repo_path="$1"
local xgo_image
xgo_image="$(resolve_xgo_image)"
if ! docker run --rm -v "$repo_path":/probe:ro --entrypoint sh "$xgo_image" -lc 'test -f /probe/go.mod'; then
echo "❌ Docker can reach the daemon, but the daemon cannot mount this repository path correctly:"
echo " $repo_path"
echo " The xgo container only sees an empty or different host path, so /source/go.mod is missing there."
echo " If smart-build runs inside a code-server container with the host Docker socket,"
echo " the repository must be mounted from a host bind path that exists at the same absolute path."
exit 1
fi
}
write_sha256_file() { write_sha256_file() {
local artifact_path="$1" local artifact_path="$1"
local artifact_dir artifact_name local artifact_dir artifact_name
@@ -169,7 +236,7 @@ fi
echo "" echo ""
echo "🎯 Select Arch to build:" echo "🎯 Select Arch to build:"
notify_human_interaction notify_human_interaction
arch_options=("linux-amd64" "linux-armv7" "windows-amd64" "All Arch" "Quit") arch_options=("linux-amd64" "linux-armv7" "windows-amd64" "macos-amd64" "macos-arm64" "All Arch" "Quit")
select opt in "${arch_options[@]}" select opt in "${arch_options[@]}"
do do
case $opt in case $opt in
@@ -185,8 +252,16 @@ do
TARGETS=("windows/amd64") TARGETS=("windows/amd64")
break break
;; ;;
"macos-amd64")
TARGETS=("darwin/amd64")
break
;;
"macos-arm64")
TARGETS=("darwin/arm64")
break
;;
"All Arch") "All Arch")
TARGETS=("linux/amd64" "linux/arm/7" "windows/amd64") TARGETS=("linux/amd64" "linux/arm/7" "windows/amd64" "darwin/amd64" "darwin/arm64")
break break
;; ;;
"Quit") "Quit")
@@ -269,6 +344,73 @@ ensure_bindata_assets() {
ensure_bindata_assets ensure_bindata_assets
build_darwin_sqlite_target() {
local arch="$1"
local output="$2"
local repo_root temp_dist built_file output_abs
local built_files=()
require_docker_for_darwin_sqlite
repo_root="$(resolve_darwin_sqlite_repo_root)"
validate_repo_bind_mount_for_darwin_sqlite "$repo_root"
output_abs="$(pwd -P)/$output"
temp_dist="$repo_root/dist/.smart-build-darwin-${arch}-$$"
rm -rf "$temp_dist"
if ! mkdir -p "$temp_dist"; then
echo "❌ Failed to create a temporary macOS release directory in dist/."
exit 1
fi
echo "📦 Building for darwin/$arch with TAGS=\"$BUILD_TAGS\" via release-darwin..."
if ! make -C "$repo_root" release-darwin TAGS="$BUILD_TAGS" DARWIN_ARCHS="darwin-10.12/$arch" DIST="$temp_dist"; then
rm -rf "$temp_dist"
echo "❌ Fail to build for darwin/$arch with SQLite"
exit 1
fi
mapfile -t built_files < <(find "$temp_dist/binaries" -maxdepth 1 -type f | sort)
if [ "${#built_files[@]}" -ne 1 ]; then
rm -rf "$temp_dist"
echo "❌ Unexpected macOS artifact count for darwin/$arch: ${#built_files[@]}"
exit 1
fi
built_file="${built_files[0]}"
mv "$built_file" "$output_abs"
rm -rf "$temp_dist"
write_sha256_file "$output_abs"
echo "✅ Created: $output_abs"
echo "✅ Created: $output_abs.sha256"
}
build_standard_target() {
local os="$1"
local arch="$2"
local arm_ver="$3"
local output="$4"
local ext="$5"
export GOOS=$os
export GOARCH=$arch
export GOARM=$arm_ver
export CGO_ENABLED=0
if [ "$BUILD_VARIANT" == "sqlite" ]; then
export CGO_ENABLED=1
fi
if make build TAGS="$BUILD_TAGS"; then
mv "gitea$ext" "$output"
write_sha256_file "$output"
echo "✅ Created: $output"
echo "✅ Created: $output.sha256"
else
echo "❌ Fail to build for $os/$arch${arm_ver:+/v$arm_ver}"
exit 1
fi
}
# --- 4. COMPILARE --- # --- 4. COMPILARE ---
mkdir -p dist mkdir -p dist
for TARGET in "${TARGETS[@]}"; do for TARGET in "${TARGETS[@]}"; do
@@ -279,27 +421,14 @@ for TARGET in "${TARGETS[@]}"; do
VARIANT_SUFFIX="" && [ "$BUILD_VARIANT" == "sqlite" ] && VARIANT_SUFFIX="-sqlite" VARIANT_SUFFIX="" && [ "$BUILD_VARIANT" == "sqlite" ] && VARIANT_SUFFIX="-sqlite"
OUTPUT="dist/gitea-$BUILD_REF-$OS-$PLATFORM$VARIANT_SUFFIX$EXT" OUTPUT="dist/gitea-$BUILD_REF-$OS-$PLATFORM$VARIANT_SUFFIX$EXT"
echo "📦 Building for $OS/$ARCH ${ARM_VER:+(v$ARM_VER) }with TAGS=\"$BUILD_TAGS\"..." if [ "$OS" == "darwin" ] && [ "$BUILD_VARIANT" == "sqlite" ]; then
build_darwin_sqlite_target "$ARCH" "$OUTPUT"
export GOOS=$OS
export GOARCH=$ARCH
export GOARM=$ARM_VER
export CGO_ENABLED=0
if [ "$BUILD_VARIANT" == "sqlite" ]; then
export CGO_ENABLED=1
fi
if make build TAGS="$BUILD_TAGS"; then
mv "gitea$EXT" "$OUTPUT"
write_sha256_file "$OUTPUT"
echo "✅ Created: $OUTPUT"
echo "✅ Created: $OUTPUT.sha256"
else else
echo "❌ Fail to build for $TARGET" echo "📦 Building for $OS/$ARCH ${ARM_VER:+(v$ARM_VER) }with TAGS=\"$BUILD_TAGS\"..."
exit 1 build_standard_target "$OS" "$ARCH" "$ARM_VER" "$OUTPUT" "$EXT"
fi fi
unset GOOS GOARCH GOARM unset GOOS GOARCH GOARM CGO_ENABLED
done done
echo "✨ Buid finished. Get file(s) from /dist" echo "✨ Buid finished. Get file(s) from /dist"
+2 -1
View File
@@ -107,6 +107,7 @@ endif
LDFLAGS := $(LDFLAGS) -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)" LDFLAGS := $(LDFLAGS) -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"
LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64,linux/riscv64 LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64,linux/riscv64
DARWIN_ARCHS ?= darwin-10.12/amd64,darwin-10.12/arm64
GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/migrations/...) code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration,$(shell $(GO) list ./... | grep -v /vendor/)) GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/migrations/...) code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration,$(shell $(GO) list ./... | grep -v /vendor/))
MIGRATE_TEST_PACKAGES ?= $(shell $(GO) list code.gitea.io/gitea/models/migrations/...) MIGRATE_TEST_PACKAGES ?= $(shell $(GO) list code.gitea.io/gitea/models/migrations/...)
@@ -685,7 +686,7 @@ release-linux: | $(DIST_DIRS)
.PHONY: release-darwin .PHONY: release-darwin
release-darwin: | $(DIST_DIRS) release-darwin: | $(DIST_DIRS)
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-s -w $(LDFLAGS)' -targets 'darwin-10.12/amd64,darwin-10.12/arm64' -out gitea-$(VERSION) . CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-s -w $(LDFLAGS)' -targets '$(DARWIN_ARCHS)' -out gitea-$(VERSION) .
.PHONY: release-freebsd .PHONY: release-freebsd
release-freebsd: | $(DIST_DIRS) release-freebsd: | $(DIST_DIRS)