瀏覽代碼

Update build script + add some workarounds

Thomas Fanninger 10 年之前
父節點
當前提交
e968dc72bc
共有 5 個文件被更改,包括 205 次插入48 次删除
  1. 5 3
      .SRCINFO
  2. 62 27
      PKGBUILD
  3. 22 9
      app_new.ini
  4. 22 9
      app_old.ini
  5. 94 0
      helper.sh

+ 5 - 3
.SRCINFO

@@ -1,17 +1,17 @@
 pkgbase = gogs
 pkgbase = gogs
 	pkgdesc = Gogs(Go Git Service) is a Self Hosted Git Service in the Go Programming Language.
 	pkgdesc = Gogs(Go Git Service) is a Self Hosted Git Service in the Go Programming Language.
 	pkgver = 0.6.5
 	pkgver = 0.6.5
-	pkgrel = 4
+	pkgrel = 5
 	epoch = 1
 	epoch = 1
 	url = http://gogs.io/
 	url = http://gogs.io/
 	install = gogs.install
 	install = gogs.install
-	changelog = gogs.changelog
 	arch = i686
 	arch = i686
 	arch = x86_64
 	arch = x86_64
 	arch = armv6h
 	arch = armv6h
 	arch = armv7h
 	arch = armv7h
 	license = MIT
 	license = MIT
 	makedepends = go>=1.2
 	makedepends = go>=1.2
+	makedepends = git>=1.7.1
 	makedepends = patch
 	makedepends = patch
 	depends = git>=1.7.1
 	depends = git>=1.7.1
 	optdepends = sqlite: SQLite support
 	optdepends = sqlite: SQLite support
@@ -21,16 +21,18 @@ pkgbase = gogs
 	optdepends = memcached: MemCached support
 	optdepends = memcached: MemCached support
 	optdepends = openssh: GIT over SSH support
 	optdepends = openssh: GIT over SSH support
 	conflicts = gogs-bin
 	conflicts = gogs-bin
+	conflicts = gogs
 	conflicts = gogs-git
 	conflicts = gogs-git
-	conflicts = gogs-git-dev
 	options = !strip
 	options = !strip
 	options = !emptydirs
 	options = !emptydirs
 	backup = srv/gogs/conf/app.ini
 	backup = srv/gogs/conf/app.ini
 	source = gogs.service
 	source = gogs.service
 	source = app.ini.patch
 	source = app.ini.patch
+	source = helper.sh
 	source = gogs::git+https://github.com/gogits/gogs.git#tag=v0.6.5
 	source = gogs::git+https://github.com/gogits/gogs.git#tag=v0.6.5
 	sha512sums = 2b4303f850e3b13b2fc3c9f0bc5820dae431d228002b35f01be0d4bfbcf05de8dcec2a559a85e318b609e4a4d492d44306eadf5f6508fd72333b198661bb0bb7
 	sha512sums = 2b4303f850e3b13b2fc3c9f0bc5820dae431d228002b35f01be0d4bfbcf05de8dcec2a559a85e318b609e4a4d492d44306eadf5f6508fd72333b198661bb0bb7
 	sha512sums = 939be9ad851ae6e20b786e2e189b0b67c0198edfc8c83442934ec48c7be073e03c75172e79f23a6ee1e0eb467c6fa18096a66d69d1142ebba28fdc8bb2a3964c
 	sha512sums = 939be9ad851ae6e20b786e2e189b0b67c0198edfc8c83442934ec48c7be073e03c75172e79f23a6ee1e0eb467c6fa18096a66d69d1142ebba28fdc8bb2a3964c
+	sha512sums = e746dbdafc4c8d0b15a224dba95ae3151611ba9ff468ee6f0b1789e489955e4d7eaac0dbdf28a22e5b8211559af5950726f4a37d699a2490fd349f034401028c
 	sha512sums = SKIP
 	sha512sums = SKIP
 
 
 pkgname = gogs
 pkgname = gogs

+ 62 - 27
PKGBUILD

@@ -1,15 +1,13 @@
 # Contributor: Thomas Laroche <tho.laroche@gmail.com>
 # Contributor: Thomas Laroche <tho.laroche@gmail.com>
-# Contributor: Kristian Klausen <klausenbusk@hotmail.com>
 # Maintainer: Thomas Fanninger <thomas@fanninger.at>
 # Maintainer: Thomas Fanninger <thomas@fanninger.at>
 
 
 pkgname=gogs
 pkgname=gogs
 _pkgname=${pkgname}
 _pkgname=${pkgname}
 pkgver=0.6.5
 pkgver=0.6.5
-pkgrel=4
+pkgrel=5
 epoch=1
 epoch=1
 pkgdesc="Gogs(Go Git Service) is a Self Hosted Git Service in the Go Programming Language."
 pkgdesc="Gogs(Go Git Service) is a Self Hosted Git Service in the Go Programming Language."
 arch=('i686' 'x86_64' 'armv6h' 'armv7h')
 arch=('i686' 'x86_64' 'armv6h' 'armv7h')
-changelog=$pkgname.changelog
 url="http://gogs.io/"
 url="http://gogs.io/"
 license=('MIT')
 license=('MIT')
 depends=('git>=1.7.1')
 depends=('git>=1.7.1')
@@ -19,50 +17,87 @@ optdepends=('sqlite: SQLite support'
             'redis: Redis support'
             'redis: Redis support'
             'memcached: MemCached support'
             'memcached: MemCached support'
             'openssh: GIT over SSH support')
             'openssh: GIT over SSH support')
-makedepends=('go>=1.2' 'patch')
-conflicts=('gogs-bin' 'gogs-git' 'gogs-git-dev')
+makedepends=('go>=1.2' 'git>=1.7.1' 'patch')
+conflicts=('gogs-bin' 'gogs' 'gogs-git')
 options=('!strip' '!emptydirs')
 options=('!strip' '!emptydirs')
 backup=('srv/gogs/conf/app.ini')
 backup=('srv/gogs/conf/app.ini')
 
 
 install=gogs.install
 install=gogs.install
 
 
-_gourl=github.com/gogits
+_gourl=github.com/gogits/$_pkgname
 source=('gogs.service'
 source=('gogs.service'
         'app.ini.patch'
         'app.ini.patch'
-        "${_pkgname}::git+https://${_gourl}/${_pkgname}.git#tag=v${pkgver}")
+        'helper.sh'
+        "$_pkgname::git+https://${_gourl}.git#tag=v${pkgver}")
 
 
-sha512sums=('2b4303f850e3b13b2fc3c9f0bc5820dae431d228002b35f01be0d4bfbcf05de8dcec2a559a85e318b609e4a4d492d44306eadf5f6508fd72333b198661bb0bb7'
-            '939be9ad851ae6e20b786e2e189b0b67c0198edfc8c83442934ec48c7be073e03c75172e79f23a6ee1e0eb467c6fa18096a66d69d1142ebba28fdc8bb2a3964c'
+sha512sums=(2b4303f850e3b13b2fc3c9f0bc5820dae431d228002b35f01be0d4bfbcf05de8dcec2a559a85e318b609e4a4d492d44306eadf5f6508fd72333b198661bb0bb7
+            939be9ad851ae6e20b786e2e189b0b67c0198edfc8c83442934ec48c7be073e03c75172e79f23a6ee1e0eb467c6fa18096a66d69d1142ebba28fdc8bb2a3964c
+            e746dbdafc4c8d0b15a224dba95ae3151611ba9ff468ee6f0b1789e489955e4d7eaac0dbdf28a22e5b8211559af5950726f4a37d699a2490fd349f034401028c
             'SKIP')
             'SKIP')
 
 
+_goroot="/usr/lib/go"
 
 
 prepare() {
 prepare() {
-  mkdir -p "${srcdir}/src/${_gourl}"
-  mv "${_pkgname}" "${srcdir}/src/${_gourl}/${_pkgname}"
-  msg2 "go get"
-  GOPATH="${srcdir}" go get -tags "sqlite redis memcache" "${_gourl}/${_pkgname}"
+  source $srcdir/helper.sh
+
+  export GOROOT=/usr/lib/go
+  
+  msg2 "Prepare GO build enviroment"
+  rm -rf build
+  mkdir -p build/go
+  cd build/go
+
+  for f in "$GOROOT/"*; do
+    ln -s "$f"
+  done
+
+  rm pkg
+  mkdir pkg
+  cd pkg
+
+  for f in "$GOROOT/pkg/"*; do
+    ln -s "$f"
+  done
+
+  export GOROOT="$srcdir/build/go"
+  export GOPATH="$srcdir/build"
   
   
-  msg2 "Patch: GOGS app.ini"
-  patch -Np1 -i "${srcdir}/app.ini.patch" "${srcdir}/src/${_gourl}/${_pkgname}/conf/app.ini"
+  mkdir -p "$GOPATH/src/github.com/gogits"
+
+  mv "$srcdir/$_pkgname" $GOPATH/src/${_gourl}
+
+  msg2 "Check and download dependencies from .gopmfile"
+  get_gopm "$GOPATH/src/${_gourl}/.gopmfile" "$GOPATH/src"
+
+  msg2 "Download missing dependencies"
+  go_get github.com/shurcooL/sanitized_anchor_name "$GOPATH/src/github.com/shurcooL/sanitized_anchor_name"
+
+#  msg2 "Workaround dependencies"
+#  cd "$GOPATH/src/github.com/gogits/go-gogs-client/"
+#  git checkout -q master
+
+  # Execute patch
+  msg2 "Execute patches"
+  patch -Np1 -i "$srcdir/app.ini.patch" "$GOPATH/src/${_gourl}/conf/app.ini"
 }
 }
 
 
 build() {
 build() {
+  cd $GOPATH/src/${_gourl}
+
   msg2 "Build program"
   msg2 "Build program"
-  cd ${srcdir}/src/${_gourl}/${_pkgname}
-  GOPATH="${srcdir}" go fix
-  GOPATH="${srcdir}" go build -tags "sqlite redis memcache cert"
+  go fix
+  go build -x -tags='sqlite redis memcache'
 }
 }
 
 
 package() {
 package() {
-  install -D -m 0755 "${srcdir}/src/${_gourl}/${_pkgname}/${_pkgname}" "${pkgdir}/usr/share/${_pkgname}/${_pkgname}"
+  install -Dm0755 "$srcdir/build/src/${_gourl}/$_pkgname" "$pkgdir/usr/share/$_pkgname/$_pkgname"
 
 
-  cp -r "${srcdir}/src/${_gourl}/${_pkgname}/conf" "${pkgdir}/usr/share/${_pkgname}"
-  install -d "${pkgdir}/usr/share/themes/gogs/default/"
-  cp -r "${srcdir}/src/${_gourl}/${_pkgname}/public" "${pkgdir}/usr/share/themes/gogs/default"
-  cp -r "${srcdir}/src/${_gourl}/${_pkgname}/templates" "${pkgdir}/usr/share/themes/gogs/default"
+  cp -r "$srcdir/build/src/${_gourl}/conf" "$pkgdir/usr/share/$_pkgname"
+  mkdir -p "$pkgdir/usr/share/themes/gogs/default/"
+  cp -r "$srcdir/build/src/${_gourl}/public" "$pkgdir/usr/share/themes/gogs/default"
+  cp -r "$srcdir/build/src/${_gourl}/templates" "$pkgdir/usr/share/themes/gogs/default"
 
 
-  install -D -m 0600 "${pkgdir}/usr/share/${_pkgname}/conf/app.ini" "$pkgdir/srv/${_pkgname}/conf/app.ini"
-  install -D -m 0644 "${srcdir}/gogs.service" "$pkgdir/usr/lib/systemd/system/gogs.service"
-  install -d "${pkgdir}/var/log/gogs"
-  install -D -m 0644 "${srcdir}/src/${_gourl}/${_pkgname}/LICENSE" "${pkgdir}/usr/share/licenses/$_pkgname"
+  install -Dm0644 "$pkgdir/usr/share/$_pkgname/conf/app.ini" "$pkgdir/srv/$_pkgname/conf/app.ini"
+  install -Dm0644 "$srcdir/gogs.service" "$pkgdir/usr/lib/systemd/system/gogs.service"
+  install -Dm0644 "$srcdir/build/src/${_gourl}/LICENSE" "$pkgdir/usr/share/licenses/$_pkgname"
 }
 }

+ 22 - 9
app_new.ini

@@ -281,21 +281,34 @@ DRIVER =
 ; Based on xorm, e.g.: root:root@localhost/gogs?charset=utf8
 ; Based on xorm, e.g.: root:root@localhost/gogs?charset=utf8
 CONN =
 CONN =
 
 
+[cron]
+; Enable running cron tasks periodically.
+ENABLED = true
+; Run cron tasks when Gogs starts.
+RUN_AT_START = false
+
+; Update mirrors
+[cron.update_mirrors]
+SCHEDULE = @every 1h
+
+; Repository health check
+[cron.repo_health_check]
+SCHEDULE = @every 24h
+; Arguments for command 'git fsck', e.g.: "--unreachable --tags"
+; see more on http://git-scm.com/docs/git-fsck/1.7.5
+ARGS = 
+
+; Check repository statistics
+[cron.check_repo_stats]
+RUN_AT_START = true
+SCHEDULE = @every 24h
+
 [git]
 [git]
 MAX_GIT_DIFF_LINES = 10000
 MAX_GIT_DIFF_LINES = 10000
 ; Arguments for command 'git gc', e.g.: "--aggressive --auto"
 ; Arguments for command 'git gc', e.g.: "--aggressive --auto"
 ; see more on http://git-scm.com/docs/git-gc/1.7.5
 ; see more on http://git-scm.com/docs/git-gc/1.7.5
 GC_ARGS = 
 GC_ARGS = 
 
 
-; Git health check.
-[git.fsck]
-ENABLE = true
-; Execution interval in hours. Default is 24.
-INTERVAL = 24
-; Arguments for command 'git fsck', e.g.: "--unreachable --tags"
-; see more on http://git-scm.com/docs/git-fsck/1.7.5
-ARGS = 
-
 [i18n]
 [i18n]
 LANGS = en-US,zh-CN,zh-HK,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,ja-JP,es-ES,pt-BR,pl-PL,bg-BG,it-IT
 LANGS = en-US,zh-CN,zh-HK,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,ja-JP,es-ES,pt-BR,pl-PL,bg-BG,it-IT
 NAMES = English,简体中文,繁體中文,Deutsch,Français,Nederlands,Latviešu,Русский,日本語,Español,Português do Brasil,Polski,български,Italiano
 NAMES = English,简体中文,繁體中文,Deutsch,Français,Nederlands,Latviešu,Русский,日本語,Español,Português do Brasil,Polski,български,Italiano

+ 22 - 9
app_old.ini

@@ -281,21 +281,34 @@ DRIVER =
 ; Based on xorm, e.g.: root:root@localhost/gogs?charset=utf8
 ; Based on xorm, e.g.: root:root@localhost/gogs?charset=utf8
 CONN =
 CONN =
 
 
+[cron]
+; Enable running cron tasks periodically.
+ENABLED = true
+; Run cron tasks when Gogs starts.
+RUN_AT_START = false
+
+; Update mirrors
+[cron.update_mirrors]
+SCHEDULE = @every 1h
+
+; Repository health check
+[cron.repo_health_check]
+SCHEDULE = @every 24h
+; Arguments for command 'git fsck', e.g.: "--unreachable --tags"
+; see more on http://git-scm.com/docs/git-fsck/1.7.5
+ARGS = 
+
+; Check repository statistics
+[cron.check_repo_stats]
+RUN_AT_START = true
+SCHEDULE = @every 24h
+
 [git]
 [git]
 MAX_GIT_DIFF_LINES = 10000
 MAX_GIT_DIFF_LINES = 10000
 ; Arguments for command 'git gc', e.g.: "--aggressive --auto"
 ; Arguments for command 'git gc', e.g.: "--aggressive --auto"
 ; see more on http://git-scm.com/docs/git-gc/1.7.5
 ; see more on http://git-scm.com/docs/git-gc/1.7.5
 GC_ARGS = 
 GC_ARGS = 
 
 
-; Git health check.
-[git.fsck]
-ENABLE = true
-; Execution interval in hours. Default is 24.
-INTERVAL = 24
-; Arguments for command 'git fsck', e.g.: "--unreachable --tags"
-; see more on http://git-scm.com/docs/git-fsck/1.7.5
-ARGS = 
-
 [i18n]
 [i18n]
 LANGS = en-US,zh-CN,zh-HK,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,ja-JP,es-ES,pt-BR,pl-PL,bg-BG,it-IT
 LANGS = en-US,zh-CN,zh-HK,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,ja-JP,es-ES,pt-BR,pl-PL,bg-BG,it-IT
 NAMES = English,简体中文,繁體中文,Deutsch,Français,Nederlands,Latviešu,Русский,日本語,Español,Português do Brasil,Polski,български,Italiano
 NAMES = English,简体中文,繁體中文,Deutsch,Français,Nederlands,Latviešu,Русский,日本語,Español,Português do Brasil,Polski,български,Italiano

+ 94 - 0
helper.sh

@@ -0,0 +1,94 @@
+#!/bin/bash 
+
+# $1 = package name
+# $2 = target directory path
+# $3 = branch/commit/revision string, if empty then maste ist used
+function go_get {
+  if [[ $1 == github.com* ]]
+  then 
+    get_git $1 $2 $3
+  elif [[ $1 == code.google.com* ]]
+  then 
+    get_hg $1 $2 $3
+  elif [[ $1 == golang.org* ]]
+  then 
+    get_golang $1 $2 $3
+  else
+    go get $1
+  fi
+}
+
+# $1 = git package
+# $2 = target directory path
+# $3 = branch/commit/revision string, if empty then maste ist used
+function get_git {
+  git clone https://$1 $2
+  if [[ $3 != "master" ]] && [[ ${3:0} == commit* ]]
+  then
+    cd $2
+    git checkout -q ${3:7}
+  elif [[ $3 != "master" ]] && [[ ${3:0} == tag* ]]
+  then
+    cd $2
+    git checkout -q tags/${3:4}
+  else
+    cd $2
+    git checkout -q ${3:7}
+  fi
+}
+
+# $1 = mercury package name
+# $2 = target directory path
+# $3 = branch/commit/revision string, if empty then maste ist used
+function get_hg {
+  if [[ $3 == "master" ]] || [[ $3 == "" ]]
+  then
+    hg clone https://$1 $2
+  else
+    hg clone https://$1 -r $3 $2
+  fi
+}
+
+function get_golang {
+  if [[ $1 == "golang.org/x/net" ]]
+  then
+    echo $1 $2 $3
+    get_git "github.com/golang/net" $2
+  elif [[ $1 == "golang.org/x/text" ]]
+  then
+    echo $1 $2 $3
+    get_git "github.com/golang/text" $2
+  else
+    echo $1 $2 $3
+  fi
+
+}
+
+# Read the .gopmfile file and clone the branch/commits of the depends
+# $1 = .gopmfile file path
+# $2 = target directory path
+function get_gopm {
+  local startStr=""
+  local revStr=""
+
+  while read line
+  do
+    if [[ $startStr == 'X' ]] && [[ $line == '' ]]
+    then
+      break
+    elif [[ $startStr == 'X' ]]
+    then
+      IFS="=" read -a array <<< "$line"
+      if [[ ${array[1]} != "" ]]
+      then
+        local revStr=${array[1]//\`}
+        go_get ${array[0]} "$2/${array[0]}" $revStr
+      else
+        go_get ${array[0]} "$2/${array[0]}" master
+      fi
+    elif [[ $line == '[deps]' ]]
+    then
+      local startStr="X"
+    fi
+  done <$1
+}