From df1af774dc8dc6b26467efb84b04295d2726b8bb Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 27 Oct 2012 11:34:56 -0400 Subject: improve libre/parabolaweb-utils filesystem: * pull parabolaweb-download out of parabolaweb-update * parabolaweb-update: teach about Makefiles * parabolaweb-update: use collectstatic --- libre/parabolaweb-utils/PKGBUILD | 25 ++++++----- libre/parabolaweb-utils/parabolaweb-download | 47 +++++++++++++++++++++ libre/parabolaweb-utils/parabolaweb-update | 62 +++++++++++++--------------- 3 files changed, 90 insertions(+), 44 deletions(-) create mode 100644 libre/parabolaweb-utils/parabolaweb-download (limited to 'libre') diff --git a/libre/parabolaweb-utils/PKGBUILD b/libre/parabolaweb-utils/PKGBUILD index 9c6da333a..c1beccdf9 100644 --- a/libre/parabolaweb-utils/PKGBUILD +++ b/libre/parabolaweb-utils/PKGBUILD @@ -8,7 +8,7 @@ pkgname=parabolaweb-utils pkgver=`_get_pkgver` -pkgrel=3 +pkgrel=4 pkgdesc="Utils for the Parabola website" arch=('any') url="https://projects.parabolagnulinux.org/parabolaweb.git/" @@ -25,6 +25,7 @@ backup=('etc/conf.d/parabolaweb') export pkgver source=(git://parabolagnulinux.org/parabolaweb.git + parabolaweb-download parabolaweb-update parabolaweb-fcgi parabolaweb.rc @@ -37,16 +38,18 @@ build() { package() { cd "${srcdir}" - install -Dm755 parabolaweb-update "${pkgdir}/usr/sbin/parabolaweb-update" - install -Dm755 parabolaweb-fcgi "${pkgdir}/usr/sbin/parabolaweb-fcgi" - install -Dm755 parabolaweb.rc "${pkgdir}/etc/rc.d/parabolaweb" - install -Dm644 parabolaweb.service "${pkgdir}/usr/lib/systemd/system/parabolaweb.service" - install -Dm644 parabolaweb.conf "${pkgdir}/etc/conf.d/parabolaweb" + install -Dm755 parabolaweb-download "${pkgdir}/usr/sbin/parabolaweb-download" + install -Dm755 parabolaweb-update "${pkgdir}/usr/sbin/parabolaweb-update" + install -Dm755 parabolaweb-fcgi "${pkgdir}/usr/sbin/parabolaweb-fcgi" + install -Dm755 parabolaweb.rc "${pkgdir}/etc/rc.d/parabolaweb" + install -Dm644 parabolaweb.service "${pkgdir}/usr/lib/systemd/system/parabolaweb.service" + install -Dm644 parabolaweb.conf "${pkgdir}/etc/conf.d/parabolaweb" } md5sums=('SKIP' - 'dd05d6a4ea7cff7fdd789f59aeb9059a' - '520e20b8bbca64042b3afa76b0bec55f' - '1bce8fb832ad9e61cf8b96426ce843b5' - '80ee438224b4d67677d0980d5bc57005' - 'fb291168d3f57a85f82216c4e74c9ccf') + '01bed679a4fd768e720bfd0f3c7d6694' + 'a73063b14746720b77fdbab851f5c161' + 'd5294495f42df29d29519ebd0a8f6093' + 'cc15e153f99fba82e7bb032896f655c2' + 'a468016a7155b5da46521dcfc6428384' + '9b565ef07e44d395bf7a0e484e3d19d1') diff --git a/libre/parabolaweb-utils/parabolaweb-download b/libre/parabolaweb-utils/parabolaweb-download new file mode 100644 index 000000000..823a18811 --- /dev/null +++ b/libre/parabolaweb-utils/parabolaweb-download @@ -0,0 +1,47 @@ +#!/bin/bash + +. /etc/conf.d/parabolaweb +. /usr/bin/libremessages + +dir=$WEBDIR +repo=git://parabolagnulinux.org/parabolaweb.git +ref=master + +cd_safe() { + if ! cd "$1"; then + error "$(gettext "Failed to change to directory %s")" "$1" + plain "$(gettext "Aborting...")" + exit 1 + fi +} + +download_git() { + if [[ ! -d "$dir/.git" ]] ; then + msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git" + if ! git clone "$repo" "$dir"; then + error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "git" + plain "$(gettext "Aborting...")" + exit 1 + fi + else + cd_safe "$dir" + # Make sure we are fetching the right repo + # if [[ "$repo" != "$(git config --get remote.origin.url)" ]] ; then + # error "$(gettext "%s is not a clone of %s")" "$dir" "$repo" + # plain "$(gettext "Aborting...")" + # exit 1 + # fi + msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "git" + if ! git pull origin "$ref"; then + # only warn on failure to allow offline builds + warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git" + fi + fi +} + +main() { + [[ -d "${dir%/*}" ]] || mkdir -p "${dir%/*}" + download_git +} + +main "$@" diff --git a/libre/parabolaweb-utils/parabolaweb-update b/libre/parabolaweb-utils/parabolaweb-update index b8ac5bf5e..45e17c4f2 100644 --- a/libre/parabolaweb-utils/parabolaweb-update +++ b/libre/parabolaweb-utils/parabolaweb-update @@ -2,39 +2,30 @@ set -e . /etc/conf.d/parabolaweb - - -_install_dir=${WEBDIR%/*} -_gitname=${WEBDIR##*/} -_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" +find_makefiles() { + pushd "$WEBDIR" > /dev/null + echo ./sitestatic + find . -name static -type d | while read dir; do + if [[ -e "$WEBDIR/$dir/Makefile" ]]; then + printf '%s\n' "$dir" + fi + done } clean() { msg "Purging old .pyc files...." - cd "$_install_dir/$_gitname" + cd "$WEBDIR" find . -name '*.pyc' -delete + for dir in `find_makefiles`; do + make -C "$WEBDIR/$dir" clean + done } configure() { msg "Checking configuration...." - cd "$_install_dir/$_gitname" + cd "$WEBDIR" if [[ ! -f local_settings.py ]]; then msg2 "Configuration file missing, opening editor..." cp local_settings.py.example local_settings.tmp.$$.py @@ -52,33 +43,38 @@ configure() { fi } -migrate() { +update-database() { msg "Updating database...." + cd "$WEBDIR" msg2 "Running migrations...." ./manage.py migrate msg2 "Loading fixtures...." ./manage.py loaddata */fixtures/*.json } +update-filesystem() { + msg "Updating filesystem..." + for dir in `find_makefiles`; do + msg2 "Updating $dir with GNU Make..." + make -C "$WEBDIR/$dir" + done + cd "$WEBDIR" + msg2 "Collecting static files..." + echo yes | ./manage.py collectstatic -l +} + main() { if [[ -z "$EDITOR" ]]; then error 'Please set the $EDITOR variable' exit 1 fi - [[ ! -d "$_install_dir" ]] && mkdir "$_install_dir" - - download + parabolaweb-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 + update-database + update-filesystem } main "$@" -- cgit v1.2.3