diff --git a/trunk/PKGBUILD b/trunk/PKGBUILD index 827069f..1247c3f 100644 --- a/trunk/PKGBUILD +++ b/trunk/PKGBUILD @@ -1,52 +1,46 @@ # Maintainer: Sergej Pupykin pkgname=freedesktop-docs -pkgver=20181113 +pkgver=20210508.9a32db0 pkgrel=1 pkgdesc="Specifications from freedesktop.org" arch=('any') url="https://standards.freedesktop.org" license=('GPL') options=('docs') -source=(https://specifications.freedesktop.org/autostart-spec/autostart-spec-latest.html - https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html - https://specifications.freedesktop.org/clipboard-extensions-spec/clipboard-extensions-latest.txt - https://specifications.freedesktop.org/clipboards-spec/clipboards-latest.txt - https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html - https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html - https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html - https://specifications.freedesktop.org/menu-spec/menu-spec-latest.html - https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-latest.html - https://specifications.freedesktop.org/recent-file-spec/recent-file-spec-latest.xml - https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html - https://specifications.freedesktop.org/startup-notification-spec/startup-notification-latest.txt - https://specifications.freedesktop.org/systemtray-spec/systemtray-spec-latest.html - https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html - https://specifications.freedesktop.org/trash-spec/trashspec-latest.html - https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html - https://specifications.freedesktop.org/xembed-spec/xembed-spec-latest.xml - https://specifications.freedesktop.org/xsettings-spec/xsettings-latest.html) -sha256sums=('6fc3e06d434708c03d16f18bde84676e3529b2e93ca1b6003e659b3f5ed1e2e0' - '342289ad33b48b8f643278f74cafa182f4471d490b82dc5e442e2e720fa4080f' - 'add8dc513aef482eb6d7103f9485924f47846b844244962dd36e343959ccbd3a' - 'dea39499dfa4b9500c1a81e6f634e7afbdbeff6dd950afa3c89f66c32d9a8d21' - '88372a2316373ae680149021637240e77e41dec0fe644d529eda4d2b270c7758' - 'ae5d1d9d03f157e420c5eed6e8b6b1b6f391e469ee3b6ee3db0e820bce2d484a' - 'dba6629adc93d4bbf6f7bcf4a5ffe120836a8a540c07776bbf0784f39b354a71' - 'd6de6f97da17bd648d4be84b621f246c5963a3b388f4d0d57528c23beb294ba2' - '761ac154da4db51f6917a54e5e8be0efb996a7abbd265cf8d0877a1ecd5995c6' - '7ffa245dcf80eceb06b3a26f39bf2c90e2c10c4611c1672942a9f9d999dc429c' - '2f29e9c916bc7233c4148d43f2ba8e96807236a59673a027232fcd367af61ad4' - 'e9dc125ba422998ce786cfc8336f93df6ef34d1a2672febd8c56f65985b404ef' - '2ca2e2de7c34645d5e800e697e2ea9de40acfe89c5d5331dc70a9ac464e7a2f7' - '40beab99053509f8695bc8b1d7055f67f0e757e300f783b57835f3fb5c53f045' - 'c5a753daec25c74712a6ad1884c1eb36308c4d8cb74831277610a9d11274394d' - '839b308e3901d598581b4a4b2804a2d5ca222b0d290d8668ab4f8a08794fe2f3' - '0fc7bfd96b3f1a79b965047d8de3404277b96eb939c92ae46a0482f5db4622d8' - '431b4d29d69915ede73346129a291f1922d7780f01ec95632ed54767659d9cf0') +makedepends=('git' 'xmlto' 'docbook-utils' 'docbook-xsl' 'docbook-xml' 'docbook-sgml' 'python-gitpython') +source=(git+https://gitlab.freedesktop.org/xdg/xdg-specs.git#commit=9a32db070a486e40b45045a22e39b8ff8905b773 + git+https://gitlab.freedesktop.org/xdg/default-icon-theme.git#commit=f522d9d0bb08c395ccc1a140bf693a9e239ef61e + git+https://gitlab.freedesktop.org/xdg/shared-mime-info.git#commit=09faac14d0c88dc6ee50a59c7d880e9631c39ff3 + git+https://gitlab.freedesktop.org/xdg/sound-theme-spec.git#commit=b38cb3916fbb7243a3f4e78284d5613cc9321c8c + git+https://gitlab.freedesktop.org/xdg/startup-notification.git#commit=07237ff25d6171e1b548118442ddba4259a53ba5 + git+https://gitlab.freedesktop.org/dbus/dbus.git#commit=ef55a3db0d8f17848f8a579092fb05900cc076f5 + git+https://gitlab.freedesktop.org/mpris/mpris-spec.git#commit=51e5848f9f763864568db233bffe98e3cb72bf13 + update.py) +sha256sums=('SKIP' + 'SKIP' + 'SKIP' + 'SKIP' + 'SKIP' + 'SKIP' + 'SKIP' + '9fa781c8618de4c8cb7e7e104426830519947fd8b2f47625847d6dbe027fb245') + +pkgver() { + cd xdg-specs + + # Commit date + short rev + echo $(TZ=UTC git show -s --pretty=%cd --date=format-local:%Y%m%d HEAD).$(git rev-parse --short HEAD) +} + +build() { + cp xdg-specs/web-export/specs.idx . + ./update.py + find build -name '*.proc' -delete #find a way to stop these being produced? +} package() { - cd "$srcdir"/ - mkdir -p "$pkgdir"/usr/share/doc/freedesktop.org - cp -L * "$pkgdir"/usr/share/doc/freedesktop.org/ + cd "$srcdir"/build + install -d "$pkgdir"/usr/share/doc/freedesktop.org/ + cp -r --no-preserve=ownership * "$pkgdir"/usr/share/doc/freedesktop.org/ } diff --git a/trunk/update.py b/trunk/update.py new file mode 100755 index 0000000..99c5924 --- /dev/null +++ b/trunk/update.py @@ -0,0 +1,144 @@ +#!/usr/bin/env python3 + +import os +import sys +import subprocess + +import git +import tempfile + +# Directory to put everything in, relative to the git root directory +OUTPUTDIR = "build" + +# Specifications with their own build system +# FIXME: would be good to be able to use the same script to generate them +SELF_BUILT = [ "idle-inhibit-spec", "secret-service", "mpris-spec" ] + +def safe_mkdir(path): + if not dir: + return + os.makedirs(path,exist_ok=True) + +class VcsObject: + def __init__(self, vcstype, repo, revision): + self.vcstype = vcstype + if self.vcstype != 'git': + raise Exception('Unknown VCS: %s' % self.vcs) + self.repo = repo.split('/')[1] + self.repo = git.Repo(self.repo) + self.revision = revision + + def writeFile(self, outdir, path): + basename = os.path.basename(path) + dirname = os.path.dirname(path) + commit = self.repo.commit(rev=self.revision) + tree=commit.tree + blob=tree[path] + self.writeBlob(outdir, blob) + + def writeDir(self, outdir, path): + commit = self.repo.commit(rev=self.revision) + tree=commit.tree + if path != "": + tree=tree[path] + self.writeTree(outdir, tree) + + def writeTree(self, outdir, tree): + for blob in tree.blobs: + self.writeBlob(outdir, blob) + for subtree in tree.trees: + subdir=os.path.join(outdir, subtree.name) + safe_mkdir(subdir) + self.writeTree(subdir, subtree) + + def writeBlob(self, outdir, blob): + filename = os.path.join(outdir, blob.name) + with open(filename,"wb") as fp: + fp.write(blob.data_stream.read()) + +class SpecObject(): + def __init__(self, vcs, path, spec, out_dir, version): + self.vcs = vcs + self.spec = spec + self.version = version + self.path = path + self.out_dir= os.path.abspath(os.path.join(out_dir, spec, version)) + safe_mkdir(self.out_dir) + self.working_dir=tempfile.TemporaryDirectory() + self.ext = os.path.splitext(self.path)[1] + + if self.ext not in ['.xml', '.sgml', '.txt', '.dtd', '.html']: + raise Exception('Format \'%s\' not supported for %s' % (self.ext, self.vcs.get_url())) + + def _run(self,args): + result = subprocess.run(args, cwd=self.working_dir.name) + result.check_returncode() + + def downloadDir(self,path): + out_dir= self.working_dir.name + self.vcs.writeDir(out_dir, path) + + def generate(self): + one_chunk_command = None + multiple_chunks_command = None + + if self.spec not in SELF_BUILT: + if self.ext in ('.dtd', '.hml', '.txt'): + self.vcs.writeFile(self.out_dir, self.path) + return + else: + self.vcs.writeFile(self.working_dir.name, self.path) + if self.ext == '.xml': + one_chunk_command = ['xmlto', '-o', 'html-nochunks', os.path.basename(self.path)] + multiple_chunks_command = ['xmlto', '-o', 'html', os.path.basename(self.path)] + elif self.ext == '.sgml': + one_chunk_command = ['docbook2html', '-o', '--nochunks', os.path.basename(self.path)] + multiple_chunks_command = ['docbook2html', '-o', os.path.basename(self.path)] + else: + if self.spec == 'mpris-spec': + return #Not supported + self.downloadDir("") + else: + self.downloadDir(os.path.dirname(self.path)) + if self.spec == 'idle-inhibit-spec': + args = ['xsltproc', '-o', 'reference.xml', 'tools/spec-to-docbook.xsl', 'org.freedesktop.ScreenSaver.xml'] + self._run(args) + one_chunk_command = ['xmlto', '-o', '--skip-validation', 'xhtml-nochunks', 'specification.xml'] + multiple_chunks_command = ['xmlto', '-o', '--skip-validation', '-x', 'docbook-params.xsl', 'xhtml', 'specification.xml'] + elif self.spec == 'secret-service': + args = ['xsltproc', '-o', 'reference.xml', 'tools/spec-to-docbook.xsl', 'org.freedesktop.Secrets.xml'] + self._run(args) + one_chunk_command = ['xmlto', '-o', '--skip-validation', 'xhtml-nochunks', 'specification.xml'] + multiple_chunks_command = ['xmlto', '-o', '--skip-validation', '-x', 'docbook-params.xsl', 'xhtml', 'specification.xml'] + + if self.spec in SELF_BUILT: + print("Converting", self.spec,self.version, "to HTML") + else: + print("Converting", self.path,self.version, "to HTML") + + if one_chunk_command: + one_chunk_command.insert(2, self.out_dir) + self._run(one_chunk_command) + + if multiple_chunks_command: + html_dir= os.path.join(self.out_dir, "html-multi") + safe_mkdir(html_dir) + multiple_chunks_command.insert(2, html_dir) + self._run(multiple_chunks_command) + +safe_mkdir(OUTPUTDIR) +with open('specs.idx') as specs: + for line in specs: + line = line.strip() + if not line or line.startswith('#'): + continue + + (data, revision, version, spec) = line.split() + (vcstype, repo, path) = data.split(":") + if vcstype == "git": + vcs = VcsObject('git', repo, revision) + else: + raise Exception('VCS Format \'%s\' not supported for %s' % (vcstype, repo)) + + spec = SpecObject(vcs, path, spec, OUTPUTDIR, version) + spec.generate()