初始提交: Gitea 项目代码
This commit is contained in:
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ ! -f go.mod ] || [ ! -d snap ]; then
|
||||
echo "This script should be run from the root of the gitea repository"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$SNAPCRAFT_PART_INSTALL" ]; then
|
||||
SNAPCRAFT_PART_INSTALL="./dist/snap"
|
||||
echo "* using mock install path: $SNAPCRAFT_PART_INSTALL"
|
||||
fi
|
||||
|
||||
command -v pnpm >/dev/null 2>&1 || npm install -g pnpm
|
||||
|
||||
# build tags for 1.26: "bindata sqlite sqlite_unlock_notify pam cert"
|
||||
# for 1.27: sqlite is not needed, "cert" seems doing nothing
|
||||
TAGS="bindata pam" make build
|
||||
|
||||
install -D gitea "${SNAPCRAFT_PART_INSTALL}/gitea"
|
||||
cp -r options "${SNAPCRAFT_PART_INSTALL}/"
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ ! -f go.mod ] || [ ! -d snap ]; then
|
||||
echo "This script should be run from the root of the gitea repository"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$SNAPCRAFT_PROJECT_NAME" ]; then
|
||||
echo "No snapcraft build env, continue with mocking ...."
|
||||
craftctl() { echo "* mocking craftctl: $*"; }
|
||||
snap() { echo "* mocking snap: $*"; }
|
||||
else
|
||||
echo "Add working directory to git safe.directory ..."
|
||||
git config --global --add safe.directory "$PWD"
|
||||
fi
|
||||
|
||||
# How it works:
|
||||
# * snapcraft.io checks out the default branch (e.g.: main during 1.27 dev period)
|
||||
# * "override-pull" step gets the latest tag by date (e.g.: v1.26.1)
|
||||
# * use "snap info gitea" to get the latest released tag
|
||||
# * if the latest tag is not released to stable, checkout that tag and build it for "stable"
|
||||
# * otherwise, build the main branch for "devel"
|
||||
# * "override-build" step uses build script from the checked out commit to build
|
||||
# This approach highly depends on the "main" branch's push.
|
||||
|
||||
# To debug the logic:
|
||||
# * last_committed_tag=v1.26.1 last_released_tag=v1.26.0 ./snap/part-gitea-pull.sh
|
||||
# it will checkout tag v1.26.1, and build that for "stable"
|
||||
# * last_committed_tag=v1.26.1 last_released_tag=v1.26.1 recent_tag=v1.27.0-dev-205 ./snap/part-gitea-pull.sh
|
||||
# it will still use the current branch, and build it for "devel"
|
||||
|
||||
[ -z "$last_committed_tag" ] && last_committed_tag="$(git for-each-ref --sort=taggerdate --format '%(tag)' refs/tags | tail -n 1)"
|
||||
[ -z "$last_released_tag" ] && last_released_tag="$(snap info gitea | awk '$1 == "latest/candidate:" { print $2 }')"
|
||||
|
||||
if [ "${last_committed_tag}" != "${last_released_tag}" ]; then
|
||||
# if the latest tag has not been released to stable, build that tag instead of default branch.
|
||||
echo "Build last committed tag ${last_committed_tag} for new release, fetching and checking out ..."
|
||||
git fetch --quiet
|
||||
git checkout --quiet "${last_committed_tag}"
|
||||
# HINT: after this, the "build" step will use that commit's "part-gitea-build.sh", but not this one's
|
||||
else
|
||||
echo "Build current branch $(git branch --show-current) @ $(git rev-parse HEAD)"
|
||||
fi
|
||||
|
||||
# possible tag names:
|
||||
# * v1.27.0-dev-205-gce089f498b
|
||||
# * v1.26.1
|
||||
# * v1.22.0-rc1-2816-gce089f498b
|
||||
# then normalize it to semver format: v1.2.3+dev.205.gce089f498b
|
||||
[ -z "$recent_tag" ] && recent_tag="$(git describe --always --tags)"
|
||||
echo "Use recent tag $recent_tag to determine version and grade"
|
||||
|
||||
version_main="$(echo "$recent_tag" | cut -d'-' -f1)"
|
||||
version_ext="$(echo "$recent_tag" | cut -d'-' -s -f2- | sed -e 'y/-/./')"
|
||||
[ -n "$version_ext" ] && grade=devel || grade=stable
|
||||
|
||||
version="${version_main}"
|
||||
[ -n "$version_ext" ] && version="${version}+${version_ext}"
|
||||
|
||||
craftctl set version="$version"
|
||||
craftctl set grade="$grade"
|
||||
@@ -0,0 +1,69 @@
|
||||
name: gitea
|
||||
summary: Gitea - A painless self-hosted Git service
|
||||
description: |
|
||||
The goal of this project is to make the easiest, fastest, and most painless
|
||||
way of setting up a self-hosted Git service with GitHub-like experiences,
|
||||
including issue tracking, code review, project management, wikis, package registry,
|
||||
Gitea Actions and more.
|
||||
|
||||
icon: public/assets/img/logo.png
|
||||
confinement: strict
|
||||
base: core24
|
||||
adopt-info: gitea
|
||||
|
||||
platforms:
|
||||
armhf:
|
||||
build-on: [armhf]
|
||||
build-for: [armhf]
|
||||
amd64:
|
||||
build-on: [amd64]
|
||||
build-for: [amd64]
|
||||
arm64:
|
||||
build-on: [arm64]
|
||||
build-for: [arm64]
|
||||
|
||||
environment:
|
||||
GITEA_CUSTOM: "$SNAP_COMMON"
|
||||
GITEA_WORK_DIR: "$SNAP_COMMON"
|
||||
GIT_TEMPLATE_DIR: "$SNAP/usr/share/git-core/templates"
|
||||
GIT_EXEC_PATH: "$SNAP/usr/lib/git-core"
|
||||
|
||||
apps:
|
||||
gitea:
|
||||
command: gitea
|
||||
plugs: [network, network-bind, removable-media]
|
||||
web:
|
||||
command: gitea web
|
||||
daemon: simple
|
||||
plugs: [network, network-bind, removable-media]
|
||||
dump:
|
||||
command: gitea dump
|
||||
plugs: [home, removable-media]
|
||||
version:
|
||||
command: gitea --version
|
||||
sqlite:
|
||||
command: usr/bin/sqlite3
|
||||
|
||||
parts:
|
||||
gitea:
|
||||
plugin: make
|
||||
source: .
|
||||
stage-packages: [ git, sqlite3, openssh-client ]
|
||||
build-packages: [ git, libpam0g-dev, libsqlite3-dev, build-essential]
|
||||
build-snaps: [ go/1.26/stable, node/24/stable ]
|
||||
build-environment:
|
||||
- LDFLAGS: ""
|
||||
override-pull: craftctl default && ./snap/part-gitea-pull.sh
|
||||
override-build: ./snap/part-gitea-build.sh
|
||||
prime:
|
||||
- -etc
|
||||
- -usr/lib/systemd
|
||||
- -usr/lib/gcc
|
||||
- -usr/lib/sasl2
|
||||
- -usr/lib/x86_64-linux-gnu/krb5
|
||||
- -usr/share/apport
|
||||
- -usr/share/bash-completion
|
||||
- -usr/share/git-core/contrib
|
||||
- -usr/share/man
|
||||
- -usr/share/upstart
|
||||
- -var
|
||||
Reference in New Issue
Block a user