def part_target(self, targetdir, grub_version, grub_fw_type=None): # create target images and copy the rfs into them hdimages = do_hdimg(self.xml, targetdir, self, grub_version, grub_fw_type) for i in hdimages: self.images.append(i) self.image_packers[i] = default_packer if self.xml.has("target/package/tar"): targz_name = self.xml.text("target/package/tar/name") try: options = '' if self.xml.has("target/package/tar/options"): options = self.xml.text("target/package/tar/options") cmd = "tar cfz %(dest)s/%(fname)s -C %(sdir)s %(options)s ." args = dict( options=options, dest=targetdir, fname=targz_name, sdir=self.fname('') ) do(cmd % args) # only append filename if creating tarball was successful self.images.append(targz_name) except CommandError: # error was logged; continue creating cpio image pass if self.xml.has("target/package/cpio"): oldwd = os.getcwd() cpio_name = self.xml.text("target/package/cpio/name") os.chdir(self.fname('')) try: do("find . -print | cpio -ov -H newc >%s" % os.path.join(targetdir, cpio_name)) # only append filename if creating cpio was successful self.images.append(cpio_name) except CommandError: # error was logged; continue pass os.chdir(oldwd) if self.xml.has("target/package/squashfs"): oldwd = os.getcwd() sfs_name = self.xml.text("target/package/squashfs/name") os.chdir(self.fname('')) try: do("mksquashfs %s %s/%s -noappend -no-progress" % (self.fname(''), targetdir, sfs_name)) # only append filename if creating mksquashfs was successful self.images.append(sfs_name) except CommandError: # error was logged; continue pass os.chdir(oldwd)
def part_target(self, targetdir, grub_version): # create target images and copy the rfs into them self.images = do_hdimg( self.log, self.xml, targetdir, self, grub_version ) if self.xml.has("target/package/tar"): targz_name = self.xml.text ("target/package/tar/name") try: options = '' if self.xml.has("target/package/tar/options"): options = self.xml.text("target/package/tar/options") cmd = "tar cfz %(targetdir)s/%(targz_name)s -C %(sourcedir)s %(options)s ." args = dict( options=options, targetdir=targetdir, targz_name=targz_name, sourcedir=self.fname('') ) self.log.do(cmd % args) # only append filename if creating tarball was successful self.images.append (targz_name) except CommandError as e: # error was logged; continue creating cpio image pass if self.xml.has("target/package/cpio"): oldwd = os.getcwd() cpio_name = self.xml.text("target/package/cpio/name") os.chdir(self.fname('')) try: self.log.do("find . -print | cpio -ov -H newc >%s" % os.path.join(targetdir,cpio_name) ) # only append filename if creating cpio was successful self.images.append (cpio_name) except CommandError as e: # error was logged; continue pass if self.xml.has("target/package/squashfs"): oldwd = os.getcwd() sfs_name = self.xml.text("target/package/squashfs/name") os.chdir(self.fname('')) try: self.log.do("mksquashfs %s %s/%s -noappend -no-progress" % (self.fname(''), targetdir, sfs_name)) # only append filename if creating mksquashfs was successful self.images.append (sfs_name) except CommandError as e: # error was logged; continue pass