/[gli]/branches/overhaul/src/GLIPortage.py
Gentoo

Diff of /branches/overhaul/src/GLIPortage.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1217 Revision 1221
3# This source code is distributed under the terms of version 2 of the GNU 3# This source code is distributed under the terms of version 2 of the GNU
4# General Public License as published by the Free Software Foundation, a copy 4# General Public License as published by the Free Software Foundation, a copy
5# of which can be found in the main directory of this project. 5# of which can be found in the main directory of this project.
6Gentoo Linux Installer 6Gentoo Linux Installer
7 7
8$Id: GLIPortage.py,v 1.29 2006/01/03 04:24:49 agaffney Exp $ 8$Id: GLIPortage.py,v 1.30 2006/01/06 16:39:49 agaffney Exp $
9""" 9"""
10 10
11import re 11import re
12import os 12import os
13import GLIUtility 13import GLIUtility
49 if self._debug: self._logger.log("get_deps(): adding " + tmppkg + " to pkglist") 49 if self._debug: self._logger.log("get_deps(): adding " + tmppkg + " to pkglist")
50 pkglist.append(tmppkg) 50 pkglist.append(tmppkg)
51 if self._debug: self._logger.log("get_deps(): pkglist is " + str(pkglist)) 51 if self._debug: self._logger.log("get_deps(): pkglist is " + str(pkglist))
52 return pkglist 52 return pkglist
53 53
54 def parse_vdb_contents(self, file):
55 entries = []
56 try:
57 vdbfile = open(file, "r")
58 except:
59 return entries
60 for line in vdbfile.readlines():
61 parts = line.strip().split(" ")
62 if parts[0] == "obj":
63 entries.append(parts[1])
64 elif parts[0] == "dir":
65 entries.append(parts[1] + "/")
66 elif parts[0] == "sym":
67 entries.append(" ".join(parts[1:4]))
68 entries.sort()
69 return entries
70
54 def copy_pkg_to_chroot(self, package, use_root=False): 71 def copy_pkg_to_chroot(self, package, use_root=False):
55 symlinks = { '/bin/': '/mnt/livecd/bin/', '/boot/': '/mnt/livecd/boot/', '/lib/': '/mnt/livecd/lib/', 72 symlinks = { '/bin': '/mnt/livecd/bin/', '/boot': '/mnt/livecd/boot/', '/lib': '/mnt/livecd/lib/',
56 '/opt/': '/mnt/livecd/opt/', '/sbin/': '/mnt/livecd/sbin/', '/usr/': '/mnt/livecd/usr/', 73 '/opt': '/mnt/livecd/opt/', '/sbin': '/mnt/livecd/sbin/', '/usr': '/mnt/livecd/usr/',
57 '/etc/gconf/': '/usr/livecd/gconf/' } 74 '/etc/gconf': '/usr/livecd/gconf/' }
58 75
59 tmpdir = "/var/tmp/portage" 76 tmpdir = "/var/tmp/portage"
60 image_dir = tmpdir + "/" + package.split("/")[1] + "/image" 77 image_dir = tmpdir + "/" + package.split("/")[1] + "/image"
61 root_cmd = "" 78 root_cmd = ""
62 tmp_chroot_dir = self._chroot_dir 79 tmp_chroot_dir = self._chroot_dir
75 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running 'mkdir -p " + self._chroot_dir + image_dir + "'") 92 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running 'mkdir -p " + self._chroot_dir + image_dir + "'")
76 if not GLIUtility.exitsuccess(GLIUtility.spawn("mkdir -p " + self._chroot_dir + image_dir)): 93 if not GLIUtility.exitsuccess(GLIUtility.spawn("mkdir -p " + self._chroot_dir + image_dir)):
77 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not create image dir for " + package) 94 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not create image dir for " + package)
78 95
79 # Create list of files for tar to work with from CONTENTS file in vdb entry 96 # Create list of files for tar to work with from CONTENTS file in vdb entry
80 entries = GLIUtility.parse_vdb_contents("/var/db/pkg/" + package + "/CONTENTS") 97 entries = self.parse_vdb_contents("/var/db/pkg/" + package + "/CONTENTS")
81 if not entries: 98 if not entries:
82 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): no files for " + package + "...skipping tar and symlink fixup") 99 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): no files for " + package + "...skipping tar and symlink fixup")
83 else: 100 else:
84 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot: files for " + package + ": " + str(entries)) 101 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot: files for " + package + ": " + str(entries))
85 try: 102 try:
86 tarfiles = open("/tmp/tarfilelist", "w") 103 tarfiles = open("/tmp/tarfilelist", "w")
87 for entry in entries: 104 for entry in entries:
88 parts = entry.split(" ") 105 parts = entry.split(" ")
89 # Hack for symlink crappiness 106 # Hack for symlink crappiness
90 for symlink in symlinks: 107# for symlink in symlinks:
91 if parts[0].startswith(symlink): 108# if parts[0].startswith(symlink):
92 parts[0] = symlinks[symlink] + parts[0][len(symlink):] 109# parts[0] = symlinks[symlink] + parts[0][len(symlink):]
93 tarfiles.write(parts[0] + "\n") 110 tarfiles.write(parts[0] + "\n")
94 tarfiles.close() 111 tarfiles.close()
95 except: 112 except:
96 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not create filelist for " + package) 113 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not create filelist for " + package)
97 114
98 # Use tar to transfer files into IMAGE directory 115 # Use tar to transfer files into IMAGE directory
99 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running 'tar -c --files-from=/tmp/tarfilelist --no-recursion 2>/dev/null | tar -C " + self._chroot_dir + image_dir + " -x'") 116 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running 'tar -c --files-from=/tmp/tarfilelist --no-recursion 2>/dev/null | tar -C " + self._chroot_dir + image_dir + " -x'")
100 if not GLIUtility.exitsuccess(GLIUtility.spawn("tar -c --files-from=/tmp/tarfilelist --no-recursion 2>/dev/null | tar -C " + self._chroot_dir + image_dir + " -x")): 117 if not GLIUtility.exitsuccess(GLIUtility.spawn("tar -c --files-from=/tmp/tarfilelist --no-recursion 2>/dev/null | tar -C " + self._chroot_dir + image_dir + " -x")):
101 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute tar for " + package) 118 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute tar for " + package)
102 119
103 # More symlink crappiness hacks 120# # More symlink crappiness hacks
104 for symlink in symlinks: 121# for symlink in symlinks:
105 if GLIUtility.is_file(self._chroot_dir + image_dir + symlinks[symlink]): 122## if GLIUtility.is_file(self._chroot_dir + image_dir + symlinks[symlink]):
123# if os.path.islink(self._chroot_dir + image_dir + symlink):
106 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): fixing " + symlink + " symlink ickiness stuff in " + image_dir + " for " + package) 124# if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): fixing " + symlink + " symlink ickiness stuff in " + image_dir + " for " + package)
107 if os.path.islink(self._chroot_dir + image_dir + symlink): 125# GLIUtility.spawn("rm " + self._chroot_dir + image_dir + symlink)
108 if not GLIUtiltiy.exitsuccess(GLIUtility.spawn("rm " + self._chroot_dir + image_dir + symlink)):
109 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not remove symlink " + symlink + " for " + package)
110 if not GLIUtility.exitsuccess(GLIUtility.spawn("mv " + self._chroot_dir + image_dir + symlinks[symlink] + " " + self._chroot_dir + image_dir + symlink)): 126# if not GLIUtility.exitsuccess(GLIUtility.spawn("mv " + self._chroot_dir + image_dir + symlinks[symlink] + " " + self._chroot_dir + image_dir + symlink)):
111 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not fix " + symlink + " symlink ickiness for " + package) 127# raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not fix " + symlink + " symlink ickiness for " + package)
112 128
113 # Run pkg_setup 129 # Run pkg_setup
114 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running pkg_setup for " + package) 130 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running pkg_setup for " + package)
115 if not GLIUtility.exitsuccess(GLIUtility.spawn("env " + root_cmd + " PORTAGE_TMPDIR=" + portage_tmpdir + " ebuild /var/db/pkg/" + package + "/*.ebuild setup", chroot=tmp_chroot_dir)): 131 if not GLIUtility.exitsuccess(GLIUtility.spawn("env " + root_cmd + " PORTAGE_TMPDIR=" + portage_tmpdir + " ebuild /var/db/pkg/" + package + "/*.ebuild setup", chroot=tmp_chroot_dir)):
116 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute pkg_setup for " + package) 132 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute pkg_setup for " + package)

Legend:
Removed from v.1217  
changed lines
  Added in v.1221

  ViewVC Help
Powered by ViewVC 1.1.20