update snapcraft.yaml for core18 and latest features (#11300)
Removing some of the complexity, together with the install and configure hook. Signed-off-by: Sergio Schvezov <sergio.schvezov@canonical.com>
This commit is contained in:
parent
119173130a
commit
b09ec508c3
6 changed files with 27 additions and 341 deletions
|
@ -1,66 +0,0 @@
|
|||
APP_NAME = Gitea: Go Git Service
|
||||
RUN_USER = root
|
||||
RUN_MODE = prod
|
||||
CUSTOM_PATH = SNAP_DIR_DATA/custom
|
||||
|
||||
[server]
|
||||
DOMAIN = localhost
|
||||
PROTOCOL = http
|
||||
HTTP_PORT = 3001
|
||||
ROOT_URL = http://localhost:3001/
|
||||
DISABLE_SSH = false
|
||||
SSH_PORT = 22
|
||||
STATIC_ROOT_PATH = SNAP_DIR_DATA/static
|
||||
APP_DATA_PATH = SNAP_DIR_COMMON/data
|
||||
SSH_ROOT = SNAP_DIR_COMMON/ssh
|
||||
SSH_KEY_TEST_PATH = SNAP_DIR_DATA/sshkeytest
|
||||
|
||||
[database]
|
||||
DB_TYPE = sqlite3
|
||||
PATH = SNAP_DIR_COMMON/gitea.db
|
||||
|
||||
[repository]
|
||||
ROOT = SNAP_DIR_COMMON/repositories/data
|
||||
|
||||
[repository.upload]
|
||||
ENABLED = true
|
||||
ALLOWED_TYPES = "image/jpeg|image/png"
|
||||
FILE_MAX_SIZE = 10
|
||||
MAX_FILES = 5
|
||||
TEMP_PATH = SNAP_DIR_COMMON/repositories/tmp
|
||||
|
||||
[release.attachment]
|
||||
PATH = SNAP_DIR_COMMON/releases/attachments
|
||||
|
||||
[smartypants]
|
||||
ENABLED = true
|
||||
|
||||
[indexer]
|
||||
ISSUE_INDEXER_PATH = SNAP_DIR_COMMON/indexers/issues.bleve
|
||||
|
||||
|
||||
[mailer]
|
||||
ENABLED = false
|
||||
|
||||
[service]
|
||||
REGISTER_EMAIL_CONFIRM = false
|
||||
ENABLE_NOTIFY_MAIL = false
|
||||
DISABLE_REGISTRATION = false
|
||||
ENABLE_CAPTCHA = false
|
||||
REQUIRE_SIGNIN_VIEW = false
|
||||
|
||||
[picture]
|
||||
AVATAR_UPLOAD_PATH = SNAP_DIR_COMMON/pictures/avatars
|
||||
DISABLE_GRAVATAR = true
|
||||
ENABLE_FEDERATED_AVATAR = false
|
||||
|
||||
[attachment]
|
||||
PATH = SNAP_DIR_COMMON/attachments
|
||||
|
||||
[session]
|
||||
PROVIDER = memory
|
||||
|
||||
[log]
|
||||
MODE = file
|
||||
LEVEL = Trace
|
||||
ROOT_PATH = SNAP_DIR_COMMON/log
|
|
@ -1,126 +0,0 @@
|
|||
#!/bin/bash
|
||||
if snapctl get gitea.snap.custom; then
|
||||
cdir=$(snapctl get gitea.snap.custom)
|
||||
else
|
||||
cdir=$SNAP_COMMON
|
||||
fi
|
||||
|
||||
cfg="$cdir/conf/app.ini"
|
||||
bak="$cdir/conf/app.ini.bak-$(date -Ins)"
|
||||
basecfg="$SNAP/snap/helpers/app.ini"
|
||||
smp="$SNAP/gitea/custom/conf/app.ini.sample"
|
||||
|
||||
function toSnap() {
|
||||
OIFS=$IFS
|
||||
IFS='
|
||||
'
|
||||
category="none"
|
||||
src="$cfg"
|
||||
[[ "$1" = "init" ]] && src="$smp"
|
||||
[[ "$1" = "snap" ]] && src="$basecfg"
|
||||
|
||||
for l in $(sed 's_;\([A-Z]*\)_\1_g' $src | grep -v -e '^;' -e '^$'); do
|
||||
if echo $l | grep -q '^[[]'; then
|
||||
category=$(CatToSnap "$l")
|
||||
elif echo $l | grep -q '^[A-Z]'; then
|
||||
option=$(OptToSnap "$l")
|
||||
value=$(ValToSnap "$l")
|
||||
if [[ $category = "none" ]]; then
|
||||
snapctl set "$option=$value"
|
||||
else
|
||||
snapctl set "$category.$option=$value"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
IFS=$OIFS
|
||||
}
|
||||
|
||||
function toIni() {
|
||||
OIFS=$IFS
|
||||
IFS='
|
||||
'
|
||||
category="none"; option="none"; catUnset=true
|
||||
src=$smp
|
||||
[[ -f $cfg ]] && src="$cfg"
|
||||
tmpIni="$cfg.tmp"
|
||||
[[ -f $src ]] && cp "$src" "$tmpIni"
|
||||
cp $tmpIni $bak
|
||||
echo '' > $cfg
|
||||
for l in $(grep -v -e '^;' -e '^$' $tmpIni); do
|
||||
if echo $l | grep -q '^[[]'; then
|
||||
category=$(CatToSnap "$l")
|
||||
catUnset=true
|
||||
elif echo $l | grep -q '^[A-Z]'; then
|
||||
option=$(OptToSnap "$l")
|
||||
if [[ $category = "none" ]]; then
|
||||
value=$(snapctl get $option)
|
||||
echo $(OptToIni "$option") = $value >> $cfg
|
||||
else
|
||||
value=$(snapctl get $category.$option)
|
||||
if $catUnset; then
|
||||
echo "" >> $cfg
|
||||
echo "[$(CatToIni "$category")]" >> $cfg
|
||||
catUnset=false
|
||||
fi
|
||||
echo $(OptToIni "$option") = $value >> $cfg
|
||||
fi
|
||||
fi
|
||||
done;
|
||||
IFS=$OIFS
|
||||
}
|
||||
|
||||
function CatToSnap {
|
||||
ret=$(echo "$1" \
|
||||
| grep -oP '[A-Za-z0-9._]+' \
|
||||
| sed 's|\.|-|g' \
|
||||
| sed 's|_|99|g')
|
||||
echo $ret
|
||||
}
|
||||
function OptToSnap {
|
||||
ret=$(echo "$1" \
|
||||
| grep -oP '^[A-Z_]+' \
|
||||
| tr '[:upper:]' '[:lower:]' \
|
||||
| sed 's|_|-|g')
|
||||
echo $ret
|
||||
}
|
||||
function ValToSnap {
|
||||
ret=$(echo "$1" \
|
||||
| grep -oP '=.*$' \
|
||||
| sed 's_^= __g' \
|
||||
| sed 's_^=__g' \
|
||||
| sed "s|SNAP_DIR_DATA|$SDATA|g" \
|
||||
| sed "s|SNAP_DIR_COMMON|$SCOMMON|g" \
|
||||
| sed 's|{}||g')
|
||||
echo $ret
|
||||
}
|
||||
|
||||
function CatToIni {
|
||||
ret=$(echo "$1" \
|
||||
| sed 's|-|.|g' \
|
||||
| sed 's|\ |_|g' \
|
||||
| sed 's|99|_|g')
|
||||
echo $ret
|
||||
}
|
||||
function OptToIni {
|
||||
ret=$(echo "$1" \
|
||||
| tr '[:lower:]' '[:upper:]' \
|
||||
| sed 's|-|_|g')
|
||||
echo $ret
|
||||
}
|
||||
|
||||
[[ "$1" = "configure" ]] \
|
||||
&& toIni \
|
||||
&& exit 0
|
||||
|
||||
[[ "$1" = "install" ]] \
|
||||
&& echo "Initial Configuration..." \
|
||||
&& mkdir -p $SNAP_COMMON/conf \
|
||||
&& toSnap init \
|
||||
&& toSnap snap \
|
||||
&& toIni sample \
|
||||
&& exit 0
|
||||
|
||||
[[ "$1" = "save" ]] \
|
||||
&& echo "Saving current config..." \
|
||||
&& toSnap \
|
||||
&& exit 0
|
|
@ -1,23 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
if ! env | grep -q root; then
|
||||
echo "
|
||||
+----------------------------------------+
|
||||
| You are not running gitea as root. |
|
||||
| This is required for the snap package. |
|
||||
| Please re-run as root. |
|
||||
+----------------------------------------+
|
||||
"
|
||||
$SNAP/gitea/gitea --help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Set usernames for gitea
|
||||
export USERNAME=root
|
||||
export USER=root
|
||||
|
||||
export GITEA_WORK_DIR=$(snapctl get gitea.snap.workdir)
|
||||
export GITEA_CUSTOM=$(snapctl get gitea.snap.custom)
|
||||
|
||||
$SNAP/bin/gconfig save
|
||||
cd $SNAP/gitea; ./gitea $@
|
3
snap/hooks/configure
vendored
3
snap/hooks/configure
vendored
|
@ -1,3 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
$SNAP/bin/gconfig configure
|
|
@ -1,45 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
export SDATA=$(echo $SNAP_DATA | sed "s|$SNAP_REVISION|current|")
|
||||
export SCOMMON="$SNAP_COMMON"
|
||||
export isRoot=`true`
|
||||
snapctl set gitea.snap.workdir="$SDATA/custom"
|
||||
snapctl set gitea.snap.custom="$SCOMMON"
|
||||
|
||||
function mkDirCommon(){
|
||||
for dir in $@; do
|
||||
mkdir -p "$SCOMMON/$dir"
|
||||
done
|
||||
}
|
||||
|
||||
function mkdirData(){
|
||||
for dir in $@; do
|
||||
mkdir -p "$SDATA/$dir"
|
||||
if [ -d $SNAP/$dir ]; then
|
||||
cp -r --preserve=mode \
|
||||
$SNAP/$dir/* \
|
||||
$SNAP/$dir/.[a-zA-Z0-9-]* \
|
||||
$SDATA/$dir/ 2> $SCOMMON/log/snap-mkdirData.log
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
mkDirCommon pictures \
|
||||
repositories \
|
||||
attachments \
|
||||
data \
|
||||
log
|
||||
|
||||
mkdirData certs \
|
||||
sshkeytest \
|
||||
custom/conf \
|
||||
static/templates \
|
||||
static/scripts \
|
||||
static/public
|
||||
|
||||
[[ -f $SNAP_COMMON/conf/app.ini ]] || $SNAP/bin/gconfig install
|
||||
|
||||
# Configure Git to use the right templates
|
||||
mkdir -p $SDATA/git/
|
||||
cp -r --preserve=mode $SNAP/usr/share/git-core/templates $SDATA/git/
|
||||
$SNAP/usr/bin/git config --global init.templateDir $SDATA/git/templates/
|
|
@ -6,93 +6,55 @@ description: |
|
|||
an independent binary distribution across ALL platforms that Go supports,
|
||||
including Linux, Mac OS X, Windows and ARM.
|
||||
|
||||
type: app
|
||||
icon: public/img/gitea-lg.png
|
||||
confinement: strict
|
||||
grade: stable
|
||||
base: core18
|
||||
adopt-info: gitea
|
||||
|
||||
version: 'git'
|
||||
environment:
|
||||
GITEA_CUSTOM: "$SNAP_COMMON"
|
||||
GITEA_WORK_DIR: "$SNAP_DATA"
|
||||
|
||||
apps:
|
||||
gitea:
|
||||
command: bin/gitea
|
||||
command: gitea
|
||||
plugs: [network, network-bind]
|
||||
web:
|
||||
command: bin/gitea web
|
||||
command: gitea web
|
||||
daemon: simple
|
||||
plugs: [network, network-bind]
|
||||
serv:
|
||||
command: bin/gitea serv
|
||||
plugs: [network, network-bind]
|
||||
admin:
|
||||
command: bin/gitea admin
|
||||
plugs: [network, network-bind]
|
||||
cert:
|
||||
command: bin/gitea cert
|
||||
hook:
|
||||
command: bin/gitea hook
|
||||
plugs: [network, network-bind]
|
||||
dump:
|
||||
command: bin/gitea dump
|
||||
command: gitea dump
|
||||
plugs: [home]
|
||||
help:
|
||||
command: bin/gitea --help
|
||||
version:
|
||||
command: bin/gitea --version
|
||||
command: gitea --version
|
||||
sqlite:
|
||||
command: usr/bin/sqlite3
|
||||
|
||||
parts:
|
||||
go:
|
||||
source-tag: go1.8.3
|
||||
prime:
|
||||
- -*
|
||||
|
||||
gitea:
|
||||
plugin: nil
|
||||
plugin: make
|
||||
source: .
|
||||
source-type: git
|
||||
after: [ go ]
|
||||
stage-packages: [ git, sqlite3, openssh-client ]
|
||||
build-packages: [ libpam0g-dev, libsqlite3-dev]
|
||||
prepare: |
|
||||
export PATH=$SNAPCRAFT_PART_INSTALL/../../go/install/bin:$PATH
|
||||
export GOPATH=$SNAPCRAFT_PART_INSTALL/../go
|
||||
export bld=$SNAPCRAFT_PART_INSTALL/../build
|
||||
export src=$SNAPCRAFT_PART_INSTALL/../src
|
||||
mkdir -p $GOPATH/src/code.gitea.io/gitea
|
||||
cp -r $src/* $GOPATH/src/code.gitea.io/gitea
|
||||
build: |
|
||||
export PATH=$SNAPCRAFT_PART_INSTALL/../go/bin/:$SNAPCRAFT_PART_INSTALL/../../go/install/bin:$PATH
|
||||
export GOPATH=$SNAPCRAFT_PART_INSTALL/../go
|
||||
cd $GOPATH/src/code.gitea.io/gitea
|
||||
build-packages: [ git, libpam0g-dev, libsqlite3-dev]
|
||||
build-snaps: [ go, node/14/stable ]
|
||||
build-environment:
|
||||
- LDFLAGS: ""
|
||||
override-pull: |
|
||||
snapcraftctl pull
|
||||
|
||||
version="$(git describe --always | sed -e 's/-/+git/;y/-/./')"
|
||||
[ -n "$(echo $version | grep "+git")" ] && grade=devel || grade=stable
|
||||
snapcraftctl set-version "$version"
|
||||
snapcraftctl set-grade "$grade"
|
||||
|
||||
override-build: |
|
||||
set -x
|
||||
TAGS="bindata sqlite sqlite_unlock_notify pam cert" make build
|
||||
install: |
|
||||
# Set Convenience Variables
|
||||
src=$SNAPCRAFT_PART_INSTALL/../go/src/code.gitea.io/gitea
|
||||
giteaBase=$SNAPCRAFT_PART_INSTALL/gitea
|
||||
scurrent=/var/snap/$SNAPCRAFT_PROJECT_NAME/current
|
||||
scommon=/var/snap/$SNAPCRAFT_PROJECT_NAME/common
|
||||
# Copy build artifact and necessary files
|
||||
mkdir -p $giteaBase/conf
|
||||
# Workaround for gitea ignoring APP_DATA_PATH in app.ini after snap update.
|
||||
ln -s $scurrent/custom $giteaBase/custom
|
||||
ln -s $scommon/data $giteaBase/data
|
||||
# Workaround for cmd/certs not knowing how to put files somewhere else
|
||||
ln -s $scurrent/cert.pem $giteaBase/cert.pem
|
||||
ln -s $scurrent/key.pem $giteaBase/key.pem
|
||||
# Copy static content
|
||||
mkdir -p $SNAPCRAFT_PART_INSTALL/static
|
||||
cp $src/gitea $giteaBase/
|
||||
cp -r $src/LICENSE \
|
||||
$src/templates \
|
||||
$src/public \
|
||||
$src/scripts \
|
||||
$SNAPCRAFT_PART_INSTALL/static/
|
||||
cp -r $src/README.md \
|
||||
$src/LICENSE \
|
||||
$src/custom \
|
||||
$SNAPCRAFT_PART_INSTALL/
|
||||
install -D gitea "${SNAPCRAFT_PART_INSTALL}/gitea"
|
||||
cp -r options "${SNAPCRAFT_PART_INSTALL}/"
|
||||
|
||||
prime:
|
||||
- -etc
|
||||
- -usr/lib/systemd
|
||||
|
@ -101,20 +63,7 @@ parts:
|
|||
- -usr/lib/x86_64-linux-gnu/krb5
|
||||
- -usr/share/apport
|
||||
- -usr/share/bash-completion
|
||||
- -usr/share/doc
|
||||
- -usr/share/git-core/contrib
|
||||
- -usr/share/man
|
||||
- -usr/share/upstart
|
||||
- -var
|
||||
|
||||
helpers:
|
||||
plugin: dump
|
||||
source: snap/helpers
|
||||
organize:
|
||||
simple_launcher.sh: bin/gitea
|
||||
app.ini: gitea/snapApp.ini
|
||||
configuration.sh: bin/gconfig
|
||||
prime:
|
||||
- bin/gitea
|
||||
- bin/gconfig
|
||||
- gitea/snapApp.ini
|
||||
|
|
Reference in a new issue