/[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 1339 Revision 1474
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.50 2006/03/05 04:16:04 agaffney Exp $ 8$Id: GLIPortage.py,v 1.54 2006/07/10 05:56:31 agaffney Exp $
9""" 9"""
10 10
11import re 11import re
12import os 12import os
13import sys 13import sys
73 def copy_pkg_to_chroot(self, package, use_root=False, ignore_missing=False): 73 def copy_pkg_to_chroot(self, package, use_root=False, ignore_missing=False):
74 symlinks = { '/bin': '/mnt/livecd/bin/', '/boot': '/mnt/livecd/boot/', '/lib': '/mnt/livecd/lib/', 74 symlinks = { '/bin': '/mnt/livecd/bin/', '/boot': '/mnt/livecd/boot/', '/lib': '/mnt/livecd/lib/',
75 '/opt': '/mnt/livecd/opt/', '/sbin': '/mnt/livecd/sbin/', '/usr': '/mnt/livecd/usr/', 75 '/opt': '/mnt/livecd/opt/', '/sbin': '/mnt/livecd/sbin/', '/usr': '/mnt/livecd/usr/',
76 '/etc/gconf': '/usr/livecd/gconf/' } 76 '/etc/gconf': '/usr/livecd/gconf/' }
77 77
78 tmpdir = "/var/tmp/portage" 78 tmpdir = "/var/tmp"
79 image_dir = tmpdir + "/" + package.split("/")[1] + "/image" 79 image_dir = tmpdir + "/portage/" + package.split("/")[1] + "/image"
80 root_cmd = "" 80 root_cmd = ""
81 tmp_chroot_dir = self._chroot_dir 81 tmp_chroot_dir = self._chroot_dir
82 portage_tmpdir = "/var/tmp/portage" 82 portage_tmpdir = "/var/tmp"
83 vdb_dir = "/var/db/pkg/" 83 vdb_dir = "/var/db/pkg/"
84 if use_root: 84 if use_root:
85 root_cmd = "ROOT=" + self._chroot_dir 85 root_cmd = "ROOT=" + self._chroot_dir
86 tmp_chroot_dir = "" 86 tmp_chroot_dir = ""
87 portage_tmpdir = self._chroot_dir + "/var/tmp/portage" 87 portage_tmpdir = self._chroot_dir + "/var/tmp"
88 vdb_dir = self._chroot_dir + "/var/db/pkg/" 88 vdb_dir = self._chroot_dir + "/var/db/pkg/"
89 89
90 # Create /tmp, /var/tmp, and /var/lib/portage with proper permissions 90 # Create /tmp, /var/tmp, and /var/lib/portage with proper permissions
91 oldumask = os.umask(0) 91 oldumask = os.umask(0)
92 if not os.path.exists(self._chroot_dir + "/tmp"): 92 if not os.path.exists(self._chroot_dir + "/tmp"):
139 # Create list of files for tar to work with from CONTENTS file in vdb entry 139 # Create list of files for tar to work with from CONTENTS file in vdb entry
140 entries = self.parse_vdb_contents("/var/db/pkg/" + package + "/CONTENTS") 140 entries = self.parse_vdb_contents("/var/db/pkg/" + package + "/CONTENTS")
141 if not entries: 141 if not entries:
142 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): no files for " + package + "...skipping tar and symlink fixup") 142 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): no files for " + package + "...skipping tar and symlink fixup")
143 else: 143 else:
144 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot: files for " + package + ": " + str(entries)) 144# if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot: files for " + package + ": " + str(entries))
145 try: 145 try:
146 tarfiles = open("/tmp/tarfilelist", "w") 146 tarfiles = open("/tmp/tarfilelist", "w")
147 for entry in entries: 147 for entry in entries:
148 parts = entry.split(" ") 148 parts = entry.split(" ")
149# # Hack for symlink crappiness 149# # Hack for symlink crappiness
159 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running 'tar -cp --files-from=/tmp/tarfilelist --no-recursion 2>/dev/null | tar -C " + self._chroot_dir + image_dir + " -xp'") 159 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running 'tar -cp --files-from=/tmp/tarfilelist --no-recursion 2>/dev/null | tar -C " + self._chroot_dir + image_dir + " -xp'")
160 if not GLIUtility.exitsuccess(GLIUtility.spawn("tar -cp --files-from=/tmp/tarfilelist --no-recursion 2>/dev/null | tar -C " + self._chroot_dir + image_dir + " -xp", logfile=self._compile_logfile, append_log=True)): 160 if not GLIUtility.exitsuccess(GLIUtility.spawn("tar -cp --files-from=/tmp/tarfilelist --no-recursion 2>/dev/null | tar -C " + self._chroot_dir + image_dir + " -xp", logfile=self._compile_logfile, append_log=True)):
161 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute tar for " + package) 161 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute tar for " + package)
162 162
163 # Fix mode, uid, and gid of directories 163 # Fix mode, uid, and gid of directories
164 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running find " + self._chroot_dir + image_dir + " -type d 2>/dev/null | sed -e 's:^" + self._chroot_dir + image_dir + "::' | grep -v '^$'") 164 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running find " + self._chroot_dir + image_dir + " -mindepth 1 -type d 2>/dev/null | sed -e 's:^" + self._chroot_dir + image_dir + "::' | grep -v '^$'")
165 dirlist = GLIUtility.spawn("find " + self._chroot_dir + image_dir + " -type d 2>/dev/null | sed -e 's:^" + self._chroot_dir + image_dir + "::' | grep -v '^$'", return_output=True)[1].strip().split("\n") 165 dirlist = GLIUtility.spawn("find " + self._chroot_dir + image_dir + " -mindepth 1 -type d 2>/dev/null | sed -e 's:^" + self._chroot_dir + image_dir + "::' | grep -v '^$'", return_output=True)[1].strip().split("\n")
166 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): found the following directories: " + str(dirlist)) 166 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): found the following directories: " + str(dirlist))
167 if not dirlist or dirlist[0] == "": 167 if not dirlist or dirlist[0] == "":
168 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "directory list entry for " + package + "...this shouldn't happen!") 168 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "directory list entry for " + package + "...this shouldn't happen!")
169 for dir in dirlist: 169 for dir in dirlist:
170 dirstat = os.stat(dir) 170 dirstat = os.stat(dir)
181# if not GLIUtility.exitsuccess(GLIUtility.spawn("mv " + self._chroot_dir + image_dir + symlinks[symlink] + " " + self._chroot_dir + image_dir + symlink)): 181# if not GLIUtility.exitsuccess(GLIUtility.spawn("mv " + self._chroot_dir + image_dir + symlinks[symlink] + " " + self._chroot_dir + image_dir + symlink)):
182# raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not fix " + symlink + " symlink ickiness for " + package) 182# raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not fix " + symlink + " symlink ickiness for " + package)
183 183
184 # Run pkg_setup 184 # Run pkg_setup
185 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running pkg_setup for " + package) 185 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running pkg_setup for " + package)
186 if not GLIUtility.exitsuccess(GLIUtility.spawn("env " + root_cmd + " PORTAGE_TMPDIR=" + portage_tmpdir + " ebuild " + vdb_dir + package + "/*.ebuild setup", chroot=tmp_chroot_dir, logfile=self._compile_logfile, append_log=True)): 186 if not GLIUtility.exitsuccess(GLIUtility.spawn("env " + root_cmd + " PORTAGE_TMPDIR=" + portage_tmpdir + " FEATURES=noauto ebuild " + vdb_dir + package + "/*.ebuild setup", chroot=tmp_chroot_dir, logfile=self._compile_logfile, append_log=True)):
187 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute pkg_setup for " + package) 187 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute pkg_setup for " + package)
188 188
189 # Run pkg_preinst 189 # Run pkg_preinst
190 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running preinst for " + package) 190 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running preinst for " + package)
191 if not GLIUtility.exitsuccess(GLIUtility.spawn("env " + root_cmd + " PORTAGE_TMPDIR=" + portage_tmpdir + " ebuild " + vdb_dir + package + "/*.ebuild preinst", chroot=tmp_chroot_dir, logfile=self._compile_logfile, append_log=True)): 191 if not GLIUtility.exitsuccess(GLIUtility.spawn("env " + root_cmd + " PORTAGE_TMPDIR=" + portage_tmpdir + " FEATURES=noauto ebuild " + vdb_dir + package + "/*.ebuild preinst", chroot=tmp_chroot_dir, logfile=self._compile_logfile, append_log=True)):
192 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute preinst for " + package) 192 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute preinst for " + package)
193 193
194 # Copy files from image_dir to chroot 194 # Copy files from image_dir to chroot
195 if not entries: 195 if not entries:
196 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): no files for " + package + "...skipping copy from image dir to /") 196 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): no files for " + package + "...skipping copy from image dir to /")
200 if not GLIUtility.exitsuccess(GLIUtility.spawn("tar -C " + self._chroot_dir + image_dir + "/ -cp . | tar -C " + self._chroot_dir + "/ -xp", logfile=self._compile_logfile, append_log=True)): 200 if not GLIUtility.exitsuccess(GLIUtility.spawn("tar -C " + self._chroot_dir + image_dir + "/ -cp . | tar -C " + self._chroot_dir + "/ -xp", logfile=self._compile_logfile, append_log=True)):
201 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not copy files from " + image_dir + " to / for " + package) 201 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not copy files from " + image_dir + " to / for " + package)
202 202
203 # Run pkg_postinst 203 # Run pkg_postinst
204 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running postinst for " + package) 204 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running postinst for " + package)
205 if not GLIUtility.exitsuccess(GLIUtility.spawn("env " + root_cmd + " PORTAGE_TMPDIR=" + portage_tmpdir + " ebuild " + vdb_dir + package + "/*.ebuild postinst", chroot=tmp_chroot_dir, logfile=self._compile_logfile, append_log=True)): 205 if not GLIUtility.exitsuccess(GLIUtility.spawn("env " + root_cmd + " PORTAGE_TMPDIR=" + portage_tmpdir + " FEATURES=noauto ebuild " + vdb_dir + package + "/*.ebuild postinst", chroot=tmp_chroot_dir, logfile=self._compile_logfile, append_log=True)):
206 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute postinst for " + package) 206 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute postinst for " + package)
207 207
208 # Remove image_dir 208 # Remove image_dir
209 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): removing " + image_dir + " for " + package) 209 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): removing " + image_dir + " for " + package)
210 if not GLIUtility.exitsuccess(GLIUtility.spawn("rm -rf " + self._chroot_dir + image_dir, logfile=self._compile_logfile, append_log=True)): 210 if not GLIUtility.exitsuccess(GLIUtility.spawn("rm -rf " + self._chroot_dir + image_dir, logfile=self._compile_logfile, append_log=True)):

Legend:
Removed from v.1339  
changed lines
  Added in v.1474

  ViewVC Help
Powered by ViewVC 1.1.20