summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: fb1594105206b063d62c53585470903f9becedbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Maintainer: Yunhui Fu <yhfudev@gmail.com>

pkgbase=hustoj-git
pkgname=hustoj-git

# Dirty hack as AUR dont support split-packages
true && pkgname=('hustoj-judge-git' 'hustoj-web-git')

pkgver=r3120.58b04b80
pkgrel=1
pkgdesc='HUST Online Judge'
arch=('i686' 'x86_64' 'armv6h' 'armv7h' 'arm')
url='https://github.com/zhblue/hustoj.git'
license=('GPL')
makedepends=('git' 'libmariadbclient')
options=('emptydirs')
install="hustoj.install"
source=(
    #"${pkgbase}-${pkgver}.tar.gz::https://github.com/zhblue/hustoj/archive/${pkgver}.tar.gz"
    "${pkgbase}::git+https://github.com/zhblue/hustoj.git"
    "hustoj.install"
    "sethustoj.sh"
    )
sha256sums=('SKIP'
            '4fdf2875aa03b98ecc0a6e732159653542930b5f26b1877388faa96ee83b0435'
            '6cfe333bc5fed6f9c8e64c72dffb852c54b5142d01278c00d1eda51927b1291f'
    )

pkgver_git() {
    cd "${srcdir}/${pkgbase}"
    #local ver="$(git show | grep commit | awk '{print $2}' )"
    #printf "r%s" "${ver//[[:alpha:]]}"
    #echo ${ver:0:7}
    echo "r$(git rev-list --count HEAD).$(git rev-parse --short HEAD)"
}

pkgver() {
    pkgver_git
}

prepare() {
  cd "${srcdir}/${pkgbase}"
  msg "git fetch --all"
  git remote set-url origin ${url}
  git fetch --all

  case $CARCH in
  i686|x86_64)
    git checkout remotes/origin/master
    ;;
  armv6h|armv7h|arm)
    git checkout remotes/origin/rpi
    ;;
  esac
}

build() {
    cd "${srcdir}/${pkgbase}"
    cd trunk/core/judged
    make
    cd ../judge_client
    make
    cd ../sim/sim_2_77
    #make fresh
    make exes
}

package_hustoj-judge-git() {
  pkgdesc="HUST Online Judge binaries"
  conflicts=('hustoj-judge')
  provides=("hustoj-judge")

  msg 'Preparing package ...'

  install -d "$pkgdir/usr/bin"
  install -d "$pkgdir/usr/share"

  cp -r "${pkgbase}/trunk/install/" "$pkgdir/usr/share/hustoj"

  cd "${srcdir}/${pkgbase}"
  cd trunk/core/judged
  cp judged $pkgdir/usr/bin
  chmod +x $pkgdir/usr/bin/judged
  cd ../judge_client
  cp judge_client $pkgdir/usr/bin
  chmod +x $pkgdir/usr/bin/judge_client
  cd ../sim/sim_2_77
  cp sim_c.exe $pkgdir/usr/bin/sim_c
  cp sim_java.exe $pkgdir/usr/bin/sim_java
  cp sim_pasc.exe $pkgdir/usr/bin/sim_pas
  cp sim_text.exe $pkgdir/usr/bin/sim_text
  cp sim_lisp.exe $pkgdir/usr/bin/sim_scm
  chmod +x $pkgdir/usr/bin/sim*
  cd ..
  cp sim.sh $pkgdir/usr/bin
  chmod +x $pkgdir/usr/bin/sim.sh
  rm -f $pkgdir/usr/bin/sim_cc $pkgdir/usr/bin/sim_rb $pkgdir/usr/bin/sim_sh
  ln -s sim_c $pkgdir/usr/bin/sim_cc

  cp ${srcdir}/sethustoj.sh "$pkgdir/usr/share/hustoj/"
}

package_hustoj-web-git() {
  pkgdesc="HUST Online Judge web UI"
  conflicts=('hustoj-web')
  provides=("hustoj-web")
  arch=('any')

  install=hustoj.install

  depends=('php' 'php-fpm' 'php-gd')
  optdepends=('nginx: Web server for serving Wordpress'
            'apache: Web server for serving Wordpress'
            'mariadb: Database server')

  msg 'Preparing package ...'

  install -d "$pkgdir/usr/share"
  install -d "$pkgdir/usr/share/webapps"

  cp -r "${pkgbase}/trunk/web/" "$pkgdir/usr/share/webapps/hustoj"
  chown http:http -R "$pkgdir/usr/share/webapps/hustoj"
}

# vim: ts=2 sw=2 et: