diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-10-20 17:49:49 -0400 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-10-20 17:49:49 -0400 |
commit | 8a605d4d9f6a191081d2d2e71badfd75a3c0a66a (patch) | |
tree | 90cdbb39e31fb81fda71d3eadb96573e0391bee3 | |
parent | be61bc10d8a9af8fc8b671e8ac743b99caaa34f2 (diff) |
redo libre/parabolaweb-git into libre/parabolaweb-utils
-rwxr-xr-x | Makefile | 26 | ||||
-rw-r--r--[-rwxr-xr-x] | PKGBUILD | 52 | ||||
-rwxr-xr-x | deps-ver.txt | 7 | ||||
-rw-r--r-- | helper.sh | 37 | ||||
-rw-r--r--[-rwxr-xr-x] | parabolaweb.init.sh | 33 | ||||
-rwxr-xr-x | parabolaweb.update.sh.in | 59 | ||||
-rwxr-xr-x | requirements_prod.txt | 7 | ||||
-rw-r--r-- | update-parabolaweb | 81 |
8 files changed, 157 insertions, 145 deletions
diff --git a/Makefile b/Makefile deleted file mode 100755 index 55115ab..0000000 --- a/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -all: - makepkg - -python_packages=south -python2_packages=markdown|psycopg2|pyinotify|pytz -requirements= https://projects.parabolagnulinux.org/parabolaweb.git/plain/requirements_prod.txt - -requirements_prod.txt: WEB - rm -f $@ - wget --no-check-certificate $(requirements) - -deps-ver.txt: requirements_prod.txt - sed -r -e 's/.*/\L&/' -e 's/==/=/' \ - -e 's/^(${python_packages})/python-&/' \ - -e 's/^(${python2_packages})/python2-&/' $< >$@ - -deps-nover.txt: deps-ver.txt - sed 's/[<>=].*//' $< >$@ - -clean: - rm requirements_prod.txt deps-ver.txt deps-nover.txt - -WEB: FORCE -FORCE: PHONY -PHONY: -.PHONY: PHONY @@ -1,43 +1,37 @@ # Maintainer: Luke Shumaker <lukeshu@sbcglobal.net> -pkgname=parabolaweb-git -pkgver=20120506 -pkgrel=3 -pkgdesc="The Parabola website, fork of archweb" +. helper.sh +# provides: +# _get_pkgver +# _get_depends +# _get_depends_nover (no version requirements) + +pkgname=parabolaweb-utils +pkgver=`_get_pkgver` +pkgrel=1 +pkgdesc="Utils for the Parabola website" arch=('any') url="https://projects.parabolagnulinux.org/parabolaweb.git/" license=('GPL2') +depends=('python2' 'git' 'libretools' `_get_depends`) -_deps_file=deps-ver.txt -#_deps_file=deps-nover.txt -make "$_deps_file" 1>&2 -depends=('python2' 'git' 'libretools' `cat $_deps_file`) +export pkgver -source=('parabolaweb.init.sh' 'parabolaweb.update.sh.in') - -# These will make it install into /http/srv/web -_install_dir=/srv/http -_gitname=web - -_gitroot=https://projects.parabolagnulinux.org/parabolaweb.git -_gitbranch="master" +source=(git://parabolagnulinux.org/parabolaweb.git + parabolaweb.init.sh + update-parabolaweb) build() { - cd "${srcdir}" - sed \ - -e "s|^_install_dir=.*|_install_dir='$_install_dir'|" \ - -e "s|^_gitname=.*|_gitname='$_gitname'|" \ - -e "s|^_gitroot=.*|_gitroot='$_gitroot'|" \ - -e "s|^_gitbranch=.*|_gitbranch='$_gitbranch'|" \ - < parabolaweb.update.sh.in > parabolaweb.update.sh + : } package() { - cd "${srcdir}" - install -d "${pkgdir}/${_install_dir}" - install -Dm755 parabolaweb.init.sh "${pkgdir}/etc/rc.d/parabolaweb" - install -Dm755 parabolaweb.update.sh "${pkgdir}/usr/sbin/parabolaweb.update" + cd "${srcdir}" + install -d "${pkgdir}/${_install_dir}" + install -Dm755 parabolaweb.init.sh "${pkgdir}/etc/rc.d/parabolaweb" + install -Dm755 update-parabolaweb "${pkgdir}/usrls/sbin/update-parabolaweb" } -md5sums=('72bc7092e4e50a2aaca8b871644520d9' - 'f495b2e4623691925308cb4a1ec7e5a9') +md5sums=('SKIP' + 'f52aebbedaa61f688fb2bc626a783003' + 'dd05d6a4ea7cff7fdd789f59aeb9059a') diff --git a/deps-ver.txt b/deps-ver.txt deleted file mode 100755 index 67fe684..0000000 --- a/deps-ver.txt +++ /dev/null @@ -1,7 +0,0 @@ -django=1.3.1 -python2-markdown>=2.0.3 -python2-psycopg2 -python-south>=0.7.3 -python2-pyinotify>=0.9.2 -python-memcached>=1.47 -python2-pytz>=2011n diff --git a/helper.sh b/helper.sh new file mode 100644 index 0000000..d00f83f --- /dev/null +++ b/helper.sh @@ -0,0 +1,37 @@ +_mksource() { + if [[ -z _DO_NOT_RUN_MKSOURCE ]]; then + _DO_NOT_RUN_MKSOURCE=true makepkg -o + fi +} + +_get_pkgver() { + if [[ -n $pkgver ]] && [[ $pkgver != 0.bogus ]]; then + echo $pkgver + else + _mksource 1>&2 + if [[ -f "${srcdir:-src}/parabolaweb/requirements_prod.txt" ]]; then + pushd "${srcdir:-src}/parabolaweb" >/dev/null + # get the date requirements_prod.txt was last modified + gitdate="$(git log -n1 --date=iso --format=format:'%cd' ./requirements_prod.txt)" + date -u +%Y%m%d.%H%M -d "$gitdate" + popd >/dev/null + else + echo 0.bogus + fi + fi +} + +_get_depends() { + _mksource 1>&2 + pushd "${srcdir:-src}" >/dev/null + python2_packages='markdown|psycopg2|pyinotify|pytz|south' + < parabolaweb/requirements_prod.txt sed -r \ + -e 's/.*/\L&/' -e 's/==/=/' \ + -e 's/^python-memcached/python2-memcached/' \ + -e "s/^(${python2_packages})/python2-&/" + popd >/dev/null +} + +_get_depends_nover() { + _get_depends | sed 's/[<>=].*//' +} diff --git a/parabolaweb.init.sh b/parabolaweb.init.sh index cb9f244..0ff8ecd 100755..100644 --- a/parabolaweb.init.sh +++ b/parabolaweb.init.sh @@ -10,29 +10,28 @@ PIDFILE=/var/run/web/fcgi.pid case $1 in start) stat_busy "Starting ParabolaWeb" - if [[ -e /srv/http/web/manage.py ]]; then - sudo -u nobody \ - python2 /srv/http/web/manage.py runfcgi \ - host=${HOST} \ - port=${PORT} \ - pidfile=${PIDFILE} \ - --settings=settings - - add_daemon parabolaweb - stat_done - exit 0 + if [[ -e /srv/http/web/manage.py ]]; then + sudo -u nobody \ + python2 /srv/http/web/manage.py runfcgi \ + host=${HOST} \ + port=${PORT} \ + pidfile=${PIDFILE} \ + --settings=settings + add_daemon parabolaweb + stat_done + exit 0 else - stat_fail - exit 1 + stat_fail + exit 1 fi ;; stop) stat_busy "Stopping ParabolaWeb" - if [[ -f ${PIDFILE} ]]; then - pid=$(cat ${PIDFILE}) - kill ${pid} - rm_daemon parabolaweb + if [[ -f ${PIDFILE} ]]; then + pid=$(cat ${PIDFILE}) + kill ${pid} + rm_daemon parabolaweb stat_done else stat_fail diff --git a/parabolaweb.update.sh.in b/parabolaweb.update.sh.in deleted file mode 100755 index 8c3aef0..0000000 --- a/parabolaweb.update.sh.in +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh -set -e - -_install_dir=@INSTALL_DIR@ -_gitname=@GIT_NAME@ - -_gitroot=@GITROOT@ -_gitbranch=@GITBRANCH@ - -. /usr/bin/libremessages - -if [ ! -d "$_install_dir" ]; then - mkdir "$_install_dir" -fi -cd "$_install_dir" - -msg "Connecting to GIT server...." -if [ -d ${_gitname} ] ; then - msg2 "Updating existing tree" - cd ${_gitname} && git pull ${_gitroot} -else - msg2 "Cloning tree" - git clone ${_gitroot} ${_gitname} - cd ${_gitname} -fi -git checkout ${_gitbranch} -msg "GIT checkout done or server timeout" - -msg "Purging old .pyc files...." -find . -name '*.pyc' -delete - -msg "Checking configuration...." -if [ ! -f local_settings.py ]; then - cp local_settings.py.example local_settings.tmp.$$.py - if ${EDITOR:-xdg-open} local_settings.tmp.$$.py; then - mv local_settings.tmp.$$.py local_settings.py - else - rm local_settings.tmp.$$.py - msg "Failed to configure, exiting" - exit 1 - fi - msg "Creating database...." - ./manage.py syncdb -fi - -msg "Purging old .pyc files...." -find . -name '*.pyc' -delete - -msg "Updating database...." -msg2 "Running migrations...." -./manage.py migrate -msg2 "Loading fixtures...." -./manage.py loaddata */fixtures/*.json - -msg "Checking media/admin_media symlink...." -if [ ! -e media/admin-media ]; then - rm media/admin_media - ln -s /usr/lib/python2.7/site-packages/django/contrib/admin/media media/admin_media -fi diff --git a/requirements_prod.txt b/requirements_prod.txt deleted file mode 100755 index 78eb512..0000000 --- a/requirements_prod.txt +++ /dev/null @@ -1,7 +0,0 @@ -Django==1.3.1 -Markdown>=2.0.3 -psycopg2 -South>=0.7.3 -pyinotify>=0.9.2 -python-memcached>=1.47 -pytz>=2011n diff --git a/update-parabolaweb b/update-parabolaweb new file mode 100644 index 0000000..e4d65c2 --- /dev/null +++ b/update-parabolaweb @@ -0,0 +1,81 @@ +#!/bin/bash +set -e + +_install_dir=/srv/http +_gitname=web +_gitroot=git://parabolagnulinux.org/parabolaweb.git +_gitbranch=master + +. /usr/bin/libremessages + +download() { + msg "Connecting to GIT server...." + cd "$_install_dir" + if [[ -d ${_gitname} ]]; then + msg2 "Updating existing tree" + cd ${_gitname} && git pull ${_gitroot} + else + msg2 "Cloning tree" + git clone ${_gitroot} ${_gitname} + cd ${_gitname} + fi + git checkout ${_gitbranch} + msg "GIT checkout done or server timeout" +} + +clean() { + msg "Purging old .pyc files...." + cd "$_install_dir/$_gitname" + find . -name '*.pyc' -delete +} + +configure() { + msg "Checking configuration...." + cd "$_install_dir/$_gitname" + if [[ ! -f local_settings.py ]]; then + msg2 "Configuration file missing, opening editor..." + cp local_settings.py.example local_settings.tmp.$$.py + if "$EDITOR" local_settings.tmp.$$.py; then + mv local_settings.tmp.$$.py local_settings.py + else + rm local_settings.tmp.$$.py + msg "Failed to configure, exiting" + exit 1 + fi + msg2 "Creating database...." + ./manage.py syncdb + else + msg2 "Current configuration checks out" + fi +} + +migrate() { + msg "Updating database...." + msg2 "Running migrations...." + ./manage.py migrate + msg2 "Loading fixtures...." + ./manage.py loaddata */fixtures/*.json +} + +main() { + if [[ -z "$EDITOR" ]]; then + error 'Please set the $EDITOR variable' + exit 1 + fi + + [[ ! -d "$_install_dir" ]] && mkdir "$_install_dir" + + download + clean + configure + clean + migrate + + msg "Checking media/admin_media symlink...." + if [ ! -e media/admin-media ]; then + rm media/admin_media + ln -s /usr/lib/python2.7/site-packages/django/contrib/admin/media media/admin_media + fi +} + +main "$@" |