more work done on the python fork
This commit is contained in:
@@ -4,14 +4,17 @@ import re
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import git # python-gitpython in AUR
|
||||
import menu3 # python-menu3 in AUR
|
||||
import hashlib
|
||||
import urllib2
|
||||
import git # python-gitpython in AUR
|
||||
import menu3 # python-menu3 in AUR
|
||||
import jinja2 # python-jinja in community
|
||||
from tempfile import gettempdir
|
||||
|
||||
import pprint
|
||||
|
||||
## SETTINGS ##
|
||||
gpgkey = '748231EBCBD808A14F5E85D28C004C2F93481F6B' # https://wiki.archlinux.org/index.php/PKGBUILD#validpgpkeys
|
||||
gpgkey = ['748231EBCBD808A14F5E85D28C004C2F93481F6B'] # https://wiki.archlinux.org/index.php/PKGBUILD#validpgpkeys
|
||||
maintname = 'brent s. <bts[at]square-r00t[dot]net>' # your name and email address, feel free to obfuscate though
|
||||
pkgbuild_dir = '/opt/dev/arch' # what dir do the pkgbuilds/AUR checkouts live?
|
||||
aur_pkgs_dir = pkgbuild_dir # should be the dir where the aur_pkgs repo checkout lives. it's recommended you keep this the same as pkgbuild_dir
|
||||
@@ -42,15 +45,19 @@ def gui_init():
|
||||
"Mercurial (hg)",
|
||||
"Bazaar (bzr)"]
|
||||
vcs_menu = m.menu("What type of VCS system?", vcs_options, "VCS type ('q' to quit):")
|
||||
pkg['name'] = input("\nWhat is the name of your package? (Exclude the '-git' etc. suffix)\n").lower()
|
||||
pkg['name'] = input("\nWhat is the name of your package? (Exclude the '-git' etc. suffix, that will be added automatically later on)\n").lower()
|
||||
srcurl = input("\nWhat is the checkout URL for {0}?\n(Do not include the directory or VCS type prefix as per\nhttps://wiki.archlinux.org/index.php/VCS_package_guidelines#VCS_sources ...\nit will be added automatically)\n".format(pkg['name']))
|
||||
pkg['vcstype'] = ["git",
|
||||
"svn",
|
||||
"hg",
|
||||
"bzr"]
|
||||
pkg['srcurl'] = pkg['name'] + "::" + pkg['vcstype'][vcs_menu-1] + srcurl
|
||||
pkg['name'] = pkg['name'] + "-" + pkg['vcstype']
|
||||
pkg['type'] = 'vcs'
|
||||
pkg['srcfile'] = False
|
||||
pkg['ver'] = False
|
||||
pkg['srchash'] = 'SKIP'
|
||||
pkg['src_dl'] = False
|
||||
|
||||
# If they're adding a release package...
|
||||
elif add_menu == 1:
|
||||
@@ -59,6 +66,15 @@ def gui_init():
|
||||
pkg['ver'] = input("\nWhat is the version of the release you are packaging for {0}?\n".format(pkg['name']))
|
||||
pkg['srcurl'] = input("\nWhat is the full URL for the tarball/zip file/etc. for {0} (version {1})?\n".format(pkg['name'], pkg['ver']))
|
||||
pkg['srcfile'] = re.sub('^\s*(https?|ftp).*/(.*)\s*$', '\\2', pkg['srcurl'], re.IGNORECASE)
|
||||
pkg['type'] = 'release'
|
||||
# And here's where we download the source file for hashing
|
||||
pkg['src_dl'] = gettempdir() + "/" + pkg['srcfile']
|
||||
print("Please wait while we download {0} to {1}...\n".format(pkg['srcfile'], pkg['src_dl']))
|
||||
datastream = urllib2.urlopen(pkg['srcurl'])
|
||||
data_in = datastream.read()
|
||||
with open(pkg['src_dl'], "wb") as data_dl:
|
||||
data_dl.write(data_in)
|
||||
pkg['srchash'] = hashlib.sha512(open(pkg['src_dl'],'rb').read()).hexdigest()
|
||||
|
||||
# And this is stuff shared by both types.
|
||||
pkg['desc'] = input("\nWhat is a short description of {0}?\n".format(pkg['name']))
|
||||
@@ -91,12 +107,40 @@ def sanity_checks(pkg):
|
||||
if exception.errno != errno.EEXIST:
|
||||
raise
|
||||
|
||||
## REGISTER IN THE AUR AND MAKE FIRST COMMIT ##
|
||||
def aur_create(pkg):
|
||||
tmpcheckout = os.path.join(gettempdir(), '.aur_pkgs.{}'.format(pkg['name']))
|
||||
pygit2.clone_repository('aur@aur.archlinux.org:' + pkg['name'], tmpcheckout, bare=False, repository=None, remote=None, checkout_branch=None, callbacks=None)
|
||||
# git clone from AUR to create repository, add .gitignore
|
||||
tmpcheckout = os.path.join(gettempdir(), '.aur_pkgs')
|
||||
repo_dir = tmpcheckout + '/' + pkg['name']
|
||||
aur_repo = git.Repo.clone_from('aur@aur.archlinux.org:' + pkg['name'], git.osp.join(tmpcheckout, pkg['name']), branch='master')
|
||||
shutil.copy2(aur_pkgs_dir + "/_docs/PKGBUILD.templates.d/gitignore", tmpcheckout + "/.gitignore")
|
||||
aur_repo.index.add('.gitignore')
|
||||
# Create the initial PKGBUILD
|
||||
tpl_dir = aur_pkgs_dir + '/_docs/PKGBUILD.templates.d.python'
|
||||
tpl_meta = aur_pkgs_dir + '/_docs/PKGBUILD.templates.d.python' + '/' + pkg['type'] + '.all'
|
||||
tpl_fsloader = jinja2.FileSystemLoader(searchpath = tpl_dir, followlinks = True)
|
||||
tpl_fsloader2 = jinja2.FileSystemLoader(searchpath = tpl_dir + '/' + pkg['type'], followlinks = True)
|
||||
pkgbuild_list = tpl_fsloader2.list_templates()
|
||||
pkgbuild_list[:] = [pkg['type'] + '/' + s for s in pkgbuild_list]
|
||||
tpl_env = jinja2.Environment(loader = tpl_fsloader)
|
||||
pkgbuild_out = tpl_env.get_template(pkg['type'] + '.all.j2').render(pkg = pkg, maintname = maintname, gpgkey = gpgkey, pkgbuild_list = pkgbuild_list)
|
||||
with open(repo_dir + "/PKGBUILD", "wb") as pkgbuild_file:
|
||||
pkgbuild_file.write(pkgbuild_out)
|
||||
# Move the source file
|
||||
if pkg['srcfile']:
|
||||
os.rename(pkg['src_dl'], repodir + '/' + pkg['srcfile'])
|
||||
gpg = gnupg.GPG()
|
||||
datastream = open(pkg['dl_src'], 'rb')
|
||||
gpg.sign_file(datastream, keyid = gpgkey[0], detach = True, clearsign = False, output = repodir + '/' + pkg['srcfile'] + '.sig')
|
||||
datastream.close()
|
||||
aur.repo.indes.add(pkg['srcfile'] + '.sig')
|
||||
aur.repo.index.add('PKGBUILD')
|
||||
# commit to git
|
||||
aur_repo.index.commit("initial commit; setting up .gitignores and skeleton PKGBUILD")
|
||||
# and push...
|
||||
aur_repo.push()
|
||||
|
||||
|
||||
pprint.pprint(gui_init())
|
||||
|
||||
|
||||
#aur_create(gui_init())
|
||||
|
||||
Reference in New Issue
Block a user