self.pack_to = None
self.repourl = {}
self.multiple_partitions = False
+ self._imgdir = None
# If the kernel is save to the destdir when copy_kernel cmd is called.
self._need_copy_kernel = False
def postinstall(self):
self.copy_attachment()
+ def _get_sign_scripts_env(self):
+ """Return an environment dict for %post-umount scripts.
+
+ This is the hook where subclasses may specify some environment
+ variables for %post-umount scripts by return a dict containing the
+ desired environment.
+ """
+
+ env = {}
+
+ # Directory path of images
+ if self._imgdir:
+ env['IMG_DIR_PATH'] = str(self._imgdir)
+
+ imgfiles = []
+ imgpaths = []
+ for item in self._instloops:
+ imgfiles.append(item['name'])
+ if self._imgdir:
+ imgpaths.append(os.path.join(self._imgdir, item['name']))
+
+ # Images file name
+ env['IMG_FILES'] = ' '.join(imgfiles)
+
+ # Absolute path of images
+ env['IMG_PATHS'] = ' '.join(imgpaths)
+
+ return env
+
def run_sign_scripts(self):
if kickstart.get_sign_scripts(self.ks)==[]:
return
os.write(fd, 'exit 0\n')
os.close(fd)
os.chmod(path, 0700)
+
for item in os.listdir(self._imgdir):
sub = os.path.splitext(item)[1]
if sub == ".img":
os.path.join(self._instroot + "/tmp", item))
oldoutdir = os.getcwd()
os.chdir(self._instroot + "/tmp")
+
+ env = self._get_sign_scripts_env()
+ #*.img files are moved to self._instroot + "/tmp" directory in running runscripts
+ env['IMG_PATHS'] = env['IMG_PATHS'].replace(self._imgdir,self._instroot + "/tmp")
try:
try:
p = subprocess.Popen([s.interp, path],
+ env = env,
stdout = subprocess.PIPE,
stderr = subprocess.STDOUT)
while p.poll() == None:
for item in os.listdir(self._instroot + "/tmp"):
shutil.move(os.path.join(self._instroot + "/tmp", item),
os.path.join(self._imgdir, item))
+
def __run_post_scripts(self):
msger.info("Running post scripts ...")
if os.path.exists(self._instroot + "/tmp"):