[jhbuild/desrt/master: 29/35] systeminstall: add support for FreeBSD



commit 3e81fa125373e0dad2dcbfdcba736d26cde868ae
Author: Ryan Lortie <desrt desrt ca>
Date:   Sat Jan 3 20:14:16 2015 -0500

    systeminstall: add support for FreeBSD
    
    Follow the general idea of the Debian systeminstall backend.
    
    The technology level is a bit lower here, in two ways:
    
     - there is only one mapping, since there is only one FreeBSD pkg
       collection at a given time
    
     - there is no 'contents' file as on Debian, so the update script must
       be run on a FreeBSD system which has all of the relevant packages
       installed
    
    https://bugzilla.gnome.org/show_bug.cgi?id=742291

 data/Makefile.am                  |    1 +
 data/freebsd-sysdeps.py           |  189 +++++++++++++++++++++++++++++++++++++
 jhbuild/utils/systeminstall.py    |   41 ++++++++-
 scripts/update-freebsd-sysdeps.py |  119 +++++++++++++++++++++++
 4 files changed, 349 insertions(+), 1 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index a1f2fd2..9a4b65e 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,3 +1,4 @@
 pkgdata_DATA = \
        debian-sysdeps.py               \
+       freebsd-sysdeps.py              \
        $(null)
diff --git a/data/freebsd-sysdeps.py b/data/freebsd-sysdeps.py
new file mode 100644
index 0000000..283b181
--- /dev/null
+++ b/data/freebsd-sysdeps.py
@@ -0,0 +1,189 @@
+# this file was generated by scripts/update-freebsd-sysdeps.py
+
+
+{
+    'c_include:X11/extensions/Xinerama.h': 'libXinerama',
+    'c_include:boost/variant.hpp': 'boost-libs',
+    'c_include:crack.h': 'cracklib',
+    'c_include:db.h': '',
+    'c_include:espeak/speak_lib.h': 'espeak',
+    'c_include:expat.h': 'expat',
+    'c_include:gcrypt.h': 'libgcrypt',
+    'c_include:gettext-po.h': 'gettext-tools',
+    'c_include:gflags/gflags.h': 'gflags',
+    'c_include:glm/glm.hpp': 'glm',
+    'c_include:glog/logging.h': 'glog',
+    'c_include:jpeglib.h': 'jpeg',
+    'c_include:ldap.h': 'openldap-client',
+    'c_include:ltdl.h': 'libltdl',
+    'c_include:magic.h': '',
+    'c_include:mpfr.h': 'mpfr',
+    'c_include:readline/readline.h': 'readline',
+    'c_include:sasl/sasl.h': 'cyrus-sasl',
+    'c_include:security/pam_appl.h': '',
+    'c_include:sys/acl.h': '',
+    'c_include:sys/capability.h': '',
+    'c_include:tiff.h': 'tiff',
+    'c_include:unistring/version.h': 'libunistring',
+    'c_include:webp/decode.h': 'webp',
+    'c_include:yaml.h': 'libyaml',
+    'path:automake': 'automake-wrapper',
+    'path:bison': 'bison',
+    'path:bogofilter': 'bogofilter',
+    'path:bzr': 'bzr',
+    'path:c++': '',
+    'path:cc': '',
+    'path:cmake': 'cmake',
+    'path:cups-config': 'cups-client',
+    'path:cvs': 'cvs',
+    'path:desktop-file-validate': 'desktop-file-utils',
+    'path:doxygen': 'doxygen',
+    'path:flex': '',
+    'path:gdb': '',
+    'path:git': 'git',
+    'path:gperf': '',
+    'path:gpg': 'gnupg1',
+    'path:gpgme-config': 'gpgme',
+    'path:hg': 'mercurial',
+    'path:highlight': 'highlight',
+    'path:intltoolize': 'intltool',
+    'path:krb5-config': 'krb5',
+    'path:lcov': 'lcov',
+    'path:libtoolize': 'libtool',
+    'path:make': '',
+    'path:makeinfo': '',
+    'path:msgfmt': 'gettext-tools',
+    'path:pkg-config': 'pkgconf',
+    'path:python2': 'python2',
+    'path:ragel': 'ragel',
+    'path:rapper': 'raptor2',
+    'path:rdfpipe': 'py27-rdflib',
+    'path:ruby': 'ruby',
+    'path:spamassassin': 'spamassassin',
+    'path:sqlite3': 'sqlite3',
+    'path:svn': 'subversion',
+    'path:wget': 'wget',
+    'path:xmlcatalog': 'libxml2',
+    'path:xmllint': 'libxml2',
+    'path:xmlto': 'xmlto',
+    'path:xsltproc': 'libxslt',
+    'path:yasm': 'yasm',
+    'pkgconfig:alsa': 'alsa-lib',
+    'pkgconfig:avahi-gobject': 'avahi-app',
+    'pkgconfig:bdw-gc': 'boehm-gc',
+    'pkgconfig:bdw-gc-threaded': 'boehm-gc-threaded',
+    'pkgconfig:bigreqsproto': 'bigreqsproto',
+    'pkgconfig:cairomm-1.0': 'cairomm',
+    'pkgconfig:dbus-1': 'dbus',
+    'pkgconfig:dbus-glib-1': 'dbus-glib',
+    'pkgconfig:dotconf': 'dotconf',
+    'pkgconfig:dvdread': 'libdvdread',
+    'pkgconfig:egl': 'libEGL',
+    'pkgconfig:enchant': 'enchant',
+    'pkgconfig:exempi-2.0': 'exempi',
+    'pkgconfig:exiv2': 'exiv2',
+    'pkgconfig:flac': 'flac',
+    'pkgconfig:fontconfig': 'fontconfig',
+    'pkgconfig:freetype2': 'freetype2',
+    'pkgconfig:gbm': 'gbm',
+    'pkgconfig:gexiv2': 'gexiv2',
+    'pkgconfig:gl': 'libGL',
+    'pkgconfig:glesv2': 'libglesv2',
+    'pkgconfig:glu': 'libGLU',
+    'pkgconfig:gmime-2.6': 'gmime26',
+    'pkgconfig:gnutls': 'gnutls',
+    'pkgconfig:gtkspell3-3.0': 'gtkspell3',
+    'pkgconfig:guile-2.0': 'guile2',
+    'pkgconfig:icu-i18n': 'icu',
+    'pkgconfig:iso-codes': 'iso-codes',
+    'pkgconfig:json-c': 'json-c',
+    'pkgconfig:kbproto': 'kbproto',
+    'pkgconfig:lcms2': 'lcms2',
+    'pkgconfig:libarchive': 'libarchive',
+    'pkgconfig:libcanberra-gtk': 'libcanberra',
+    'pkgconfig:libcanberra-gtk3': 'libcanberra-gtk3',
+    'pkgconfig:libcrypto': 'openssl',
+    'pkgconfig:libdrm': 'libdrm',
+    'pkgconfig:libexif': 'libexif',
+    'pkgconfig:libffi': 'libffi',
+    'pkgconfig:libgphoto2': 'libgphoto2',
+    'pkgconfig:libgvc': 'graphviz',
+    'pkgconfig:libical': 'libical',
+    'pkgconfig:libmusicbrainz5': 'libmusicbrainz5',
+    'pkgconfig:liboil-0.3': 'liboil',
+    'pkgconfig:libpng': 'png',
+    'pkgconfig:libproxy-1.0': 'libproxy',
+    'pkgconfig:libraw': 'libraw',
+    'pkgconfig:libstartup-notification-1.0': 'startup-notification',
+    'pkgconfig:libtasn1': 'libtasn1',
+    'pkgconfig:libusb-1.0': '',
+    'pkgconfig:libv4l2': 'libv4l',
+    'pkgconfig:libvirt': 'libvirt',
+    'pkgconfig:libxklavier': 'libxklavier',
+    'pkgconfig:libxml-2.0': 'libxml2',
+    'pkgconfig:libxslt': 'libxslt',
+    'pkgconfig:mozjs-24': 'spidermonkey24',
+    'pkgconfig:nice': 'libnice',
+    'pkgconfig:nspr': 'nspr',
+    'pkgconfig:nss': 'nss',
+    'pkgconfig:oauth': 'liboauth',
+    'pkgconfig:opus': 'opus',
+    'pkgconfig:p11-kit-1': 'p11-kit',
+    'pkgconfig:pciaccess': 'libpciaccess',
+    'pkgconfig:pixman-1': 'pixman',
+    'pkgconfig:polkit-agent-1': 'polkit',
+    'pkgconfig:polkit-gobject-1': 'polkit',
+    'pkgconfig:poppler-glib': 'poppler-glib',
+    'pkgconfig:presentproto': 'presentproto',
+    'pkgconfig:protobuf': 'protobuf',
+    'pkgconfig:py3cairo': 'py33-cairo',
+    'pkgconfig:pycairo': 'py27-cairo',
+    'pkgconfig:pygobject-2.0': 'py27-gobject',
+    'pkgconfig:python2': 'python2',
+    'pkgconfig:python3': 'python3',
+    'pkgconfig:resourceproto': 'resourceproto',
+    'pkgconfig:scrnsaverproto': 'scrnsaverproto',
+    'pkgconfig:shared-mime-info': 'shared-mime-info',
+    'pkgconfig:sm': 'libSM',
+    'pkgconfig:smbclient': 'samba36-libsmbclient',
+    'pkgconfig:sndfile': 'libsndfile',
+    'pkgconfig:speex': 'speex',
+    'pkgconfig:sqlite3': 'sqlite3',
+    'pkgconfig:taglib': 'taglib',
+    'pkgconfig:unique-3.0': 'libunique',
+    'pkgconfig:uuid': 'e2fsprogs-libuuid',
+    'pkgconfig:videoproto': 'videoproto',
+    'pkgconfig:vorbisfile': 'libvorbis',
+    'pkgconfig:vpx': 'libvpx',
+    'pkgconfig:wavpack': 'wavpack',
+    'pkgconfig:webkit2gtk-4.0': 'webkit2-gtk3',
+    'pkgconfig:webkitgtk-3.0': 'webkit-gtk3',
+    'pkgconfig:x11': 'libX11',
+    'pkgconfig:xcb': 'libxcb',
+    'pkgconfig:xcb-aux': 'xcb-util',
+    'pkgconfig:xcb-dri2': 'libxcb',
+    'pkgconfig:xcb-xkb': 'libxcb',
+    'pkgconfig:xcmiscproto': 'xcmiscproto',
+    'pkgconfig:xcomposite': 'libXcomposite',
+    'pkgconfig:xcursor': 'libXcursor',
+    'pkgconfig:xdamage': 'libXdamage',
+    'pkgconfig:xext': 'libXext',
+    'pkgconfig:xf86driproto': 'xf86driproto',
+    'pkgconfig:xfixes': 'libXfixes',
+    'pkgconfig:xfont': 'libXfont',
+    'pkgconfig:xft': 'libXft',
+    'pkgconfig:xkbfile': 'libxkbfile',
+    'pkgconfig:xkeyboard-config': 'xkeyboard-config',
+    'pkgconfig:xorg-macros': 'xorg-macros',
+    'pkgconfig:xorg-wacom': 'xf86-input-wacom',
+    'pkgconfig:xproto': 'xproto',
+    'pkgconfig:xrandr': 'libXrandr',
+    'pkgconfig:xt': 'libXt',
+    'pkgconfig:xtrans': 'xtrans',
+    'pkgconfig:xtst': 'libXtst',
+    'pkgconfig:xv': 'libXv',
+    'pkgconfig:zlib': '',
+    'python2:libxml2': 'py27-libxml2',
+    'xml:http://docbook.sourceforge.net/release/xsl/current/': 'docbook-xsl',
+    '': []
+}
diff --git a/jhbuild/utils/systeminstall.py b/jhbuild/utils/systeminstall.py
index 5447863..f784e3e 100644
--- a/jhbuild/utils/systeminstall.py
+++ b/jhbuild/utils/systeminstall.py
@@ -390,6 +390,45 @@ class DebianSystemInstall(SystemInstall):
 
         return sysdeps_data and sysid.get_id() in sysdeps_data
 
+class FreeBSDSystemInstall(SystemInstall):
+    def __init__(self):
+        SystemInstall.__init__(self)
+
+    def install(self, uninstalled):
+        sysdeps_data = read_sysdeps_data('freebsd')
+
+        to_install = set()
+
+        logging.info(_("Using internal database to find packages"))
+
+        for modname, deptype, value in uninstalled:
+            depname = deptype + ':' + value
+
+            if depname in sysdeps_data:
+                if sysdeps_data[depname] == '':
+                    logging.info(_('Installation requested for %(id)s (%(depname)s), '
+                                   'which should be part of the base system') % { 'id'      : modname,
+                                                                                  'depname' : depname })
+                else:
+                    to_install.add(sysdeps_data[depname])
+
+            else:
+                logging.info(_('No native package found for %(id)s '
+                               '(%(filename)s)') % {'id'       : modname,
+                                                    'filename' : depname})
+
+        if to_install:
+            logging.info(_('Installing: %(pkgs)s') % {'pkgs': ' '.join(sorted(to_install))})
+            args = self._root_command_prefix_args + ['pkg', 'install']
+            args.extend(sorted(to_install))
+            subprocess.check_call(args)
+        else:
+            logging.info(_('Nothing to install'))
+
+    @classmethod
+    def detect(cls):
+        return sysid.get_id().startswith('freebsd')
+
 class AptSystemInstall(SystemInstall):
     def __init__(self):
         SystemInstall.__init__(self)
@@ -441,7 +480,7 @@ class AptSystemInstall(SystemInstall):
         return cmds.has_command('apt-file')
 
 # Ordered from best to worst
-_classes = [DebianSystemInstall, AptSystemInstall, PKSystemInstall, YumSystemInstall]
+_classes = [FreeBSDSystemInstall, DebianSystemInstall, AptSystemInstall, PKSystemInstall, YumSystemInstall]
 
 if __name__ == '__main__':
     logging.basicConfig(level=logging.INFO)
diff --git a/scripts/update-freebsd-sysdeps.py b/scripts/update-freebsd-sysdeps.py
new file mode 100755
index 0000000..efb7c9f
--- /dev/null
+++ b/scripts/update-freebsd-sysdeps.py
@@ -0,0 +1,119 @@
+#!/usr/bin/env python2
+
+# Run this script like so:
+#
+#  jhbuild -m gnome-world sysdeps --dump-all `jhbuild -m gnome-world list -a` | ./update-freebsd-sysdeps.py 
../data/freebsd-sysdeps.py
+
+import subprocess
+import sys
+import os
+
+c_include_paths = ['/usr/local/include', '/usr/include']
+pkgconfig_paths = ['/usr/local/lib/pkgconfig', '/usr/local/libdata/pkgconfig', '/usr/libdata/pkgconfig']
+path_paths = ['/usr/local/bin', '/usr/local/sbin', '/usr/bin', '/usr/sbin', '/bin', '/sbin']
+python2_paths = ['/usr/local/lib/python2.7/site-packages']
+
+hints = {
+    'xml:http://docbook.sourceforge.net/release/xsl/current/':            'docbook-xsl',
+    '': ''
+}
+
+ignore = set([
+    'c_include:libdevmapper.h',
+    'c_include:pppd/pppd.h',
+    'c_include:wireless.h',
+    'path:iptables',
+
+    'pkgconfig:ply-boot-client',
+    'pkgconfig:wayland-egl',
+    'pkgconfig:bluez', 'pkgconfig:sbc',
+
+    'pkgconfig:lttng-ust',
+
+    'pkgconfig:libsystemd', 'pkgconfig:libsystemd-daemon',
+    'pkgconfig:libsystemd-journal', 'pkgconfig:libsystemd-login',
+
+    'pkgconfig:gudev-1.0', 'pkgconfig:libudev', 'pkgconfig:libatasmart',
+    'pkgconfig:libnl-3.0', 'pkgconfig:libnl-genl-3.0', 'pkgconfig:libnl-route-3.0',
+    'pkgconfig:mtdev', 'pkgconfig:libndp'
+])
+
+def add_paths(mapping, key, prefixes, name):
+    for p in prefixes:
+        filename = p + '/' + name
+        mapping[filename] = key
+
+def collect_depends(fp):
+    filemap = {}
+
+    for line in fp:
+        line = line.strip()
+        reqtype, _, name = line.partition(':')
+
+        if reqtype == 'path':
+            add_paths(filemap, line, path_paths, name)
+
+        elif reqtype =='c_include':
+            add_paths(filemap, line, c_include_paths, name)
+
+        elif reqtype == 'pkgconfig':
+            add_paths(filemap, line, pkgconfig_paths, name + '.pc')
+
+        elif reqtype == 'python2':
+            add_paths(filemap, line, python2_paths, name + '/__init__.py')
+            add_paths(filemap, line, python2_paths, name + '.py')
+
+        else:
+            filemap[line] = line
+
+    return filemap
+
+def find_pkgs(filemap, log = sys.stderr):
+    result = {}
+
+    for filename in filemap:
+        if os.path.exists(filename):
+            key = filemap[filename]
+
+            if filename.startswith('/usr/local'):
+                assert key not in result or not result[key]
+                output = subprocess.check_output(['pkg', 'which', filename])
+                assert ' installed by package ' in output
+                package = output.split()[-1]
+                name, _, version = package.rpartition('-')
+                assert name
+                result[key] = name
+            else:
+                if key not in result:
+                    result[key] = ''
+
+    for key in sorted(set(filemap.itervalues())):
+        if key not in result:
+            if key in hints:
+                result[key] = hints[key]
+            elif key not in ignore:
+                log.write("# warning: unable to locate dependency '{}'\n".format(key))
+
+    return result
+
+def generate_file(outfile, infile, log = sys.stderr):
+    outfile.write('# this file was generated by scripts/update-freebsd-sysdeps.py\n\n')
+
+    filemap = collect_depends(infile)
+    result = find_pkgs(filemap, log)
+
+    outfile.write('\n')
+    outfile.write('{\n')
+    for key in sorted(result):
+        outfile.write('    {!r}: {!r},\n'.format(key, result[key]))
+    outfile.write("    '': []\n")
+    outfile.write('}\n')
+
+if __name__ == '__main__':
+    if len(sys.argv) != 2:
+        sys.stderr.write("this script must be run with a single argument: the name of the output file\n")
+        sys.exit(1)
+
+    output = open(sys.argv[1], 'w')
+    generate_file(output, sys.stdin, log = output)
+    output.close()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]