Permalink
Browse files

fix python and rpm packaging

  • Loading branch information...
1 parent 042fc2a commit e76eaf8ba1a9674a46301b319042bae71ba2133b @mapleoin committed Oct 8, 2011
View
@@ -0,0 +1,2 @@
+recursive-include popcorn/templates *
+recursive-include popcorn/static *
View
@@ -1,9 +1,13 @@
-FILES=README popcorn-client popcorn.conf popcorn.cron server/index.html server/popcorn-server server/popcorn-server.init server/server.conf
+FILES=README popcorn-client popcorn.conf popcorn.cron setup.py MANIFEST.in
+DIRS=popcorn server
all: release
release: popcorn.tar.bz2
-popcorn.tar.bz2: $(FILES)
- tar cf popcorn.tar $(FILES)
+popcorn.tar.bz2: $(FILES) $(DIRS)
+ tar cf popcorn.tar $(FILES) $(DIRS)
bzip2 --best popcorn.tar
+
+clean:
+ rm -rf popcorn.tar.bz2
View
@@ -1,6 +1,4 @@
-#
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
-#
+%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
Name: popcorn
Version: 0.1
@@ -12,6 +10,7 @@ Group: System/Packages
Source: %{name}.tar.bz2
Requires: cron
Requires: rpm-python
+BuildRequires: python-devel
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
@@ -20,8 +19,11 @@ Popularity Contest (for RPM).
%package server
Summary: Server for Popularity Contest (for RPM)
+Requires: redis
Requires: python-redis
-Requires: python-tornado
+Requires: python-Flask
+Requires: python-jinja2
+BuildRequires: python-devel
%description server
Server for Popularity Contest (for RPM).
@@ -30,22 +32,20 @@ Server for Popularity Contest (for RPM).
%setup -q -c -n %{name}
%build
-# not needed
+python setup.py build
%install
# client files
install -D -m 0755 popcorn-client %{buildroot}%{_bindir}/popcorn
install -D -m 0644 popcorn.conf %{buildroot}%{_sysconfdir}/popcorn.conf
install -D -m 0755 popcorn.cron %{buildroot}%{_sysconfdir}/cron.weekly/popcorn
+
# server files
+python setup.py install --skip-build --root %{buildroot} --prefix=%{_prefix}
install -D -m 0755 server/popcorn-server %{buildroot}%{_sbindir}/popcorn-server
-install -D -m 0644 server/index.html %{buildroot}%{_datadir}/popcorn/index.html
install -D -m 0644 server/server.conf %{buildroot}%{_sysconfdir}/popcorn-server.conf
install -D -m 0755 server/popcorn-server.init %{buildroot}%{_initddir}/popcorn-server
ln -s %{_initddir}/popcorn-server %{buildroot}%{_sbindir}/rcpopcorn-server
-# use absolute paths
-sed -i "s:^CONFIG_FILE = .*$:CONFIG_FILE = '%{_sysconfdir}/popcorn-server.conf':" %{buildroot}%{_sbindir}/popcorn-server
-sed -i "s:^INDEX_FILE = .*$:INDEX_FILE = '%{_datadir}/popcorn/index.html':" %{buildroot}%{_sbindir}/popcorn-server
%clean
rm -rf %{buildroot}
@@ -75,8 +75,8 @@ rm -rf %{buildroot}
%defattr(-,root,root)
%doc README
%config(noreplace) %{_sysconfdir}/popcorn-server.conf
-%dir %{_datadir}/popcorn
-%{_datadir}/popcorn/index.html
+%{python_sitelib}/popcorn
+%{python_sitelib}/%{name}-*.egg-info
%{_sbindir}/popcorn-server
%{_sbindir}/rcpopcorn-server
%{_initddir}/popcorn-server
View
@@ -1,2 +1,28 @@
-import sys
-sys.path.append("/location-of-popcorn")
+# -*- coding: utf-8 -*-
+# Copyright (c) 2011 Ionuț Arțăriși <iartarisi@suse.cz>
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation
+# files (the "Software"), to deal in the Software without
+# restriction, including without limitation the rights to use,
+# copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following
+# conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+from flask import Flask
+app = Flask(__name__)
+
+# Flask docs say we need this in order to use decorators
+import popcorn.views
View
@@ -26,7 +26,7 @@
from ConfigParser import RawConfigParser
-CONFIG_FILE = '/etc/popcorn.conf'
+CONFIG_FILE = '/etc/popcorn-server.conf'
config = RawConfigParser()
config.read(CONFIG_FILE)
View
@@ -0,0 +1,10 @@
+from setuptools import setup
+
+setup(
+ name="Popcorn",
+ version="0.1",
+ long_description=__doc__,
+ packages=["popcorn"],
+ include_package_data=True,
+ zip_safe=False,
+ install_requires=["Flask", "jinja2", "redis"]
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2011 Ionuț Arțăriși <iartarisi@suse.cz>
#
@@ -23,18 +22,13 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
-import sys
-
-from flask import Flask, abort, render_template, request
-app = Flask("popcorn")
+from flask import abort, render_template, request
+from popcorn import app
from popcorn.model import Distro, Package, System, Vendor, Submission
from popcorn.model.error import DoesNotExist
-
from popcorn.parse import parse_text
-sys.path.append("/home/mapleoin/popcorn/")
-
@app.route('/', methods=['GET'])
def index():
distros = Distro.get_all_ids()
@@ -96,7 +90,3 @@ def distro(distro_id):
except DoesNotExist:
abort(404)
return render_template('distro.html', distro=dist)
-
-if __name__ == "__main__":
- app.debug = True
- app.run()
View
@@ -0,0 +1,4 @@
+#!/usr/bin/env python
+
+from popcorn import app
+app.run(debug=False)
View
@@ -0,0 +1,60 @@
+#!/bin/sh
+#
+# /etc/init.d/popcorn-server
+#
+### BEGIN INIT INFO
+# Provides: popcorn-server
+# Required-Start: $syslog $remote_fs
+# Should-Start:
+# Required-Stop: $syslog $remote_fs
+# Should-Stop:
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 2 6
+# Short-Description: Popcorn server
+# Description: Starts and stops the Popcorn service
+### END INIT INFO
+
+. /etc/rc.status
+
+EXEC=/usr/sbin/popcorn-server
+
+PIDFILE=/var/run/popcorn-server.pid
+
+case "$1" in
+ start)
+ if [ ! -r $PIDFILE ]; then
+ touch $PIDFILE
+ chown popcorn:popcorn $PIDFILE
+ fi
+ echo -n "Starting service Popcorn server "
+ /sbin/startproc -u popcorn -g popcorn -p $PIDFILE -s -e $EXEC >/dev/null 2>&1
+ rc_status -v
+ ;;
+ stop)
+ if [ ! -f $PIDFILE ]
+ then
+ echo -n "$PIDFILE does not exist, process is not running"
+ rc_failed
+ else
+ echo -n "Stopping service Popcorn server "
+ /sbin/killproc -p $PIDFILE $EXEC >/dev/null 2>&1
+ fi
+ rc_status -v
+ ;;
+ restart)
+ $0 stop
+ $0 start
+ ;;
+ reload)
+ $0 restart
+ ;;
+ status)
+ echo -n "Checking for service Popcorn server "
+ /sbin/checkproc -p $PIDFILE $EXEC
+ rc_status -v
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|reload}"
+ exit 1
+esac
+rc_exit
File renamed without changes.
View
@@ -0,0 +1,12 @@
+from setuptools import setup, find_packages
+
+setup(
+ name="popcorn",
+ version="0.1",
+ long_description=__doc__,
+ packages=find_packages(exclude=["*.test", "test", "*.test.*"]),
+ include_package_data=True,
+ zip_safe=False,
+ install_requires=['Flask', 'jinja2', 'redis'],
+ test_suite="popcorn.test"
+ )

0 comments on commit e76eaf8

Please sign in to comment.