| … | |
… | |
| 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.52 2006/04/19 16:31:18 agaffney Exp $ |
8 | $Id: GLIPortage.py,v 1.53 2006/06/25 02:28:19 agaffney Exp $ |
| 9 | """ |
9 | """ |
| 10 | |
10 | |
| 11 | import re |
11 | import re |
| 12 | import os |
12 | import os |
| 13 | import sys |
13 | import 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"): |
| … | |
… | |
| 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) |
| 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) |
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) |
| 172 | # 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]) |
| 173 | # os.chmod(self._chroot_dir + image_dir + dir, dirstat[0]) |
173 | os.chmod(self._chroot_dir + image_dir + dir, dirstat[0]) |
| 174 | |
174 | |
| 175 | # # More symlink crappiness hacks |
175 | # # More symlink crappiness hacks |
| 176 | # for symlink in symlinks: |
176 | # for symlink in symlinks: |
| 177 | ## if GLIUtility.is_file(self._chroot_dir + image_dir + symlinks[symlink]): |
177 | ## if GLIUtility.is_file(self._chroot_dir + image_dir + symlinks[symlink]): |
| 178 | # if os.path.islink(self._chroot_dir + image_dir + symlink): |
178 | # if os.path.islink(self._chroot_dir + image_dir + symlink): |