diff options
author | Eric Anderson | 2017-12-28 14:24:10 -0600 |
---|---|---|
committer | Eric Anderson | 2017-12-28 14:24:10 -0600 |
commit | 9e79f3864bb93cf494da1e00d572be8eefe30a36 (patch) | |
tree | 8f0790d1831685dff77cbc2231328c98a9c915a6 | |
parent | f784a3a45dc26f443074e188208288e77cddfa78 (diff) | |
download | aur-9e79f3864bb93cf494da1e00d572be8eefe30a36.tar.gz |
Remove unnecessary server code
-rw-r--r-- | .SRCINFO | 8 | ||||
-rw-r--r-- | PKGBUILD | 9 | ||||
-rwxr-xr-x | pkgdistcache-daemon | 69 | ||||
-rw-r--r-- | pkgdistcached.service | 2 |
4 files changed, 11 insertions, 77 deletions
@@ -1,9 +1,9 @@ # Generated by mksrcinfo v8 -# Thu Dec 28 19:44:58 UTC 2017 +# Thu Dec 28 20:23:42 UTC 2017 pkgbase = pkgdistcache pkgdesc = A distributed local-network cache for pacman packages pkgver = 0.4.6 - pkgrel = 2 + pkgrel = 3 url = http://venator.ath.cx/dw/doku.php?id=linux:pkgdistcache install = pkgdistcache.install arch = any @@ -20,9 +20,9 @@ pkgbase = pkgdistcache source = pkgdistcache.conf source = pkgdistcached.service sha256sums = 4141d8d07a7c67ebd0dba24ca8aa2a97bcf93a2915b7afbebbd85728bbbc356c - sha256sums = c03074bdcc7456ae1dbe4cf32a6fb8854a5fbb6445bfd16208e3fb85c9b91d5e + sha256sums = 10379b95265e7aa3c6334197ef255327281e35b958c3c062ae893dd3a646a66e sha256sums = d77ac418aa651bc622cd91204d6907554c6cdb4bb989e484cc54da32342faa51 - sha256sums = 756c0bd1139e296da88937a89ab19e0b5d6c0d5d0f719034d4029b1fe1ea09e9 + sha256sums = b5fb3b3d40b31af92a1676364dfc42a35f564067988697ea4d56fd71b4b414e3 pkgname = pkgdistcache @@ -3,7 +3,7 @@ pkgname=pkgdistcache pkgver=0.4.6 -pkgrel=2 +pkgrel=3 pkgdesc='A distributed local-network cache for pacman packages' arch=('any') url='http://venator.ath.cx/dw/doku.php?id=linux:pkgdistcache' @@ -15,14 +15,15 @@ source=('pkgdistcache-client' 'pkgdistcache.conf' 'pkgdistcached.service') sha256sums=('4141d8d07a7c67ebd0dba24ca8aa2a97bcf93a2915b7afbebbd85728bbbc356c' - 'c03074bdcc7456ae1dbe4cf32a6fb8854a5fbb6445bfd16208e3fb85c9b91d5e' + '10379b95265e7aa3c6334197ef255327281e35b958c3c062ae893dd3a646a66e' 'd77ac418aa651bc622cd91204d6907554c6cdb4bb989e484cc54da32342faa51' - '756c0bd1139e296da88937a89ab19e0b5d6c0d5d0f719034d4029b1fe1ea09e9') + 'b5fb3b3d40b31af92a1676364dfc42a35f564067988697ea4d56fd71b4b414e3') package() { install -d "${pkgdir}/usr/bin/" install -m755 "${srcdir}/pkgdistcache-client" "${pkgdir}/usr/bin/" - install -m755 "${srcdir}/pkgdistcache-daemon" "${pkgdir}/usr/bin/" + install -d "${pkgdir}/usr/lib/$pkgname/" + install -m755 "${srcdir}/pkgdistcache-daemon" "${pkgdir}/usr/lib/$pkgname/" install -d "${pkgdir}/etc/" install -m644 "${srcdir}/pkgdistcache.conf" "${pkgdir}/etc/" install -d "${pkgdir}/usr/lib/systemd/system/" diff --git a/pkgdistcache-daemon b/pkgdistcache-daemon index c1cccd5394e6..5d5b7899d8e8 100755 --- a/pkgdistcache-daemon +++ b/pkgdistcache-daemon @@ -4,23 +4,17 @@ # pkgdistcache daemon v0.3.1 # by Alessio Bianchi <venator85@gmail.com> # -# Daemon code by Chad J. Schroeder -# http://code.activestate.com/recipes/278731/ -# import http.server import os import os.path import signal import socket -import string -import subprocess import sys import avahi import dbus import dbus.glib -from gi.repository import GObject as gobject avahi_service = None @@ -30,57 +24,6 @@ def terminate(signum, frame): sys.exit(0) -# Run a command synchronously, redirecting stdout and stderr to strings -def runcmd(cmd, cwd=None): - pipe = subprocess.Popen(cmd, shell=True, cwd=cwd, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - # wait for process to terminate and return stdout and stderr - (stdout, stderr) = pipe.communicate() - return { - 'stdout': stdout.strip(), - 'stderr': stderr.strip(), - 'retcode': pipe.returncode} - - -# Detach a process from the controlling terminal and run it in the background -# as a daemon -def daemonize(): - try: - pid = os.fork() - except OSError as e: - raise Exception("%s [%d]" % (e.strerror, e.errno)) - - if (pid == 0): # The first child. - os.setsid() - try: - pid = os.fork() # Fork a second child. - except OSError as e: - raise Exception("%s [%d]" % (e.strerror, e.errno)) - - if (pid != 0): # The second child. - os._exit(0) # Exit parent (the first child) of the second child. - else: - os._exit(0) # Exit parent of the first child. - - import resource # Resource usage information. - maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1] - if (maxfd == resource.RLIM_INFINITY): - maxfd = 1024 - - # Iterate through and close all file descriptors. - for fd in range(0, maxfd): - try: - os.close(fd) - except OSError: # ERROR, fd wasn't open to begin with (ignored) - pass - - # The standard I/O file descriptors are redirected to /dev/null by default. - os.open("/dev/null", os.O_RDWR) # standard input (0) - os.dup2(0, 1) # standard output (1) - os.dup2(0, 2) # standard error (2) - return(0) - - class AvahiPublisher: # Based on http://avahi.org/wiki/PythonPublishExample def __init__(self, name, stype, host, port): @@ -120,16 +63,6 @@ class HTTPServerV6(http.server.HTTPServer): def main(args): - import optparse - parser = optparse.OptionParser() - parser.add_option("-F", "--foreground", action="store_true", - dest="no_daemon", default=False, - help="run pkgdistcache-daemon in foreground") - (options, args) = parser.parse_args() - if not options.no_daemon: - # fork daemon in background - daemonize() - # load configuration file conf_file = '/etc/pkgdistcache.conf' if os.path.isfile(conf_file): @@ -139,7 +72,7 @@ def main(args): return 2 port = config['port'] - hostname = runcmd('hostname')['stdout'] + hostname = socket.gethostname() global avahi_service avahi_service = AvahiPublisher(hostname, '_pkgdistcache._tcp', '', port) avahi_service.publish() diff --git a/pkgdistcached.service b/pkgdistcached.service index 2c1140f21f0a..09f9ce3bdc00 100644 --- a/pkgdistcached.service +++ b/pkgdistcached.service @@ -2,7 +2,7 @@ Description=Distributed pacman package cache [Service] -ExecStart=/usr/bin/pkgdistcache-daemon -F +ExecStart=/usr/lib/pkgdistcache/pkgdistcache-daemon DynamicUser=yes NoNewPrivileges=yes PrivateTmp=yes |