summaryrefslogtreecommitdiffstats
path: root/tupkg/client
diff options
context:
space:
mode:
Diffstat (limited to 'tupkg/client')
-rw-r--r--tupkg/client/communitypkg132
-rwxr-xr-xtupkg/client/tupkg216
2 files changed, 0 insertions, 348 deletions
diff --git a/tupkg/client/communitypkg b/tupkg/client/communitypkg
deleted file mode 100644
index 8579273d..00000000
--- a/tupkg/client/communitypkg
+++ /dev/null
@@ -1,132 +0,0 @@
-#!/bin/bash
-
-# Source makepkg.conf; fail if it is not found
-if [ -r "/etc/makepkg.conf" ]; then
- source "/etc/makepkg.conf"
-else
- echo "/etc/makepkg.conf not found!"
- exit 1
-fi
-
-# Source user-specific makepkg.conf overrides
-if [ -r ~/.makepkg.conf ]; then
- source ~/.makepkg.conf
-fi
-
-cmd=`basename $0`
-
-if [ ! -f PKGBUILD ]; then
- echo "No PKGBUILD file"
- exit 1
-fi
-
-# define tags and staging areas based on architecture
-if [ "$CARCH" = "i686" ]; then
- currenttag='CURRENT'
- testingtag='TESTING'
- suffix=''
-elif [ "$CARCH" = "x86_64" ]; then
- currenttag='CURRENT-64'
- testingtag='TESTING-64'
- suffix='64'
-else
- echo "CARCH must be set to a recognized value!"
- exit 1
-fi
-
-source PKGBUILD
-pkgfile=${pkgname}-${pkgver}-${pkgrel}-${CARCH}.pkg.tar.gz
-oldstylepkgfile=${pkgname}-${pkgver}-${pkgrel}.pkg.tar.gz
-
-if [ ! -f $pkgfile ]; then
- if [ -f $PKGDEST/$pkgfile ]; then
- pkgfile=$PKGDEST/$pkgfile
- oldstylepkgfile=$PKGDEST/$oldstylepkgfile
- elif [ -f $oldstylepkgfile ]; then
- pkgfile=$oldstylepkgfile
- elif [ -f $PKGDEST/$oldstylepkgfile ]; then
- pkgfile=$PKGDEST/$oldstylepkgfile
- else
- echo "File $pkgfile doesn't exist"
- exit 1
- fi
-fi
-
-if [ "$cmd" == "extrapkg" ]; then
- repo="extra"
- tag="$currenttag"
-elif [ "$cmd" == "corepkg" ]; then
- repo="core"
- tag="$currenttag"
-elif [ "$cmd" == "testingpkg" ]; then
- repo="testing"
- tag="$testingtag"
-elif [ "$cmd" == "unstablepkg" ]; then
- repo="unstable"
- tag="$currenttag"
-elif [ "$cmd" == "communitypkg" ]; then
- repo="community"
- tag="$currenttag"
-fi
-
-# see if any limit options were passed, we'll send them to SCP
-unset scpopts
-if [ "$1" = "-l" ]; then
- scpopts="$1 $2"
- shift 2
-fi
-
-if [ "$repo" != "community" ]; then
- # combine what we know into a variable (suffix defined based on $CARCH)
- uploadto="staging/${repo}${suffix}/add/$(basename ${pkgfile})"
- scp ${scpopts} "${pkgfile}" "archlinux.org:${uploadto}"
- if [ "$(md5sum "${pkgfile}" | cut -d' ' -f1)" != "$(ssh archlinux.org md5sum "${uploadto}" | cut -d' ' -f1)" ]; then
- echo "File got corrupted during upload, cancelled."
- exit 1
- else
- echo "File integrity okay."
- fi
-else
- if [ ! -f ~/.tupkg ]; then
- echo "Must configure tupkg via ~/.tupkg, cancelled"
- exit 1
- fi
- if [ "$(basename $pkgfile)" != "$(basename $oldstylepkgfile)" ]; then
- echo "Renaming makepkg3 package for compatability"
- mv $pkgfile $oldstylepkgfile
- pkgfile=$oldstylepkgfile
- fi
- tupkg $pkgfile
-fi
-if [ $? -ne 0 ]; then
- echo "Cancelled"
- exit 1
-fi
-echo "===> Uploaded $pkgfile"
-
-if [ "$1" != "" ]; then
- cvs commit -m "upgpkg: $pkgname $pkgver-$pkgrel
- $1" > /dev/null
- if [ $? -ne 0 ]; then
- echo "Cancelled"
- exit 1
- fi
- echo "===> Commited with \"upgpkg: $pkgname $pkgver-$pkgrel
- $1\" message"
-else
- cvs commit -m "upgpkg: $pkgname $pkgver-$pkgrel" > /dev/null
- if [ $? -ne 0 ]; then
- echo "Cancelled"
- exit 1
- fi
- echo "===> Commited with \"upgpkg: $pkgname $pkgver-$pkgrel\" message"
-fi
-
-cvs tag -c -F -R $tag > /dev/null
-if [ $? -ne 0 ]; then
- echo "Cancelled"
- exit 1
-fi
-echo "===> Tagged as $tag"
-
-# vim:ft=sh:ts=4:sw=4:et:
diff --git a/tupkg/client/tupkg b/tupkg/client/tupkg
deleted file mode 100755
index af7d0547..00000000
--- a/tupkg/client/tupkg
+++ /dev/null
@@ -1,216 +0,0 @@
-#!/usr/bin/python -O
-#
-# Description:
-# ------------
-# This is the client-side portion of the Trusted User package
-# manager. The TUs will use this program to upload packages into
-# the AUR. For more information, see the ../README.txt file.
-#
-# Python Indentation:
-# -------------------
-# For a vim: line to be effective, it must be at the end of the
-# file. See the end of the file for more information.
-#
-
-import sys
-import socket
-import os
-import struct
-import os.path
-import cgi
-import urllib
-import getopt
-import ConfigParser
-
-from hashlib import md5
-
-class ClientFile:
- def __init__(self, pathname):
- self.pathname = pathname
- self.filename = os.path.basename(pathname)
- self.fd = open(pathname, "rb")
- self.fd.seek(0, 2)
- self.size = self.fd.tell()
- self.fd.seek(0)
- self.makeMd5()
-
- def makeMd5(self):
- md5sum = md5()
- while self.fd.tell() != self.size:
- md5sum.update(self.fd.read(1024))
- self.md5 = md5sum.hexdigest()
-
-class ClientSocket:
- def __init__(self, files, host, port, username, password):
- self.files = files
- self.host = host
- self.port = port
- self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.username = username
- self.password = password
-
- def connect(self):
- self.socket.connect((self.host, self.port))
-
- def reliableRead(self, size):
- totalread = ""
- while len(totalread) < size:
- read = self.socket.recv(size-len(totalread))
- if read == 0:
- raise RuntimeError, "socket connection broken"
- totalread += read
- return totalread
-
- def sendMsg(self, msg):
- if type(msg) == dict:
- msg = urllib.urlencode(msg,1)
- length = struct.pack("H", socket.htons(len(msg)))
- self.socket.sendall(length)
- self.socket.sendall(msg)
-
- def readMsg(self, format=0):
- initsize = self.reliableRead(2)
- (length,) = struct.unpack("H", initsize)
- length = socket.ntohs(length)
- data = self.reliableRead(length)
- if format == 1:
- qs = cgi.parse_qs(data)
- return qs
- else:
- return data
-
- def close(self):
- self.socket.close()
-
- def auth(self):
- msg = {'username': self.username, 'password': self.password}
- self.sendMsg(msg)
- reply = self.readMsg(1)
- if reply['result'] == ["PASS"]:
- return 1
- elif reply['result'] == ["SQLERR"]:
- print "SQL server-side error"
- return 0
- else:
- return 0
-
- def sendFileMeta(self):
- msg = {'numpkgs': len(self.files)}
- for i, v in enumerate(self.files):
- msg['name'+str(i)] = v.filename
- msg['size'+str(i)] = v.size
- msg['md5sum'+str(i)] = v.md5
- self.sendMsg(msg)
- reply = self.readMsg(1)
- print reply
- for i in reply:
- if i[:4] == 'size':
- self.files[int(i[4:])].cur_done = int(reply[i][0])
-
- def sendFiles(self):
- for i in self.files:
- i.fd.seek(i.cur_done)
- print "Uploading:", i.filename, str(i.size/1024), "kb"
- sdone = 0
- while i.fd.tell() < i.size:
- sdone+=1
- self.socket.sendall(i.fd.read(1024))
- if sdone % 100 == 0:
- print "\r",
- print str(sdone), "of", str(i.size/1024), "kb",
- sys.stdout.flush()
- reply = self.readMsg(1)
- print reply
- self.sendMsg("ack")
-
-def usage():
- print "usage: tupkg [options] <package file>"
- print "options:"
- print " -u, --user Connect with username"
- print " -P, --password Connect with password"
- print " -h, --host Connect to host"
- print " -p, --port Connect to host on port (default 1034)"
- print "May also use conf file: ~/.tupkg"
-
-def main(argv=None):
- if argv is None:
- argv = sys.argv
-
- confdict = {}
- conffile = os.path.join(os.getenv("HOME"),".tupkg") #try the standard location
- #Set variables from file now, may be overridden on command line
- if os.path.isfile(conffile):
- config = ConfigParser.ConfigParser()
- config.read(conffile)
- confdict['user'] = config.get('tupkg','username')
- confdict['password'] = config.get('tupkg','password')
- try:
- confdict['host'] = config.get('tupkg','host')
- except:
- confdict['host'] = 'aur.archlinux.org'
- try:
- confdict['port'] = config.getint('tupkg','port')
- except:
- confdict['port'] = 1034
- else:
- confdict['user'] = ""
- confdict['password'] = ""
- confdict['host'] = 'aur.archlinux.org'
- confdict['port'] = 1034
- if len(argv) == 1: #no config file and no args, bail
- usage()
- return 1
-
- try:
- optlist, args = getopt.getopt(argv[1:], "u:P:h:p:", ["user=", "password=", "host=", "port="])
- except getopt.GetoptError:
- usage()
- return 1
-
- for i, k in optlist:
- if i in ('-u', '--user'):
- confdict['user'] = k
- if i in ('-P', '--password'):
- confdict['password'] = k
- if i in ('-h', '--host'):
- confdict['host'] = k
- if i in ('-p', '--port'):
- confdict['port'] = int(k)
-
- files = []
- for i in args:
- try:
- files.append(ClientFile(i))
- except IOError, err:
- print "Error: " + err.strerror + ": '" + err.filename + "'"
- usage()
- return 1
-
- cs = ClientSocket(files, confdict['host'], confdict['port'], confdict['user'], confdict['password'])
- try:
- cs.connect()
-
- if not cs.auth():
- print "Error authenticating you, you bastard"
- return 1
-
- cs.sendFileMeta()
-
- cs.sendFiles()
-
- cs.close()
- except KeyboardInterrupt:
- print "Cancelling"
- cs.close()
-
- return 0
-
-if __name__ == "__main__":
- sys.exit(main())
-
-# Python Indentation:
-# -------------------
-# Use tabs not spaces. If you use vim, the following comment will
-# configure it to use tabs.
-#
-# vim:noet:ts=2 sw=2 ft=python