Hi, as discussed this morning @ irc I made a script to generate automatically json files with the KDE build depends, so this json files could be used by the "bump- build-dep-versions" script in kubuntu-automation.
I'm attaching:
1. a patch for lib/utils.py
2. a repo-names.json file mapping source package names with repository names
(for those packages with a repository name different than the source package
name)
3. the dev-package-name-list script itself
Example of usage to give you a clue how it works:
Assuming we have in ~/kdeframeworks all the git repositories of frameworks
kubuntu's packaging, we could do this:
user@host:~/kdeframeworks$ dev-package-name-list -d wily -r frameworks -v 5.15
write /usr/local/bin/dev-package-name-lists/frameworks-wily.json
The contents of frameworks-wily.json would look like this:
{
"extra-cmake-modules": "5.15.0~",
"kded5-dev": "5.15.0~",
"kdoctools-dev": "5.15.0~",
[snip]
}
Please review and test if the output files are ok, if you are reasonably happy
with the result the next step would be hacking the "bump-build-dep-versions"
script so it would use the resulting json files.
P.S. The reason to write a json map instead of a plain text file with one
binary package per line is that some packages might have a different version
than the rest of the frameworks/plasma/applications packages. Also some
packages might have an epoch while others might not, so I think the best
approach is finding out the right version on the fly and write it to the file.
=== modified file 'lib/utils.py'
--- lib/utils.py 2015-06-29 14:07:29 +0000
+++ lib/utils.py 2015-10-12 12:24:48 +0000
@@ -1,5 +1,7 @@
import json
import os
+import subprocess
+import re
def readAllFromFile(filename):
f = open(filename, "r")
@@ -25,3 +27,45 @@
return pkgmap[package]
else:
return package
+
+def repoName(package):
+ cwd = os.path.dirname(os.path.realpath(__file__))
+ with open(cwd + "/../repo-names.json") as repofile:
+ pkgmap = json.load(repofile)
+ if package in pkgmap:
+ return pkgmap[package]
+ else:
+ return package
+
+# ReleaseType = [frameworks,plasma,applications]
+def getFtpVersionMap(releaseType,version):
+ #Find out which subdirectories we have to inspeact in the ftp
+ ftp_subdirs = []
+ if releaseType == "frameworks":
+ ftp_subdirs = ["","portingAids"]
+ elif releaseType == "plasma":
+ ftp_subdirs = [""]
+ elif releaseType == "applications":
+ ftp_subdirs = ["src"]
+ #Find out the stability
+ versionParts = version.split(".")
+ lastDigit = int(versionParts[-1])
+ if lastDigit >= 80:
+ stability = "unstable"
+ else:
+ stability = "stable"
+ #Populate and return the map
+ packageVersionMap = {}
+ for subdir in ftp_subdirs:
+ p = subprocess.Popen(["sftp", "-b", "-", "depot.kde.org:%s/%s/%s/%s" % (stability, releaseType, version, subdir)],
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+ output, _ = p.communicate(bytes("ls *xz", 'utf-8'))
+
+ for line in output.splitlines():
+ line = line.decode('utf-8')
+ match = re.search(r'([a-zA-Z0-9\-]+)-' + '([\d.]*)' + r'\.tar\.', line)
+ if match:
+ package = match.group(1)
+ package_version = match.group(2)
+ packageVersionMap[package] = package_version
+ return packageVersionMap
repo-names.json
Description: application/json
#!/usr/bin/python3
# kate: space-indent on; indent-width 4; replace-tabs on; indent-mode python; remove-trailing-space modified;
# a script to make the list of package names which is then used by kubuntu-initial-upload
# Copyright Jonathan Riddell 2015
# Copyright José Manuel Santamaría Lema 2015
# may be copied under the GPL version 2 or later
from lib.utils import *
import argparse
import sys
import os
import json
import re
from debian import deb822
from debian.changelog import Changelog, Version
parser = argparse.ArgumentParser(description="Update -dev package name list used by bump-build-dep-versions")
parser.add_argument("-d", "--dist", help="Distribution name", default="wily")
parser.add_argument("-r", "--releasetype", help="KDE Release Type [frameworks,plasma,applications]", default="frameworks")
parser.add_argument("-v", "--version", help="Version [latest]", required�lse)
args = parser.parse_args()
def quit():
parser.print_help()
sys.exit(1)
if len(sys.argv) < 2:
quit()
try:
dist = args.dist
releaseType = args.releasetype
version = args.version
except IndexError:
quit()
upstream_package_version_map = getFtpVersionMap(releaseType,version)
cwd = os.path.dirname(os.path.realpath(__file__))
dev_package_version_map = {}
dev_package_version_map["_comment"] = "This file was generated automatically by dev-package-name-list."
#Populate the package version map inspecting the control files, changelogs and FTP
src_package_list = readPackages(cwd + "/package-name-lists/" + releaseType + "-" + dist)
for src_package in src_package_list:
#Find out source package version
src_package_version = upstream_package_version_map[upstreamName(src_package)]
#Find out if the package has epoch or not, if so preprend it to the version
changelog = Changelog()
changelog_file_name = repoName(src_package) + '/debian/changelog'
try:
changelog.parse_changelog(open(changelog_file_name, 'r'))
except FileNotFoundError:
print("WARNING: File " + changelog_file_name + " not found!")
continue
epoch = changelog.get_version().epoch
if epoch != None:
src_package_version = epoch + ":" + src_package_version
src_package_version += "~"
#Find out -dev package names
control_file_name = repoName(src_package) + '/debian/control'
try:
control_file = deb822.Packages.iter_paragraphs(open(control_file_name, 'r'));
except FileNotFoundError:
print("WARNING: File " + control_file_name + " not found!")
continue
for pkg in control_file:
if 'Package' in pkg:
bin_package_name = pkg['Package']
if re.match('.*-dev$', bin_package_name) != None:
dev_package_version_map[bin_package_name] = src_package_version
control_file.close()
#Packages contaning dev binary packages not ending in -dev
if src_package == "extra-cmake-modules":
dev_package_version_map["extra-cmake-modules"] = src_package_version
elif src_package == "kdesignerplugin":
dev_package_version_map["kgendesignerplugin"] = src_package_version
json_str = json.dumps(dev_package_version_map, indent=4, sort_keys=True)
outFile = cwd + "/dev-package-name-lists/" + releaseType + "-" + dist + ".json"
f = open(outFile, 'w')
f.write(json_str)
print("write " + outFile)
signature.asc
Description: This is a digitally signed message part.
-- kubuntu-devel mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/kubuntu-devel
