Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4271)

Unified Diff: chrome/installer/linux/sysroot_scripts/generate_precise_dpkg_admin_dir.py

Issue 786543004: Linux: Add a script to generate a Precise dpkg admin dir for use with official builds on Trusty. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/linux/sysroot_scripts/generate_precise_dpkg_admin_dir.py
diff --git a/chrome/installer/linux/sysroot_scripts/generate_precise_dpkg_admin_dir.py b/chrome/installer/linux/sysroot_scripts/generate_precise_dpkg_admin_dir.py
new file mode 100755
index 0000000000000000000000000000000000000000..af57926ff1a5c31c0f23cbd608acc00d99e8eb8c
--- /dev/null
+++ b/chrome/installer/linux/sysroot_scripts/generate_precise_dpkg_admin_dir.py
@@ -0,0 +1,165 @@
+#!/usr/bin/env python
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Takes in a Ubuntu Precise dpkg admin directory (typically /var/lib/dpkg) and
+# outputs a dpkg admin directory appropriate for use with dpkg-shlibdeps on
+# Ubuntu Trusty.
+#
+# Example usage:
+# generate_precise_dpkg_admin_dir.py --arch i386 \
+# /path/to/precise_32-bit_chroot/var/lib/dpkg /path/to/dest_dir
+
+import optparse
+import os
+import shutil
+import string
+import sys
+
+
+SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
+PACKAGES = [
Paweł Hajdan Jr. 2014/12/08 10:12:15 Can we de-duplicate the list of packages between t
+ "libasound2",
+ "libc6",
+ "libcairo2",
+ "libcups2",
+ "libdbus-1-3",
+ "libexpat1",
+ "libfontconfig1",
+ "libfreetype6",
+ "libgconf-2-4",
+ "libgdk-pixbuf2.0-0",
+ "libglib2.0-0",
+ "libgtk2.0-0",
+ "libnspr4",
+ "libnss3",
+ "libpango-1.0-0",
+ "libpangocairo-1.0-0",
+ "libstdc++6",
+ "libx11-6",
+ "libxcomposite1",
+ "libxcursor1",
+ "libxdamage1",
+ "libxext6",
+ "libxfixes3",
+ "libxi6",
+ "libxrandr2",
+ "libxrender1",
+ "libxss1",
+ "libxtst6",
+]
+
+
+def ParseStatusFile(status_file):
+ package_map = {}
+ lines = open(status_file).readlines()
+ current_package_name = ''
+ current_package_data = ''
+ for line in lines:
+ if (not line or
+ line[0] not in string.ascii_uppercase or
+ line.startswith('Homepage: ') or
+ line.startswith('Original-Maintainer: ')):
+ continue
+ if line.startswith('Package: '):
+ if current_package_name:
+ package_map[current_package_name] = current_package_data
+ current_package_name = line[len('Package: '):].strip()
+ current_package_data = ''
+ # Hack for libpango1.0-0 vs libpango-1.0-0
Paweł Hajdan Jr. 2014/12/08 10:12:15 Could you explain more why we need this hack? If p
+ if current_package_name == 'libpango1.0-0':
+ current_package_name = 'libpango-1.0-0'
+ else:
+ current_package_data += line
+
+ # Hack for libpangocairo-1.0-0
Paweł Hajdan Jr. 2014/12/08 10:12:15 Same here, I'm really surprised we'd need this. C
+ if 'libpango-1.0-0' in package_map:
+ assert('libpangocairo-1.0-0' not in package_map)
+ package_map['libpangocairo-1.0-0'] = package_map['libpango-1.0-0']
+ return package_map
+
+
+def main():
+ if options.arch not in ['amd64', 'i386']:
Paweł Hajdan Jr. 2014/12/08 10:12:15 At least argparse has built-in ways to validate th
+ print 'Unknown architecture: %s' % options.arch
+ return 1
+
+ if len(args) != 2:
+ print 'Wrong number of arguments.'
+ return 1
+
+ src_dir = args[0]
+ dest_dir = args[1]
+
+ src_status_file = os.path.join(src_dir, 'status')
+ src_info_dir = os.path.join(src_dir, 'info')
+ src_info_format_file = os.path.join(src_info_dir, 'format')
+ src_triggers_dir = os.path.join(src_dir, 'triggers')
+ src_updates_dir = os.path.join(src_dir, 'updates')
+ if not os.path.isfile(src_status_file):
+ print 'status file not found. (%s)' % src_status_file
+ return 1
+ if not os.path.isdir(src_info_dir):
+ print 'info dir not found. (%s)' % src_info_dir
+ return 1
+ if not os.path.isfile(src_info_format_file):
+ print 'info format file not found. (%s)' % src_info_format_file
+ return 1
+ if not os.path.isdir(src_triggers_dir):
+ print 'triggers dir not found. (%s)' % src_triggers_dir
+ return 1
+ if not os.path.isdir(src_updates_dir):
+ print 'updates dir not found. (%s)' % src_updates_dir
+ return 1
+
+ package_map = ParseStatusFile(src_status_file)
+ missing_packages = []
+ for package in PACKAGES:
+ if package not in package_map:
+ missing_packages.append(package)
+ if missing_packages:
+ print 'Missing packages: %s' % ','.join(missing_packages)
+ return 1
+
+ dest_status_file = os.path.join(dest_dir, 'status')
+ dest_info_dir = os.path.join(dest_dir, 'info')
+ dest_info_format_file = os.path.join(dest_info_dir, 'format')
+ dest_triggers_dir = os.path.join(dest_dir, 'triggers')
+ dest_updates_dir = os.path.join(dest_dir, 'updates')
+
+ os.makedirs(dest_info_dir)
+ shutil.copy(src_info_format_file, dest_info_format_file)
+ shutil.copytree(src_triggers_dir, dest_triggers_dir,
+ ignore=shutil.ignore_patterns('Lock'))
+ shutil.copytree(src_updates_dir, dest_updates_dir)
+
+ dest_status_file_handle = open(dest_status_file, 'w')
+ for package in PACKAGES:
+ dest_status_file_handle.write('Package: %s\n' % package)
+ dest_status_file_handle.write(package_map[package])
+ dest_status_file_handle.write('\n')
+ dest_status_file_handle.close()
Paweł Hajdan Jr. 2014/12/08 10:12:15 nit: Why not just "with open(...) as ..."?
+
+ for package in PACKAGES:
+ for extension in ('shlibs', 'symbols'):
+ dest_filename = '%s:%s.%s' % (package, options.arch, extension)
+ # Hack for libpango
+ if (package == 'libpango-1.0-0' or package == 'libpangocairo-1.0-0'):
+ src_filename = 'libpango1.0-0:%s.%s' % (options.arch, extension)
+ else:
+ src_filename = dest_filename
+ src_file = os.path.join(src_info_dir, src_filename)
+ dest_file = os.path.join(dest_info_dir, dest_filename)
+ if not os.path.isfile(src_file):
+ continue
+ shutil.copy(src_file, dest_file)
+
+ return 0
+
+
+if __name__ == '__main__':
+ parser = optparse.OptionParser('usage: %prog --arch ARCH SRC DEST')
+ parser.add_option('--arch', help='Sysroot architecture: i386 or amd64')
+ options, args = parser.parse_args()
+ sys.exit(main())
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698