| … | |
… | |
| 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. |
| 6 | Gentoo Linux Installer |
6 | Gentoo Linux Installer |
| 7 | |
7 | |
| 8 | $Id: GLIPortage.py,v 1.49 2006/03/05 03:06:44 agaffney Exp $ |
8 | $Id: GLIPortage.py,v 1.50 2006/03/05 04:16:04 agaffney Exp $ |
| 9 | """ |
9 | """ |
| 10 | |
10 | |
| 11 | import re |
11 | import re |
| 12 | import os |
12 | import os |
| 13 | import sys |
13 | import sys |
| … | |
… | |
| 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/portage" |
| 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 |
|
|
91 | oldumask = os.umask(0) |
|
|
92 | if not os.path.exists(self._chroot_dir + "/tmp"): |
|
|
93 | if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): /tmp doesn't exist in chroot...creating with proper permissions") |
|
|
94 | try: |
|
|
95 | os.mkdir(self._chroot_dir + "/tmp", 01777) |
|
|
96 | except: |
|
|
97 | raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Failed to create /tmp in chroot") |
|
|
98 | if not os.path.exists(self._chroot_dir + "/var/tmp"): |
|
|
99 | if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): /var/tmp doesn't exist in chroot...creating with proper permissions") |
|
|
100 | try: |
|
|
101 | os.mkdir(self._chroot_dir + "/var", 0755) |
|
|
102 | except: |
|
|
103 | pass |
|
|
104 | try: |
|
|
105 | os.mkdir(self._chroot_dir + "/var/tmp", 01777) |
|
|
106 | except: |
|
|
107 | raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Failed to create /var/tmp in chroot") |
|
|
108 | if not os.path.exists(self._chroot_dir + "/var/lib/portage"): |
|
|
109 | if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): /var/lib/portage doesn't exist in chroot...creating with proper permissions") |
|
|
110 | try: |
|
|
111 | os.mkdir(self._chroot_dir + "/var/lib", 0755) |
|
|
112 | except: |
|
|
113 | pass |
|
|
114 | try: |
|
|
115 | os.mkdir(self._chroot_dir + "/var/lib/portage", 02750) |
|
|
116 | except: |
|
|
117 | raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Failed to create /var/lib/portage in chroot") |
|
|
118 | os.umask(oldumask) |
|
|
119 | |
| 90 | # Check to see if package is actually in vdb |
120 | # Check to see if package is actually in vdb |
| 91 | if not GLIUtility.is_file("/var/db/pkg/" + package): |
121 | if not GLIUtility.is_file("/var/db/pkg/" + package): |
| 92 | if ignore_missing: |
122 | if ignore_missing: |
| 93 | if self._debug: |
123 | if self._debug: |
| 94 | self._logger.log("DEBUG: copy_pkg_to_chroot(): package " + package + " does not have a vdb entry but ignore_missing=True...ignoring error") |
124 | self._logger.log("DEBUG: copy_pkg_to_chroot(): package " + package + " does not have a vdb entry but ignore_missing=True...ignoring error") |
| … | |
… | |
| 131 | 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) |
| 132 | |
162 | |
| 133 | # Fix mode, uid, and gid of directories |
163 | # Fix mode, uid, and gid of directories |
| 134 | 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 + " -type d 2>/dev/null | sed -e 's:^" + self._chroot_dir + image_dir + "::' | grep -v '^$'") |
| 135 | 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 + " -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)) |
| 136 | if not dirlist or dirlist[0] == "": |
167 | if not dirlist or dirlist[0] == "": |
| 137 | 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!") |
| 138 | for dir in dirlist: |
169 | for dir in dirlist: |
| 139 | dirstat = os.stat(dir) |
170 | dirstat = os.stat(dir) |
|
|
171 | if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): setting mode " + str(dirstat[0]) + " and uid/gid " + str(dirstat[4]) + "/" + str(dirstat[5]) + " for directory " + self._chroot_dir + image_dir + dir) |
| 140 | os.chown(self._chroot_dir + image_dir + dir, dirstat[4], dirstat[5]) |
172 | os.chown(self._chroot_dir + image_dir + dir, dirstat[4], dirstat[5]) |
| 141 | os.chmod(self._chroot_dir + image_dir + dir, dirstat[0]) |
173 | os.chmod(self._chroot_dir + image_dir + dir, dirstat[0]) |
| 142 | |
174 | |
| 143 | # # More symlink crappiness hacks |
175 | # # More symlink crappiness hacks |
| 144 | # for symlink in symlinks: |
176 | # for symlink in symlinks: |