[jhbuild/desrt/packagedb: 12/21] systeminstall: add new backend for Debian



commit fcf1afbfd35fd68996628013e47cbd8998c14333
Author: Ryan Lortie <desrt desrt ca>
Date:   Fri Jan 2 13:37:11 2015 -0500

    systeminstall: add new backend for Debian
    
    Add a new systeminstall backend for popular Debian-based distributions.
    
    This backend uses a hardcoded package map for currently-interesting
    releases of Debian and Ubuntu.
    
    A script is included for keeping the mapping file up to date.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=742251

 Makefile.am                      |    2 +-
 configure.ac                     |    1 +
 data/Makefile.am                 |    3 +
 data/debian-sysdeps.py           |  346 ++++++++++++++++++++++++++++++++++++++
 jhbuild/utils/systeminstall.py   |   67 +++++++-
 scripts/update-debian-sysdeps.py |  180 ++++++++++++++++++++
 6 files changed, 596 insertions(+), 3 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 4c506da..b61edb6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = po examples scripts triggers jhbuild buildbot
+SUBDIRS = po examples scripts triggers jhbuild buildbot data
 
 if DOC_INSTALLATION_ENABLED
 SUBDIRS += doc
diff --git a/configure.ac b/configure.ac
index e98086b..7990702 100644
--- a/configure.ac
+++ b/configure.ac
@@ -41,6 +41,7 @@ AC_CONFIG_FILES([
        scripts/Makefile
        triggers/Makefile
        jhbuild.desktop.in
+       data/Makefile
        jhbuild/Makefile
        jhbuild/buildbot/Makefile
        jhbuild/buildbot/status/web/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
new file mode 100644
index 0000000..a1f2fd2
--- /dev/null
+++ b/data/Makefile.am
@@ -0,0 +1,3 @@
+pkgdata_DATA = \
+       debian-sysdeps.py               \
+       $(null)
diff --git a/data/debian-sysdeps.py b/data/debian-sysdeps.py
new file mode 100644
index 0000000..af79413
--- /dev/null
+++ b/data/debian-sysdeps.py
@@ -0,0 +1,346 @@
+# this file was generated by scripts/update-debian-sysdeps.py
+
+# scanning 'debian-7'
+# warning: debian-7: unable to locate dependency 'c_include:glog/logging.h'
+# warning: debian-7: unable to locate dependency 'pkgconfig:gtkspell3-3.0'
+# warning: debian-7: unable to locate dependency 'pkgconfig:json-c'
+# warning: debian-7: unable to locate dependency 'pkgconfig:libndp'
+# warning: debian-7: unable to locate dependency 'pkgconfig:libsystemd'
+# warning: debian-7: unable to locate dependency 'pkgconfig:mozjs-24'
+# warning: debian-7: unable to locate dependency 'pkgconfig:presentproto'
+# warning: debian-7: unable to locate dependency 'pkgconfig:python2'
+# warning: debian-7: unable to locate dependency 'pkgconfig:sbc'
+# warning: debian-7: unable to locate dependency 'pkgconfig:smbclient'
+# warning: debian-7: unable to locate dependency 'pkgconfig:webkit2gtk-4.0'
+# warning: debian-7: unable to locate dependency 'pkgconfig:xcb-xkb'
+# scanning 'debian-8'
+# scanning 'ubuntu-14.04'
+# warning: ubuntu-14.04: unable to locate dependency 'pkgconfig:libndp'
+# warning: ubuntu-14.04: unable to locate dependency 'pkgconfig:libsystemd'
+# warning: ubuntu-14.04: unable to locate dependency 'pkgconfig:webkit2gtk-4.0'
+# scanning 'ubuntu-14.10'
+# warning: ubuntu-14.10: unable to locate dependency 'pkgconfig:libsystemd'
+# warning: ubuntu-14.10: unable to locate dependency 'pkgconfig:webkit2gtk-4.0'
+# scanning 'ubuntu-15.04'
+
+{
+    'common': {
+        'c_include:X11/extensions/Xinerama.h': ['libxinerama-dev'],
+        'c_include:crack.h': ['libcrack2-dev'],
+        'c_include:espeak/speak_lib.h': ['libespeak-dev'],
+        'c_include:expat.h': ['libexpat1-dev'],
+        'c_include:gflags/gflags.h': ['libgflags-dev'],
+        'c_include:glm/glm.hpp': ['libglm-dev'],
+        'c_include:ldap.h': ['libldap2-dev'],
+        'c_include:libdevmapper.h': ['libdevmapper-dev'],
+        'c_include:ltdl.h': ['libltdl-dev'],
+        'c_include:magic.h': ['libmagic-dev'],
+        'c_include:mpfr.h': ['libmpfr-dev'],
+        'c_include:pppd/pppd.h': ['ppp-dev'],
+        'c_include:readline/readline.h': ['libreadline-gplv2-dev', 'libreadline6-dev'],
+        'c_include:sasl/sasl.h': ['libsasl2-dev'],
+        'c_include:security/pam_appl.h': ['libpam0g-dev'],
+        'c_include:sys/acl.h': ['libacl1-dev'],
+        'c_include:sys/capability.h': ['libcap-dev'],
+        'c_include:unistring/version.h': ['libunistring-dev'],
+        'c_include:webp/decode.h': ['libwebp-dev'],
+        'c_include:wireless.h': ['libiw-dev'],
+        'c_include:yaml.h': ['libyaml-dev'],
+        'path:automake': ['automake'],
+        'path:bison': ['bison', 'bison++'],
+        'path:bogofilter': ['bogofilter'],
+        'path:bzr': ['bzr'],
+        'path:c++': ['g++', 'clang'],
+        'path:cc': ['gcc', 'clang'],
+        'path:cmake': ['cmake'],
+        'path:cups-config': ['libcups2-dev'],
+        'path:cvs': ['cvs'],
+        'path:desktop-file-validate': ['desktop-file-utils'],
+        'path:doxygen': ['doxygen'],
+        'path:flex': ['flex', 'flex-old'],
+        'path:git': ['git'],
+        'path:gperf': ['gperf'],
+        'path:gpg': ['gnupg'],
+        'path:gpgme-config': ['libgpgme11-dev'],
+        'path:hg': ['mercurial'],
+        'path:highlight': ['highlight'],
+        'path:intltoolize': ['intltool'],
+        'path:iptables': ['iptables'],
+        'path:krb5-config': ['heimdal-dev', 'libkrb5-dev'],
+        'path:lcov': ['lcov'],
+        'path:libtoolize': ['libtool'],
+        'path:makeinfo': ['texinfo'],
+        'path:msgfmt': ['gettext'],
+        'path:python2': ['python-minimal'],
+        'path:ragel': ['ragel'],
+        'path:rapper': ['raptor-utils', 'raptor2-utils'],
+        'path:ruby': ['ruby'],
+        'path:spamassassin': ['spamassassin'],
+        'path:sqlite3': ['sqlite3'],
+        'path:svn': ['subversion'],
+        'path:wget': ['wget'],
+        'path:xmlcatalog': ['libxml2-utils'],
+        'path:xmllint': ['libxml2-utils'],
+        'path:xmlto': ['xmlto'],
+        'path:xsltproc': ['xsltproc'],
+        'path:yasm': ['yasm'],
+        'pkgconfig:alsa': ['libasound2-dev'],
+        'pkgconfig:avahi-gobject': ['libavahi-gobject-dev'],
+        'pkgconfig:bdw-gc': ['libgc-dev'],
+        'pkgconfig:bigreqsproto': ['x11proto-bigreqs-dev'],
+        'pkgconfig:bluez': ['libbluetooth-dev'],
+        'pkgconfig:cairomm-1.0': ['libcairomm-1.0-dev'],
+        'pkgconfig:dbus-1': ['libdbus-1-dev'],
+        'pkgconfig:dbus-glib-1': ['libdbus-glib-1-dev'],
+        'pkgconfig:dotconf': ['libdotconf-dev'],
+        'pkgconfig:dvdread': ['libdvdread-dev'],
+        'pkgconfig:egl': ['libegl1-mesa-dev'],
+        'pkgconfig:enchant': ['libenchant-dev'],
+        'pkgconfig:exempi-2.0': ['libexempi-dev'],
+        'pkgconfig:exiv2': ['libexiv2-dev'],
+        'pkgconfig:flac': ['libflac-dev'],
+        'pkgconfig:fontconfig': ['libfontconfig1-dev'],
+        'pkgconfig:freetype2': ['libfreetype6-dev'],
+        'pkgconfig:gbm': ['libgbm-dev'],
+        'pkgconfig:gexiv2': ['libgexiv2-dev'],
+        'pkgconfig:glesv2': ['libgles2-mesa-dev'],
+        'pkgconfig:glu': ['libglu1-mesa-dev'],
+        'pkgconfig:gmime-2.6': ['libgmime-2.6-dev'],
+        'pkgconfig:gudev-1.0': ['libgudev-1.0-dev'],
+        'pkgconfig:guile-2.0': ['guile-2.0-dev'],
+        'pkgconfig:icu-i18n': ['libicu-dev'],
+        'pkgconfig:iso-codes': ['iso-codes'],
+        'pkgconfig:kbproto': ['x11proto-kb-dev'],
+        'pkgconfig:lcms2': ['liblcms2-dev'],
+        'pkgconfig:libarchive': ['libarchive-dev'],
+        'pkgconfig:libatasmart': ['libatasmart-dev'],
+        'pkgconfig:libcanberra-gtk': ['libcanberra-gtk-dev'],
+        'pkgconfig:libcanberra-gtk3': ['libcanberra-gtk3-dev'],
+        'pkgconfig:libcrypto': ['libssl-dev'],
+        'pkgconfig:libdrm': ['libdrm-dev'],
+        'pkgconfig:libexif': ['libexif-dev'],
+        'pkgconfig:libffi': ['libffi-dev'],
+        'pkgconfig:libgvc': ['libgraphviz-dev'],
+        'pkgconfig:libical': ['libical-dev'],
+        'pkgconfig:libmusicbrainz5': ['libmusicbrainz5-dev'],
+        'pkgconfig:libnl-3.0': ['libnl-3-dev'],
+        'pkgconfig:libnl-genl-3.0': ['libnl-genl-3-dev'],
+        'pkgconfig:libnl-route-3.0': ['libnl-route-3-dev'],
+        'pkgconfig:liboil-0.3': ['liboil0.3-dev'],
+        'pkgconfig:libpng': ['libpng12-dev'],
+        'pkgconfig:libproxy-1.0': ['libproxy-dev'],
+        'pkgconfig:libraw': ['libraw-dev'],
+        'pkgconfig:libstartup-notification-1.0': ['libstartup-notification0-dev'],
+        'pkgconfig:libsystemd-daemon': ['libsystemd-daemon-dev'],
+        'pkgconfig:libsystemd-journal': ['libsystemd-journal-dev'],
+        'pkgconfig:libsystemd-login': ['libsystemd-login-dev'],
+        'pkgconfig:libudev': ['libudev-dev'],
+        'pkgconfig:libusb-1.0': ['libusb-1.0-0-dev'],
+        'pkgconfig:libv4l2': ['libv4l-dev'],
+        'pkgconfig:libvirt': ['libvirt-dev'],
+        'pkgconfig:libxklavier': ['libxklavier-dev'],
+        'pkgconfig:libxml-2.0': ['libxml2-dev'],
+        'pkgconfig:libxslt': ['libxslt1-dev'],
+        'pkgconfig:lttng-ust': ['liblttng-ust-dev'],
+        'pkgconfig:mtdev': ['libmtdev-dev'],
+        'pkgconfig:nice': ['libnice-dev'],
+        'pkgconfig:nspr': ['libnspr4-dev'],
+        'pkgconfig:nss': ['libnss3-dev'],
+        'pkgconfig:oauth': ['liboauth-dev'],
+        'pkgconfig:opus': ['libopus-dev'],
+        'pkgconfig:p11-kit-1': ['libp11-kit-dev'],
+        'pkgconfig:pciaccess': ['libpciaccess-dev'],
+        'pkgconfig:pixman-1': ['libpixman-1-dev'],
+        'pkgconfig:polkit-agent-1': ['libpolkit-agent-1-dev'],
+        'pkgconfig:polkit-gobject-1': ['libpolkit-gobject-1-dev'],
+        'pkgconfig:poppler-glib': ['libpoppler-glib-dev'],
+        'pkgconfig:protobuf': ['libprotobuf-dev'],
+        'pkgconfig:py3cairo': ['python3-cairo-dev'],
+        'pkgconfig:pycairo': ['python-cairo-dev'],
+        'pkgconfig:pygobject-2.0': ['python-gobject-2-dev'],
+        'pkgconfig:python3': ['python3-dev'],
+        'pkgconfig:resourceproto': ['x11proto-resource-dev'],
+        'pkgconfig:scrnsaverproto': ['x11proto-scrnsaver-dev'],
+        'pkgconfig:shared-mime-info': ['shared-mime-info'],
+        'pkgconfig:sm': ['libsm-dev'],
+        'pkgconfig:sndfile': ['libsndfile1-dev'],
+        'pkgconfig:speex': ['libspeex-dev'],
+        'pkgconfig:sqlite3': ['libsqlite3-dev'],
+        'pkgconfig:taglib': ['libtag1-dev'],
+        'pkgconfig:unique-3.0': ['libunique-3.0-dev'],
+        'pkgconfig:uuid': ['uuid-dev'],
+        'pkgconfig:videoproto': ['x11proto-video-dev'],
+        'pkgconfig:vorbisfile': ['libvorbis-dev'],
+        'pkgconfig:vpx': ['libvpx-dev'],
+        'pkgconfig:wavpack': ['libwavpack-dev'],
+        'pkgconfig:wayland-egl': ['libegl1-mesa-dev'],
+        'pkgconfig:webkitgtk-3.0': ['libwebkitgtk-3.0-dev'],
+        'pkgconfig:x11': ['libx11-dev'],
+        'pkgconfig:xcb': ['libxcb1-dev'],
+        'pkgconfig:xcb-aux': ['libxcb-util0-dev'],
+        'pkgconfig:xcb-dri2': ['libxcb-dri2-0-dev'],
+        'pkgconfig:xcmiscproto': ['x11proto-xcmisc-dev'],
+        'pkgconfig:xcomposite': ['libxcomposite-dev'],
+        'pkgconfig:xcursor': ['libxcursor-dev'],
+        'pkgconfig:xdamage': ['libxdamage-dev'],
+        'pkgconfig:xext': ['libxext-dev'],
+        'pkgconfig:xf86driproto': ['x11proto-xf86dri-dev'],
+        'pkgconfig:xfixes': ['libxfixes-dev'],
+        'pkgconfig:xfont': ['libxfont-dev'],
+        'pkgconfig:xft': ['libxft-dev'],
+        'pkgconfig:xkbfile': ['libxkbfile-dev'],
+        'pkgconfig:xkeyboard-config': ['xkb-data'],
+        'pkgconfig:xorg-macros': ['xutils-dev'],
+        'pkgconfig:xorg-wacom': ['xserver-xorg-input-wacom'],
+        'pkgconfig:xproto': ['x11proto-core-dev'],
+        'pkgconfig:xrandr': ['libxrandr-dev'],
+        'pkgconfig:xt': ['libxt-dev'],
+        'pkgconfig:xtrans': ['xtrans-dev'],
+        'pkgconfig:xtst': ['libxtst-dev'],
+        'pkgconfig:xv': ['libxv-dev'],
+        'pkgconfig:zlib': ['zlib1g-dev'],
+        'python2:libxml2': ['python-libxml2'],
+        'xml:http://docbook.sourceforge.net/release/xsl/current/': ['docbook-xsl'],
+        '': []
+    },
+
+    'debian-7': {
+        'c_include:boost/variant.hpp': ['libboost1.49-dev'],
+        'c_include:db.h': ['libdb5.1-dev'],
+        'c_include:gcrypt.h': ['libgcrypt11-dev'],
+        'c_include:gettext-po.h': ['gettext'],
+        'c_include:jpeglib.h': ['libjpeg62-dev', 'libjpeg8-dev'],
+        'c_include:tiff.h': ['libtiff4-dev', 'libtiff5-dev'],
+        'path:gdb': ['gdb', 'gdb-minimal'],
+        'path:make': ['make'],
+        'path:pkg-config': ['pkg-config'],
+        'path:rdfpipe': ['python-rdflib'],
+        'pkgconfig:gl': ['libgl1-mesa-dev'],
+        'pkgconfig:gnutls': ['libgnutls-dev'],
+        'pkgconfig:libgphoto2': ['libgphoto2-2-dev'],
+        'pkgconfig:libtasn1': ['libtasn1-3-dev'],
+        'pkgconfig:ply-boot-client': ['plymouth-dev'],
+        '': []
+    },
+
+    'debian-8': {
+        'c_include:boost/variant.hpp': ['libboost1.55-dev'],
+        'c_include:db.h': ['libdb5.3-dev'],
+        'c_include:gcrypt.h': ['libgcrypt20-dev'],
+        'c_include:gettext-po.h': ['libgettextpo-dev'],
+        'c_include:glog/logging.h': ['libgoogle-glog-dev'],
+        'c_include:jpeglib.h': ['libjpeg62-turbo-dev', 'libjpeg8-dev', 'libjpeg9-dev'],
+        'c_include:tiff.h': ['libtiff5-dev'],
+        'path:gdb': ['gdb', 'gdb-minimal'],
+        'path:make': ['make', 'make-guile'],
+        'path:pkg-config': ['pkg-config', 'pkgconf'],
+        'path:rdfpipe': ['python-rdflib-tools'],
+        'pkgconfig:gl': ['libgl1-mesa-dev', 'libgl1-mesa-swx11-dev'],
+        'pkgconfig:gnutls': ['libgnutls28-dev'],
+        'pkgconfig:gtkspell3-3.0': ['libgtkspell3-3-dev'],
+        'pkgconfig:json-c': ['libjson-c-dev'],
+        'pkgconfig:libgphoto2': ['libgphoto2-dev'],
+        'pkgconfig:libndp': ['libndp-dev'],
+        'pkgconfig:libsystemd': ['libsystemd-dev'],
+        'pkgconfig:libtasn1': ['libtasn1-6-dev'],
+        'pkgconfig:mozjs-24': ['libmozjs-24-dev'],
+        'pkgconfig:ply-boot-client': ['plymouth-dev'],
+        'pkgconfig:presentproto': ['x11proto-present-dev'],
+        'pkgconfig:python2': ['python-dev'],
+        'pkgconfig:sbc': ['libsbc-dev'],
+        'pkgconfig:smbclient': ['libsmbclient-dev'],
+        'pkgconfig:webkit2gtk-4.0': ['libwebkit2gtk-4.0-dev'],
+        'pkgconfig:xcb-xkb': ['libxcb-xkb-dev'],
+        '': []
+    },
+
+    'ubuntu-14.04': {
+        'c_include:boost/variant.hpp': ['libboost1.54-dev', 'libboost1.55-dev'],
+        'c_include:db.h': ['libdb5.3-dev', 'libdb6.0-dev', 'libdb5.1-dev'],
+        'c_include:gcrypt.h': ['libgcrypt11-dev', 'libgcrypt20-dev'],
+        'c_include:gettext-po.h': ['libgettextpo-dev'],
+        'c_include:glog/logging.h': ['libgoogle-glog-dev'],
+        'c_include:jpeglib.h': ['libjpeg-turbo8-dev', 'libjpeg62-dev'],
+        'c_include:tiff.h': ['libtiff5-dev'],
+        'path:gdb': ['gdb', 'gdb-minimal'],
+        'path:make': ['make'],
+        'path:pkg-config': ['pkg-config', 'pkgconf'],
+        'path:rdfpipe': ['python-rdflib'],
+        'pkgconfig:gl': ['libgl1-mesa-dev'],
+        'pkgconfig:gnutls': ['libgnutls-dev', 'libgnutls28-dev'],
+        'pkgconfig:gtkspell3-3.0': ['libgtkspell3-3-dev'],
+        'pkgconfig:json-c': ['libjson-c-dev'],
+        'pkgconfig:libgphoto2': ['libgphoto2-dev'],
+        'pkgconfig:libtasn1': ['libtasn1-6-dev'],
+        'pkgconfig:mozjs-24': ['libmozjs-24-dev'],
+        'pkgconfig:ply-boot-client': ['libplymouth-dev'],
+        'pkgconfig:presentproto': ['x11proto-present-dev'],
+        'pkgconfig:python2': ['python-dev'],
+        'pkgconfig:sbc': ['libsbc-dev'],
+        'pkgconfig:smbclient': ['libsmbclient-dev'],
+        'pkgconfig:xcb-xkb': ['libxcb-xkb-dev'],
+        '': []
+    },
+
+    'ubuntu-14.10': {
+        'c_include:boost/variant.hpp': ['libboost1.55-dev', 'libboost1.54-dev'],
+        'c_include:db.h': ['libdb5.3-dev', 'libdb5.1-dev'],
+        'c_include:gcrypt.h': ['libgcrypt11-dev', 'libgcrypt20-dev'],
+        'c_include:gettext-po.h': ['libgettextpo-dev'],
+        'c_include:glog/logging.h': ['libgoogle-glog-dev'],
+        'c_include:jpeglib.h': ['libjpeg-turbo8-dev', 'libjpeg62-dev'],
+        'c_include:tiff.h': ['libtiff5-dev'],
+        'path:gdb': ['gdb'],
+        'path:make': ['make', 'make-guile'],
+        'path:pkg-config': ['pkg-config', 'pkgconf'],
+        'path:rdfpipe': ['python-rdflib-tools'],
+        'pkgconfig:gl': ['libgl1-mesa-dev'],
+        'pkgconfig:gnutls': ['libgnutls-dev'],
+        'pkgconfig:gtkspell3-3.0': ['libgtkspell3-3-dev'],
+        'pkgconfig:json-c': ['libjson-c-dev'],
+        'pkgconfig:libgphoto2': ['libgphoto2-dev'],
+        'pkgconfig:libndp': ['libndp-dev'],
+        'pkgconfig:libtasn1': ['libtasn1-6-dev'],
+        'pkgconfig:mozjs-24': ['libmozjs-24-dev'],
+        'pkgconfig:ply-boot-client': ['libplymouth-dev'],
+        'pkgconfig:presentproto': ['x11proto-present-dev'],
+        'pkgconfig:python2': ['python-dev'],
+        'pkgconfig:sbc': ['libsbc-dev'],
+        'pkgconfig:smbclient': ['libsmbclient-dev'],
+        'pkgconfig:xcb-xkb': ['libxcb-xkb-dev'],
+        '': []
+    },
+
+    'ubuntu-15.04': {
+        'c_include:boost/variant.hpp': ['libboost1.55-dev', 'libboost1.54-dev'],
+        'c_include:db.h': ['libdb5.3-dev'],
+        'c_include:gcrypt.h': ['libgcrypt20-dev'],
+        'c_include:gettext-po.h': ['libgettextpo-dev'],
+        'c_include:glog/logging.h': ['libgoogle-glog-dev'],
+        'c_include:jpeglib.h': ['libjpeg-turbo8-dev', 'libjpeg62-dev'],
+        'c_include:tiff.h': ['libtiff5-dev'],
+        'path:gdb': ['gdb'],
+        'path:make': ['make', 'make-guile'],
+        'path:pkg-config': ['pkg-config', 'pkgconf'],
+        'path:rdfpipe': ['python-rdflib-tools'],
+        'pkgconfig:gl': ['libgl1-mesa-dev'],
+        'pkgconfig:gnutls': ['libgnutls-dev'],
+        'pkgconfig:gtkspell3-3.0': ['libgtkspell3-3-dev'],
+        'pkgconfig:json-c': ['libjson-c-dev'],
+        'pkgconfig:libgphoto2': ['libgphoto2-dev'],
+        'pkgconfig:libndp': ['libndp-dev'],
+        'pkgconfig:libsystemd': ['libsystemd-dev'],
+        'pkgconfig:libtasn1': ['libtasn1-6-dev'],
+        'pkgconfig:mozjs-24': ['libmozjs-24-dev'],
+        'pkgconfig:ply-boot-client': ['libplymouth-dev'],
+        'pkgconfig:presentproto': ['x11proto-present-dev'],
+        'pkgconfig:python2': ['python-dev'],
+        'pkgconfig:sbc': ['libsbc-dev'],
+        'pkgconfig:smbclient': ['libsmbclient-dev'],
+        'pkgconfig:webkit2gtk-4.0': ['libwebkit2gtk-4.0-dev'],
+        'pkgconfig:xcb-xkb': ['libxcb-xkb-dev'],
+        '': []
+    },
+
+    '': {}
+}
diff --git a/jhbuild/utils/systeminstall.py b/jhbuild/utils/systeminstall.py
index c5ebd0c..faccaaa 100644
--- a/jhbuild/utils/systeminstall.py
+++ b/jhbuild/utils/systeminstall.py
@@ -18,12 +18,14 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 import os
-import sys 
+import ast
+import sys
 import logging
 import shlex
 import subprocess
 import pipes
 import imp
+import sysid
 from StringIO import StringIO
 
 import cmds
@@ -177,6 +179,23 @@ def systemdependencies_met(module_name, sysdeps, config):
 
     return True
 
+sysdeps_data_cache = {}
+def read_sysdeps_data(name):
+    if name not in sysdeps_data_cache:
+        try:
+            if PKGDATADIR is not None:
+                filename = os.path.join(PKGDATADIR, '{}-sysdeps.py'.format(name))
+            else:
+                filename = os.path.join(SRCDIR, 'data', '{}-sysdeps.py'.format(name))
+
+            fp = open(filename)
+            sysdeps_data_cache[name] = ast.literal_eval(fp.read())
+            fp.close()
+        except:
+            sysdeps_data_cache[name] = None
+
+    return sysdeps_data_cache.get(name)
+
 class SystemInstall(object):
     def __init__(self):
         if cmds.has_command('pkexec'):
@@ -347,6 +366,50 @@ class YumSystemInstall(SystemInstall):
         return cmds.has_command('yum')
 
 
+class DebianSystemInstall(SystemInstall):
+    def __init__(self):
+        SystemInstall.__init__(self)
+
+    def install(self, uninstalled):
+        myid = sysid.get_id()
+
+        sysdeps_data = read_sysdeps_data('debian')
+        package_list = dict(sysdeps_data[myid])
+        package_list.update(sysdeps_data['common'])
+
+        to_install = set()
+
+        logging.info(_("Using internal database for '%s' to find packages") % (myid,))
+
+        for modname, deptype, value in uninstalled:
+            depname = deptype + ':' + value
+
+            if depname in package_list:
+                # as below, just blindly take the first hit
+                to_install.add(package_list[depname][0])
+
+            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 + ['apt-get', 'install']
+            args.extend(sorted(to_install))
+            subprocess.check_call(args)
+        else:
+            logging.info(_('Nothing to install'))
+
+    @classmethod
+    def detect(cls):
+        if not cmds.has_command('apt-get'):
+            return False
+
+        sysdeps_data = read_sysdeps_data('debian')
+
+        return sysdeps_data and sysid.get_id() in sysdeps_data
+
 class AptSystemInstall(SystemInstall):
     def __init__(self):
         SystemInstall.__init__(self)
@@ -398,7 +461,7 @@ class AptSystemInstall(SystemInstall):
         return cmds.has_command('apt-file')
 
 # Ordered from best to worst
-_classes = [AptSystemInstall, PKSystemInstall, YumSystemInstall]
+_classes = [DebianSystemInstall, AptSystemInstall, PKSystemInstall, YumSystemInstall]
 
 if __name__ == '__main__':
     logging.basicConfig(level=logging.INFO)
diff --git a/scripts/update-debian-sysdeps.py b/scripts/update-debian-sysdeps.py
new file mode 100755
index 0000000..7c3a679
--- /dev/null
+++ b/scripts/update-debian-sysdeps.py
@@ -0,0 +1,180 @@
+#!/usr/bin/env python2
+
+# Run this script like so:
+#
+#  jhbuild -m gnome-world sysdeps --dump-all `jhbuild -m gnome-world list -a` | ./update-debian-sysdeps.py 
../data/debian-sysdeps.py
+
+import urlgrabber.progress
+import urlgrabber
+import gzip
+import sys
+import os
+
+# in general, we aim to support (roughly):
+#
+#  - Debian: oldstable, stable, testing, unstable
+#
+#  - Ubuntu: last LTS, last stable, current unstable
+#
+# note for Debian: sid seems to identify itself in os-release under the
+#                  codename of the current testing release, so we probably
+#                  won't see 'unstable' here separately
+releases = {
+  'debian-7':       'http://ftp.debian.org/debian/dists/wheezy/main',
+  'debian-8':       'http://ftp.debian.org/debian/dists/jessie/main',
+  'ubuntu-14.04':   'http://archive.ubuntu.com/ubuntu/dists/trusty',
+  'ubuntu-14.10':   'http://archive.ubuntu.com/ubuntu/dists/utopic',
+  'ubuntu-15.04':   'http://archive.ubuntu.com/ubuntu/dists/vivid'
+}
+
+# We always search using Contents-amd64 under the premise that the package
+# names for the dependency won't change depending on the arch.  We can
+# therefore freely hardcode 'x86_64-linue-gnu' below.
+#
+# python2 is currently a bit of a hack since we always assume 2.7, but
+# that seems to be a valid assumption for now
+c_include_paths = ['/usr/include', '/usr/include/x86_64-linux-gnu']
+pkgconfig_paths = ['/usr/lib/x86_64-linux-gnu/pkgconfig', '/usr/lib/pkgconfig', '/usr/share/pkgconfig']
+path_paths = ['/usr/bin', '/usr/sbin', '/bin', '/sbin']
+python2_paths = ['/usr/lib/python2.7/dist-packages']
+
+# things that we know we won't find, either because we're not clever
+# enough (xml) or because of alternatives (not listed in apt-file)
+hints = {
+  'xml:http://docbook.sourceforge.net/release/xsl/current/':         ['docbook-xsl'],
+  'path:cc':                                                         ['gcc', 'clang'],
+  'path:c++':                                                        ['g++', 'clang'],
+  'path:automake':                                                   ['automake'],
+  'path:bogofilter':                                                 ['bogofilter'],
+  'path:ruby':                                                       ['ruby'],  # needed for wheezy
+  '' : []
+}
+
+def add_paths(mapping, key, prefixes, name):
+    for p in prefixes:
+        filename = p[1:] + '/' + 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_interesting_lines(fp, search_items):
+    line = fp.next()
+    while True:
+        res = cmp(search_items[0], line)
+
+        if res > 0:
+            line = fp.next()
+
+        else:
+            # apt-file has a weird format -- it is whitespace-delimited
+            # but the filenames can also contain spaces...
+            # it is unlikely that we will find a filename that starts
+            # with the name of a file that we are looking for followed
+            # by a space...
+            if line.startswith(search_items[0]) and line[len(search_items[0])].isspace():
+                yield line.split()
+
+            del search_items[0]
+            if not search_items:
+                return
+
+def handle_distro(name, filemap, log = sys.stderr):
+    contents = gzip.open(name + '-Contents-amd64.gz')
+    keys = set(filemap.itervalues())
+    result = {}
+
+    while not contents.next().startswith('FILE'):
+        pass
+
+    for filename, pkgs in find_interesting_lines(contents, sorted(filemap)):
+        key = filemap[filename]
+        assert key not in result
+        result[key] = [pkg.split('/')[-1] for pkg in pkgs.split(',')]
+
+    for key in sorted(keys):
+        if key not in result:
+            if key in hints:
+                result[key] = hints[key]
+            else:
+                log.write("# warning: {}: unable to locate dependency '{}'\n".format(name, key))
+
+    return result
+
+def print_sorted_dict(outfile, name, items):
+    outfile.write('    {!r}: {{\n'.format(name))
+    for key in sorted(items):
+        outfile.write('        {!r}: {!r},\n'.format(key, items[key]))
+    outfile.write("        '': []\n")
+    outfile.write('    },\n\n')
+
+def generate_debian_py(outfile, infile, log = sys.stderr):
+    outfile.write('# this file was generated by scripts/update-debian-sysdeps.py\n\n')
+
+    filemap = collect_depends(infile)
+    package_lists = {}
+    common = {}
+
+    for name in sorted(releases):
+        log.write("# scanning '{}'\n".format(name))
+        package_lists[name] = handle_distro(name, filemap, log)
+
+    for dep in set(filemap.itervalues()):
+        pkgs = [dist.get(dep) for dist in package_lists.itervalues()]
+        if all(pkg == pkgs[0] for pkg in pkgs):
+            # maybe they all failed?
+            if not pkgs[0]:
+                continue
+
+            common[dep] = pkgs[0]
+            for dist in package_lists.itervalues():
+                del dist[dep]
+
+    outfile.write('\n')
+    outfile.write('{\n')
+    print_sorted_dict(outfile, 'common', common)
+    for dist in sorted(package_lists):
+        print_sorted_dict(outfile, dist, package_lists[dist])
+    outfile.write("    '': {}\n}\n")
+
+def download_files(urls, filename):
+    for name, url in urls.iteritems():
+        fullname = name + '-' + filename
+        if not os.path.isfile(fullname):
+            urlgrabber.urlgrab(url + '/' + filename, fullname + '.partial',
+                               progress_obj=urlgrabber.progress.TextMeter(),
+                               text='Contents-amd64.gz ({})'.format(name),
+                               timeout=10)
+            os.rename(fullname + '.partial', fullname)
+
+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)
+
+    download_files(releases, 'Contents-amd64.gz')
+    output = open(sys.argv[1], 'w')
+    generate_debian_py(output, sys.stdin, log = output)
+    output.close()


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