import warnings
from pykickstart.errors import *
from pykickstart.ko import *
-from pykickstart.parser import Packages
+from pykickstart.parser import Packages,TpkPackages
from pykickstart.version import versionToString
###
# everything else I can think of.
self.scripts = []
self.packages = Packages()
+ self.tpk_packages = TpkPackages()
self.platform = ""
# These will be set by the dispatcher.
#
from pykickstart.version import *
from pykickstart.commands import *
+from mic.kickstart.custom_commands.micrepo import *
# This map is keyed on kickstart syntax version as provided by
# pykickstart.version. Within each sub-dict is a mapping from command name
"raid": raid.FC5_Raid,
"reboot": reboot.FC6_Reboot,
"repo": repo.FC6_Repo,
+ "tpk_repo": Mic_Tpk_Repo,
"rootpw": rootpw.FC3_RootPw,
"selinux": selinux.FC3_SELinux,
"services": services.FC6_Services,
"PartData": partition.FC4_PartData,
"RaidData": raid.FC5_RaidData,
"RepoData": repo.FC6_RepoData,
+ "TpkRepoData": Mic_Tpk_RepoData,
"UserData": user.FC6_UserData,
"VolGroupData": volgroup.FC3_VolGroupData,
"ZFCPData": zfcp.FC3_ZFCPData,
KickstartParser - The kickstart file parser state machine.
"""
-
from collections import Iterator
import os
import shlex
self.groupList = []
self.handleMissing = constants.KS_MISSING_PROMPT
self.packageList = []
+ self.tpk_packageList = []
self.instLangs = None
def __str__(self):
self.packageList = list(existingPackageSet)
self.excludedList = list(existingExcludedSet)
-
+class TpkPackages(KickstartObject):
+ """A class representing the %tpk_packages section of the kickstart file."""
+ def __init__(self, *args, **kwargs):
+ KickstartObject.__init__(self, *args, **kwargs)
+ self.tpk_packageList = []
+ def __str__(self):
+ tpk_pkgs = ""
+ retval = "\n%tpk_packages"
+ p = self.packageList
+ p.sort()
+ for pkg in p:
+ tpk_pkgs += "%s\n" % pkg
+ return retval + "\n" +tpk_pkgs
+ def add(self, tpkPackageList):
+ tpk_PackageSet = set(self.tpk_packageList)
+ for tpk_pkg in tpkPackageList:
+ stripped = tpk_pkg.strip()
+ tpk_PackageSet.add(stripped)
+ self.tpk_packageList = list(tpk_PackageSet)
###
### PARSER
###
self.registerSection(RunScriptSection(self.handler, dataObj=Script))
self.registerSection(PostUmountScriptSection(self.handler, dataObj=Script))
self.registerSection(PackageSection(self.handler))
+ self.registerSection(TpkPackageSection(self.handler))
+
(h, s, t) = line.partition('#')
line = h.rstrip()
-
self.handler.packages.add([line])
def handleHeader(self, lineno, args):
if opts.instLangs:
self.handler.packages.instLangs = opts.instLangs
+
+class TpkPackageSection(Section):
+ sectionOpen = "%tpk_packages"
+
+ def handleLine(self, line):
+ if not self.handler:
+ return
+
+ (h, s, t) = line.partition('#')
+ line = h.rstrip()
+ self.handler.tpk_packages.add([line])
+
+ def handleHeader(self, lineno, args):
+ """Process the arguments to the %tpk_packages header and set attributes
+ on the Version's TpkPackages instance appropriate. This method may be
+ overridden in a subclass if necessary.
+ """
+ Section.handleHeader(self, lineno, args)
"check_pkgs": [],
"repourl": {},
"localrepos": [], # save localrepos
+ "localtpkrepos":[],
"runtime": "bootstrap",
"extrarepos": {},
"ignore_ksrepo": False,
self.create['repomd'] = misc.get_metadata_from_repos(
ksrepos,
self.create['cachedir'])
+ kstpkrepos = kickstart.get_tpkrepos(ks)
+ if kstpkrepos:
+ for tpk_repo in kstpkrepos:
+ if hasattr(tpk_repo,'baseurl') and tpk_repo.baseurl.startswith("file:"):
+ tpk_repourl = tpk_repo.baseurl.replace('file:','')
+ tpk_repourl = "/%s" % tpk_repourl.lstrip('/')
+ self.create['localtpkrepos'].append(tpk_repourl)
+
msger.raw(" DONE")
target_archlist, archlist = misc.get_arch(self.create['repomd'])
-
#!/usr/bin/python -tt
#
# Copyright (c) 2007 Red Hat Inc.
import glob
import json
from datetime import datetime
-
import rpm
import time
from mic import kickstart
from mic.chroot import kill_proc_inchroot
from mic.archive import get_archive_suffixes
from mic.conf import configmgr
+from mic.utils.grabber import myurlgrab
#post script max run time
MAX_RUN_TIME = 120
if 'debuginfo' in self.install_pkgs:
pkg_manager.install_debuginfo = True
+
for repo in kickstart.get_repos(self.ks, repo_urls, self.ignore_ksrepo):
(name, baseurl, mirrorlist, inc, exc,
proxy, proxy_username, proxy_password, debuginfo,
except:
pass
+ def tpkinstall(self):
+ if self.ks:
+ tpk_pkgs = kickstart.get_tpkpackages(self.ks)
+ tpk_repoList = kickstart.get_tpkrepos(self.ks)
+ if tpk_repoList and tpk_pkgs:
+ tpk_dir = "/usr/apps/.preload-tpk"
+ fs.makedirs(self._instroot + "/usr/apps")
+ fs.makedirs(self._instroot + tpk_dir)
+ for pkg in tpk_pkgs:
+ flag = 0
+ for tpk_repo in tpk_repoList:
+ if hasattr(tpk_repo,'baseurl') and tpk_repo.baseurl.startswith("file:"):
+ tpk_repourl = tpk_repo.baseurl.replace('file:','')
+ tpk_repourl = "/%s" % tpk_repourl.lstrip('/')
+ tpk_pkgpath = tpk_repourl + "/"+ pkg
+ if os.path.isfile(tpk_pkgpath):
+ shutil.copy(tpk_pkgpath,self._instroot + tpk_dir)
+ flag = 1
+ break
+ elif hasattr(tpk_repo,'baseurl'):
+ url = tpk_repo.baseurl.join(pkg)
+ filename = self._instroot+tpk_dir+"/"+pkg
+ if tpk_repo.baseurl.startswith("http:"):
+ import urllib
+ status = urllib.urlopen(url).code
+ if status == 200:
+ filename = myurlgrab(url.full, filename, None)
+ flag = 1
+ break
+ elif status == 404 or status == None:
+ continue
+ #url is ok, then download, url wrong, check other url.
+ elif tpk_repo.baseurl.startswith("https:") :
+ try:
+ flag = 1
+ filename = myurlgrab(url.full, filename, None)
+ except CreatorError:
+ continue
+ if flag == 0:
+ raise CreatorError("Tpk package missing.")
+
def postinstall(self):
pass
using_version = ksversion.DEVEL
commandMap[using_version]["desktop"] = desktop.Mic_Desktop
commandMap[using_version]["repo"] = micrepo.Mic_Repo
+ commandMap[using_version]["tpk_repo"] = micrepo.Mic_Tpk_Repo
commandMap[using_version]["bootloader"] = micboot.Mic_Bootloader
commandMap[using_version]["part"] = partition.Mic_Partition
commandMap[using_version]["partition"] = partition.Mic_Partition
commandMap[using_version]["installerfw_plugins"] = installerfw.Mic_installerfw
dataMap[using_version]["RepoData"] = micrepo.Mic_RepoData
+ dataMap[using_version]["Tpk_RepoData"] = micrepo.Mic_Tpk_RepoData
dataMap[using_version]["PartData"] = partition.Mic_PartData
superclass = ksversion.returnClassForVersion(version=using_version)
repo.get('user', None),
repo.get('passwd', None))
repos[name] = Repo(**repo)
-
return repos.values()
+TpkRepoType = collections.namedtuple("TpkRepo",
+ "name, baseurl,proxy,proxy_username,proxy_password,ssl_verify")
+
+def TpkRepo(name, baseurl, proxy=None,proxy_username=None, proxy_password=None,ssl_verify=None):
+ return TpkRepoType(name, baseurl,proxy,proxy_username,proxy_password,ssl_verify)
+
+
+def get_tpkrepos(ks):
+ tpkrepos = {}
+ for tpkrepodata in ks.handler.tpk_repo.tpkRepoList:
+ tpkrepo = {}
+ for field in TpkRepoType._fields:
+ if hasattr(tpkrepodata, field) and getattr(tpkrepodata, field):
+ tpkrepo[field] = getattr(tpkrepodata, field)
+
+ if hasattr(tpkrepodata, 'baseurl') and getattr(tpkrepodata, 'baseurl'):
+ tpkrepo['baseurl'] = SafeURL(getattr(tpkrepodata, 'baseurl'),getattr(tpkrepodata, 'user',None),getattr(tpkrepodata, 'passwd',None))
+
+ if 'name' in tpkrepo:
+ tpkrepos[tpkrepo['name']] = TpkRepo(**tpkrepo)
+
+ return tpkrepos.values()
+
+
def convert_method_to_repo(ks):
try:
ks.handler.repo.methodToRepo()
def get_packages(ks, required=()):
return ks.handler.packages.packageList + list(required)
+def get_tpkpackages(ks):
+ return ks.handler.tpk_packages.tpk_packageList
+
def get_groups(ks, required=()):
return ks.handler.packages.groupList + list(required)
from desktop import Mic_Desktop
-from micrepo import Mic_Repo, Mic_RepoData
+from micrepo import Mic_Repo, Mic_RepoData,Mic_Tpk_Repo, Mic_Tpk_RepoData
from partition import Mic_Partition
from installerfw import Mic_installerfw
"Mic_Desktop",
"Mic_Repo",
"Mic_RepoData",
+ "Mic_Tpk_Repo",
+ "Mic_Tpk_RepoData",
"Mic_Partition",
"Mic_installerfw",
)
return retval
+class Mic_Tpk_RepoData(Mic_RepoData):
+ "Mic customized tpk repo data"
+ def __init__(self, *args, **kw):
+ Mic_RepoData.__init__(self, *args, **kw)
+ def __str__(self):
+ retval = Mic_RepoData._getArgsAsStr(self)
+ retval = "tpk_repo " + retval
+ return retval
class Mic_Repo(F14_Repo):
"Mic customized repo command"
op.add_option("--priority", type="int")
op.add_option("--ssl_verify", default=None)
return op
+
+
+class Mic_Tpk_Repo(Mic_Repo):
+ def __init__(self, writePriority=0, *args, **kwargs):
+ Mic_Repo.__init__(self, writePriority, *args, **kwargs)
+ self.op = self._getParser()
+
+ self.tpkRepoList = kwargs.get("tpkRepoList", [])
+
+ def _getParser(self):
+ op = Mic_Repo._getParser(self)
+ return op
+
+ def dataList(self):
+ return self.tpkRepoList
+
for lrepo in cropts['localrepos']:
binddirs.append(lrepo)
+ for ltpkrepo in cropts['localtpkrepos']:
+ binddirs.append(ltpkrepo)
bindlist = map(expath, filter(None, binddirs))
bindlist += map(os.path.dirname, map(expath, filter(None, bindfiles)))
creator.check_depend_tools()
creator.mount(None, creatoropts["cachedir"])
creator.install()
+ creator.tpkinstall()
#Download the source packages ###private options
if args.include_src:
installed_pkgs = creator.get_installed_packages()
creator.check_depend_tools()
creator.mount(None, creatoropts["cachedir"])
creator.install()
+ creator.tpkinstall()
creator.configure(creatoropts["repomd"])
creator.copy_kernel()
creator.copy_attachment()
creator.check_depend_tools()
creator.mount(None, creatoropts["cachedir"])
creator.install()
+ creator.tpkinstall()
creator.configure(creatoropts["repomd"])
creator.copy_kernel()
creator.copy_attachment()
creator.check_depend_tools()
creator.mount(None, creatoropts["cachedir"])
creator.install()
+ creator.tpkinstall()
creator.configure(creatoropts["repomd"])
creator.copy_kernel()
creator.copy_attachment()