Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
melver committed Jan 31, 2014
0 parents commit 345f637
Show file tree
Hide file tree
Showing 7 changed files with 763 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.pyc
*.swp
__pycache__
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "deps/bottle"]
path = deps/bottle
url = https://github.com/defnull/bottle.git
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions bin/abs2pkgix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

ABS2PKGIX_ROOT="$(cd "${0%/*}/.." && pwd)"
PYTHONPATH="${PYTHONPATH}:${ABS2PKGIX_ROOT}/lib/python:${ABS2PKGIX_ROOT}/deps/bottle"

export ABS2PKGIX_ROOT
export PYTHONPATH
exec "${ABS2PKGIX_ROOT}/lib/python/abs2pkgix/main.py" "$@"
1 change: 1 addition & 0 deletions deps/bottle
Submodule bottle added at a7db72
Empty file added lib/abs2pkgix/wrap.sh
Empty file.
74 changes: 74 additions & 0 deletions lib/python/abs2pkgix/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env python

#
# Copyright (C) 2014, Marco Elver <me AT marcoelver.com>
#
# This file is part of abs2pkgix.
#
# abs2pkgix is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# abs2pkgix is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with abs2pkgix. If not, see <http://www.gnu.org/licenses/>.
#

import os
import time
import bottle

ABS_PATH = "/var/abs"
REPOS = ["core", "extra", "community"]

WRAP_SCRIPT = os.path.join(os.environ["ABS2PKGIX_ROOT"], "lib", "abs2pkgix", "wrap.sh")
with open(WRAP_SCRIPT, "r") as wrap_script:
WRAP_SCRIPT_CONTENT = wrap_script.read()

def get_pkgpath(name):
for repo in REPOS:
pkgpath = os.path.join(ABS_PATH, repo, name)
if os.path.exists(pkgpath): break

if not os.path.exists(pkgpath):
raise Exception("Package does not exist!")

return pkgpath

@bottle.route('/pkgs/<name>')
def index(name):
try:
pkgpath = get_pkgpath(name)
except Exception as e:
bottle.abort(404, e)

with open(os.path.join(pkgpath, "PKGBUILD"), "r") as pkgbuild:
pkgbuild_content = pkgbuild.read()

return "\n".join([
"# abs2pkgix generated ({})".format(time.strftime("%a %b %d %H:%M:%S %Z %Y")),
"",
"#====================[ PKGBUILD ]====================#",
"",
pkgbuild_content,
"",
"#====================[ wrap.sh ]====================#",
"",
WRAP_SCRIPT_CONTENT
])

@bottle.route('/support/<name>/<filename>')
def index(name, filename):
try:
pkgpath = get_pkgpath(name)
except Exception as e:
bottle.abort(404, e)

return bottle.static_file(filename, root=pkgpath)

bottle.run(host='localhost', port=8080)

0 comments on commit 345f637

Please sign in to comment.