def setup(self): util.mkdirChain(util.joinPaths(self.image_root, 'boot', 'grub')) # path to grub stage1/stage2 files in rPL/rLS util.copytree( util.joinPaths(self.image_root, 'usr', 'share', 'grub', '*', '*'), util.joinPaths(self.image_root, 'boot', 'grub')) # path to grub files in SLES if is_SUSE(self.image_root): util.copytree( util.joinPaths(self.image_root, 'usr', 'lib', 'grub', '*'), util.joinPaths(self.image_root, 'boot', 'grub')) if is_UBUNTU(self.image_root): # path to grub files in x86 Ubuntu util.copytree( util.joinPaths(self.image_root, 'usr', 'lib', 'grub', 'i386-pc', '*'), util.joinPaths(self.image_root, 'boot', 'grub')) # path to grub files in x86_64 Ubuntu util.copytree( util.joinPaths(self.image_root, 'usr', 'lib', 'grub', 'x86_64-pc', '*'), util.joinPaths(self.image_root, 'boot', 'grub')) util.mkdirChain(util.joinPaths(self.image_root, 'etc')) # Create a stub grub.conf self.writeConf() # Create the appropriate links if self._get_grub_conf() != 'menu.lst': os.symlink('grub.conf', util.joinPaths( self.image_root, 'boot', 'grub', 'menu.lst')) os.symlink('../boot/grub/grub.conf', util.joinPaths(self.image_root, 'etc', 'grub.conf')) if is_SUSE(self.image_root): self._suse_grub_stub()
def preTagScripts(self): fakeRoot = self.root # create a swap file if self.swapSize: swapFile = util.joinPaths(fakeRoot, self.swapPath) util.mkdirChain(os.path.dirname(swapFile)) # sparse files cannot work for swap space logCall("dd if=/dev/zero of=%s bs=4096 count=%d" % (swapFile, self.swapSize / 4096)) logCall("/sbin/mkswap %s" % swapFile) os.chmod(swapFile, 0600) # Copy a skeleton config tree. # Exclude things that are not being installed. exceptFiles = [] # GPM (mouse daemon for virtual terminals) if not os.path.isfile(os.path.join(fakeRoot, "usr", "sbin", "gpm")): exceptFiles.append(os.path.join(os.path.sep, "etc", "sysconfig", "mouse")) # X windows start_x = False for svc in ("xdm", "gdm", "kdm"): if not os.path.isfile(os.path.join(fakeRoot, "etc", "init.d", svc)): continue # make sure the binary exists too for path in (("usr", "X11R6", "bin"), ("usr", "bin")): if os.path.isfile(os.path.join(*(fakeRoot,) + path + (svc,))): start_x = True if not start_x: exceptFiles.append(os.path.join(os.path.sep, "etc", "X11.*")) # use the appropriate skeleton files depending on the OS base if is_SUSE(fakeRoot): skelDir = os.path.join(constants.skelDir, "sle") elif is_UBUNTU(fakeRoot): skelDir = os.path.join(constants.skelDir, "ubuntu") else: skelDir = os.path.join(constants.skelDir, "rpl") copytree(skelDir, fakeRoot, exceptFiles) self.writeConaryRc(os.path.join(fakeRoot, "etc", "conaryrc"), self.cc) self.writeSystemModel(os.path.join(fakeRoot, "etc", "conary", "system-model")) # If X is available, use runlevel 5 by default, for graphical login if start_x: inittab = os.path.join(fakeRoot, "etc", "inittab") if os.path.isfile(inittab): cmd = r"/bin/sed -e 's/^\(id\):[0-6]:\(initdefault:\)$/\1:5:\2/' -i %s" % inittab logCall(cmd) else: log.warning("inittab does not appear to be present") # copy timezone data into /etc/localtime if os.path.exists(os.path.join(fakeRoot, "usr", "share", "zoneinfo", "UTC")): copyfile( os.path.join(fakeRoot, "usr", "share", "zoneinfo", "UTC"), os.path.join(fakeRoot, "etc", "localtime") ) # Write the /etc/sysconfig/appliance-name for distro-release initscript. # Only overwrite if the file is non existent or empty. (RBL-3104) appliancePath = os.path.join(fakeRoot, "etc", "sysconfig") if not os.path.exists(appliancePath): util.mkdirChain(appliancePath) appNameFile = os.path.join(appliancePath, "appliance-name") if not os.path.exists(appNameFile) or not os.path.getsize(appNameFile): f = open(appNameFile, "w") name = self.jobData["project"]["name"] if isinstance(name, unicode): name = name.encode("utf8") f.write(name + "\n") f.close() # Disable selinux by default selinux = "etc/selinux/config" if self.fileExists(selinux): contents = self.readFile(selinux) contents = contents.replace( "SELINUX=enforcing\n", "# NOTE: This is overridden by rBuilder. To prevent this, " "change it back using a group post-install script.\n" "SELINUX=disabled\n", ) self.createFile(selinux, contents) if is_SUSE(self.root): # SUSE needs /dev/fd for mkinitrd (RBL-5689) os.symlink("/proc/self/fd", self.filePath("dev/fd")) elif is_SUSE(self.root, version=11): self.createFile("etc/sysconfig/mkinitrd", 'OPTIONS="-A"\n') # Configure the bootloader (but don't install it yet). self.bootloader.setup() self.addScsiModules() self.writeDeviceMaps()
def _get_grub_conf(self): if is_SUSE(self.image_root) or is_UBUNTU(self.image_root): return 'menu.lst' return 'grub.conf'