This implements the kickstart driverdisk command. The changes are mostly re-structuring things a bit to make it cleaner for the kickstart code. In a couple places in the first 3 commits you may notice comments that aren't quite right, and I changed from using /tmp/dd_ks to /tmp/dd_args_ks in another place. Everything matches up by the end.
I have tested this with a current (3.10.0-83) driverdisk iso and both partition and kickstart driverdisk sources work, as well as the previously working commandline inst.dd options.
Brian C. Lane (5): driverdisk: Use getargs instead of the env variable (#1035663) driverdisk: Handle kickstart driverdisk command (#1035663) driverdisk: Process kickstart driverdisk commands (#1035663) driverdisk: Add dd_args_ks handling to driver-updates (#1035663) driverdisk: Use a single systemd service to start DD UI (#1035663)
dracut/Makefile.am | 1 - dracut/README-dd | 26 +++++++++++------- dracut/anaconda-lib.sh | 37 +++++++++++++++++++++++++ dracut/driver-updates | 56 +++++++++++++++++++++++++++----------- dracut/driver-updates-net.sh | 11 +------- dracut/driver-updates-net@.service | 17 ------------ dracut/driver-updates.sh | 15 +++------- dracut/fetch-driver-net.sh | 9 +++--- dracut/module-setup.sh | 3 +- dracut/parse-anaconda-dd.sh | 3 +- dracut/parse-kickstart | 24 +++++++++++----- 11 files changed, 121 insertions(+), 81 deletions(-) delete mode 100644 dracut/driver-updates-net@.service
This makes it easier to change what dd args are being passed. Also rename dd-net.done to dd_net.done for consistency in /tmp/dd_* naming usage.
Related: rhbz#1035663 --- dracut/README-dd | 2 +- dracut/driver-updates.sh | 5 ++++- dracut/fetch-driver-net.sh | 9 ++++----- dracut/parse-anaconda-dd.sh | 3 +-- 4 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/dracut/README-dd b/dracut/README-dd index 0103b56..2c3a1be 100644 --- a/dracut/README-dd +++ b/dracut/README-dd @@ -6,7 +6,7 @@ modules before the rest of the installer is executed.
cmdline hook parse-anaconda-dd.sh - parses the inst.dd/dd arguments for URIs and saves all of them into $dd_args + parses the inst.dd/dd arguments for URIs and saves all of them into /tmp/dd_args and calls set_neednet if network is needed to retrieve a driver rpm The files will be downloaded when the network device online hook is executed.
diff --git a/dracut/driver-updates.sh b/dracut/driver-updates.sh index 3765575..99ca245 100755 --- a/dracut/driver-updates.sh +++ b/dracut/driver-updates.sh @@ -10,7 +10,10 @@ udevadm settle blkid -t LABEL=OEMDRV > /dev/null blkid_rc=$?
-# dd_args will have been set by parse-anaconda-dd.sh cmdline hook +command -v getarg >/dev/null || . /lib/dracut-lib.sh +dd_args="$(getargs dd= inst.dd=)" + +# /tmp/dd_args will have been set by parse-anaconda-dd.sh cmdline hook if [ -n "$dd_args" -o $blkid_rc -eq 0 ]; then command -v getarg >/dev/null || . /lib/dracut-lib.sh . /lib/anaconda-lib.sh diff --git a/dracut/fetch-driver-net.sh b/dracut/fetch-driver-net.sh index 9e46a95..5adc39b 100755 --- a/dracut/fetch-driver-net.sh +++ b/dracut/fetch-driver-net.sh @@ -6,14 +6,13 @@ netif="$1"
# We already processed the dd_args - exit -[ -e /tmp/dd-net.done ] && return 0 +[ -e /tmp/dd_net.done ] && return 0
-# no dd requested - exit +command -v getarg >/dev/null || . /lib/dracut-lib.sh +dd_args="$(getargs dd= inst.dd=)" [ -n "$dd_args" ] || return 0
-command -v getarg >/dev/null || . /lib/dracut-lib.sh . /lib/url-lib.sh - dd_repo=/tmp/DD-net/ for dd in $dd_args; do case "${dd%%:*}" in @@ -28,4 +27,4 @@ for dd in $dd_args; do ;; esac done -echo > /tmp/dd-net.done +echo > /tmp/dd_net.done diff --git a/dracut/parse-anaconda-dd.sh b/dracut/parse-anaconda-dd.sh index df02bc1..ebabd07 100755 --- a/dracut/parse-anaconda-dd.sh +++ b/dracut/parse-anaconda-dd.sh @@ -2,7 +2,7 @@ # parse-anaconda-dd.sh: handle driver update disk settings
# no need to do this twice -[ -f /tmp/dd-net.done ] && return +[ -f /tmp/dd_net.done ] && return
command -v getarg >/dev/null || . /lib/dracut-lib.sh
@@ -16,4 +16,3 @@ for dd in $dd_args; do ;; esac done -export dd_args
Write driverdisk partitions to /tmp/dd_args_ks and add network sources to the cmdline as inst.dd= entries for later handling by fetch-driver-net.sh
Related: rhbz#1035663 --- dracut/parse-kickstart | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/dracut/parse-kickstart b/dracut/parse-kickstart index 29e6e6f..a877595 100755 --- a/dracut/parse-kickstart +++ b/dracut/parse-kickstart @@ -91,13 +91,23 @@ class MediaCheck(commands.mediacheck.FC4_MediaCheck):
class DriverDisk(commands.driverdisk.F14_DriverDisk): def dracut_args(self, args, lineno, obj): - dd = self.driverdiskList[-1] - if dd.biospart: - location = "bd:%s" % dd.biospart - else: - location = dd.partition or dd.source - if location: - return "inst.driverdisk=%s" % location + dd_net = [] + dd_disk = [] + for dd in self.driverdiskList: + if dd.partition: + dd_disk.append(dd.partition) + elif dd.source: + dd_net.append("inst.dd=%s" % dd.source) + + # disk sources cannot be added to cmdline because the initial + # driver-update run has already finished. + if dd_disk: + with open("/tmp/dd_args_ks", "w") as f: + f.write(" ".join(dd_disk)) + + # network sources can be added to the existing cmdline, they + # are processed later. + return "\n".join(dd_net)
class Network(commands.network.F20_Network): def dracut_args(self, args, lineno, net):
This launches the driver-updates UI if disk partitions have been written to /tmp/dd_args_ks or it makes sure that the network is activated for network kickstart driverdisk sources.
The UI needs to be rerun here because this will be executed after the first run of the driver-updates UI.
Related: rhbz#1035663 --- dracut/anaconda-lib.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
diff --git a/dracut/anaconda-lib.sh b/dracut/anaconda-lib.sh index d282297..348b5b4 100755 --- a/dracut/anaconda-lib.sh +++ b/dracut/anaconda-lib.sh @@ -206,6 +206,36 @@ run_kickstart() { esac [ "$root" = "anaconda-auto-cd" ] && do_disk=1
+ # kickstart Driver Disk Handling + # parse-kickstart may have added network inst.dd entries to the cmdline + # Or it may have written devices to /tmp/dd_ks + + # Does network need to be rerun? + dd_args="$(getargs dd= inst.dd=)" + for dd in $dd_args; do + case "${dd%%:*}" in + http|https|ftp|nfs|nfs4) + do_net=1 + rm /tmp/dd_net.done + break + ;; + esac + done + + # Run the driver update UI for disks + if [ -e "/tmp/dd_ks" ]; then + # TODO: Seems like this should be a function, a mostly same version is used in 3 places + tty=$(find_tty) + + # save module state + cat /proc/modules > /tmp/dd_modules + + info "Starting Kickstart Driver Update Disk Service on $tty" + systemctl start driver-updates@$tty.service + status=$(systemctl -p ExecMainStatus show driver-updates@$tty.service) + info "DD status=$status" + fi + # replay udev events to trigger actions if [ "$do_disk" ]; then . $hookdir/pre-trigger/*repo-genrules.sh
This reworks how driver-updates works to look for files in /tmp/ instead of expecting a cmdline arg (although that does still work). This allows us to use a single systemd service and to turn the UI startup into a common function in anaconda-lib.sh
If /tmp/DD-net/ is present it processes the drivers or iso's in the directory that have been downloaded from a network source. Passing a path to driver-updates also triggers this behavior.
If /tmp/dd_args_ks is present the existing OEMDRV devices are ignored (they will have been processed eariler) and the partitions in /tmp/dd_args_ks will be processed, as well as any OEMDRV devices that may appear as a result.
If neither /tmp/dd_args_ks nor /tmp/DD-net/ are present it will look for OEMDRV labeled devices and process partitions from /tmp/dd_args if present.
Resolves: rhbz#1035663 --- dracut/driver-updates | 56 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 16 deletions(-)
diff --git a/dracut/driver-updates b/dracut/driver-updates index 3684b73..2b9e634 100755 --- a/dracut/driver-updates +++ b/dracut/driver-updates @@ -23,6 +23,7 @@ Driver Update Disk UI /tmp/dd_modules is a copy of /proc/modules at startup time /tmp/dd_args is a parsed list of the inst.dd= cmdline args, and may include 'dd' or 'inst.dd' if it was specified without arguments +/tmp/dd_args_ks is the same format, but skips processing existing OEMDRV devices.
Pass a path and it will install the driver rpms from the path before checking for new OEMDRV devices. @@ -110,19 +111,24 @@ def is_dd(dd_path):
def get_dd_args(): - """ Get the dd arguments from /tmp/dd_args + """ Get the dd arguments from /tmp/dd_args or /tmp/dd_args_ks
:returns: List of arguments :rtype: list of strings """ - try: - dd_args = open("/tmp/dd_args", "r").readline().split() - except IOError: - return [] - - # skip dd args that need networking net_protocols = ["http", "https", "ftp", "nfs", "nfs4"] - return filter(lambda x: x.split(":")[0].lower() not in net_protocols, dd_args) + args = [] + for dd_args_file in ["/tmp/dd_args", "/tmp/dd_args_ks"]: + if not os.path.exists(dd_args_file): + continue + try: + dd_args = open(dd_args_file, "r").readline().split() + except IOError: + return [] + + # skip dd args that need networking + args.extend(filter(lambda x: x.split(":")[0].lower() not in net_protocols, dd_args)) + return args
def is_interactive(): @@ -141,10 +147,13 @@ def is_interactive(): def umount(device): """ Unmount the device
- :param device: Device to unmount + :param device: Device or mountpoint to unmount :type device: string :returns: None """ + if not device: + return + try: run_cmd(["umount", device]) except (OSError, RunCmdError): @@ -588,8 +597,8 @@ def network_driver(dd_path):
# TODO: May need to add new drivers to /tmp/dd_modules to prevent them from being unloaded
- # Scan for new OEMDRV devices - dd_scan(skip_dds) + # Scan for new OEMDRV devices and ignore dd_args + dd_scan(skip_dds, False)
class DeviceInfo(object): def __init__(self, device, label, uuid, fs_type): @@ -655,12 +664,14 @@ def select_iso():
return ("/media/DD-search/" + dd_iso, "/media/DD-search")
-def dd_scan(skip_dds=None): +def dd_scan(skip_dds=None, scan_dd_args=True): """ Scan the system for OEMDRV devices and and specified by dd=/dev/<device>
- :param skip_dds: devices to skip when checking for OEMDRV label - :type skip_dds: set() - :returns: None + :param skip_dds: devices to skip when checking for OEMDRV label + :type skip_dds: set() + :param scan_dd_args: Scan devices passed in /tmp/dd_args or dd_args_ks + :type scan_dd_args: bool + :returns: None """ if skip_dds: dd_finished = skip_dds @@ -671,6 +682,7 @@ def dd_scan(skip_dds=None): dd_finished = set() dd_todo = set(oemdrv_list())
+ if scan_dd_args: # Add the user specified devices dd_devs = get_dd_args() dd_devs = [dev for dev in dd_devs if dev not in ("dd", "inst.dd")] @@ -678,7 +690,7 @@ def dd_scan(skip_dds=None): log.info("Checking devices %s" % ", ".join(dd_todo))
mount_point = None - if not dd_todo: + if not dd_todo and is_interactive(): iso, mount_point = select_iso() if iso: dd_todo.add(iso) @@ -707,7 +719,19 @@ if __name__ == '__main__': log.addHandler(handler)
if len(sys.argv) > 1: + # Network driver source network_driver(sys.argv[1]) + elif os.path.exists("/tmp/DD-net/"): + network_driver("/tmp/DD-net/") + elif os.path.exists("/tmp/dd_args_ks"): + # Kickstart driverdisk command, skip existing OEMDRV devices and + # process cmdline dd entries. This will process any OEMDRV that + # appear after loading the other drivers. + skip_dds = set(oemdrv_list()) + dd_scan(skip_dds) else: + # Process /tmp/dd_args and OEMDRV devices dd_scan()
+ sys.exit(0) +
This removes the second driver-updates service for network UI startup and creates a start_driver_update function that is used by the 3 places that driver updates need to be processed.
It also moves the driver-fetch-net to run after kickstart-fetch-net so that kickstart driverdisk network sources can be processed in the same way as the cmdline network sources.
Related: rhbz#1035663 --- dracut/Makefile.am | 1 - dracut/README-dd | 26 ++++++++++++++++---------- dracut/anaconda-lib.sh | 27 +++++++++++++++++---------- dracut/driver-updates-net.sh | 11 +---------- dracut/driver-updates-net@.service | 17 ----------------- dracut/driver-updates.sh | 14 ++------------ dracut/module-setup.sh | 3 +-- 7 files changed, 37 insertions(+), 62 deletions(-) delete mode 100644 dracut/driver-updates-net@.service
diff --git a/dracut/Makefile.am b/dracut/Makefile.am index 3bab16a..27cb82b 100644 --- a/dracut/Makefile.am +++ b/dracut/Makefile.am @@ -43,7 +43,6 @@ dist_dracut_SCRIPTS = module-setup.sh \ parse-anaconda-dd.sh \ fetch-driver-net.sh \ driver-updates@.service \ - driver-updates-net@.service \ driver-updates.sh \ driver-updates-net.sh \ anaconda-depmod.sh \ diff --git a/dracut/README-dd b/dracut/README-dd index 2c3a1be..ba3f522 100644 --- a/dracut/README-dd +++ b/dracut/README-dd @@ -6,8 +6,7 @@ modules before the rest of the installer is executed.
cmdline hook parse-anaconda-dd.sh - parses the inst.dd/dd arguments for URIs and saves all of them into /tmp/dd_args - and calls set_neednet if network is needed to retrieve a driver rpm + Calls set_neednet if network is needed to retrieve a driver rpm The files will be downloaded when the network device online hook is executed.
initqueue/online @@ -28,14 +27,11 @@ pre-pivot hook anaconda-depmod.sh If any drivers were installed or downloaded run depmod on the $NEWROOT
- Systemd Services - driver-updates@.service and driver-updates-net@.service - These services launch the driver update UI (/bin/driver-updates). The -net - version passes the path to the rpm's that have been downloaded from the - network. They handle connecting the tty so that the user can select drivers - if inst.dd has been passed on the cmdline. - + driver-updates@.service + This service launch the driver update UI (/bin/driver-updates). It handles + connecting the tty so that the user can select drivers if inst.dd has + been passed on the cmdline.
driver-updates This searches disks labeled OEMDRV for driver update repositories and @@ -45,7 +41,17 @@ driver-updates
Pass it the path to a directory of rpms (eg. downloaded from the network) and it will install them before checking for additional OEMDRV - labeled devices. + labeled devices. It will also do this if /tmp/DD-net/ is present. + + If /tmp/dd_args_ks is present when it runs it will ignore existing + OEMDRV devices and process the devices in the file first, then process + any new OEMDRV devices that appear.
Pass inst.dd with no parameters and it will prompt the user for specific drivers to load using a simple text user interface. + +parse-kickstart + If the driverdisk command is present in the kickstart it will write + out partitions to /tmp/dd_args_ks and network sources to the cmdline + for normal network handling. The dd_args_ks devices are handled in + run_kickstart using the driver-updates@.service diff --git a/dracut/anaconda-lib.sh b/dracut/anaconda-lib.sh index 348b5b4..11be056 100755 --- a/dracut/anaconda-lib.sh +++ b/dracut/anaconda-lib.sh @@ -223,17 +223,10 @@ run_kickstart() { done
# Run the driver update UI for disks - if [ -e "/tmp/dd_ks" ]; then + if [ -e "/tmp/dd_args_ks" ]; then # TODO: Seems like this should be a function, a mostly same version is used in 3 places - tty=$(find_tty) - - # save module state - cat /proc/modules > /tmp/dd_modules - - info "Starting Kickstart Driver Update Disk Service on $tty" - systemctl start driver-updates@$tty.service - status=$(systemctl -p ExecMainStatus show driver-updates@$tty.service) - info "DD status=$status" + start_driver_update "Kickstart Driver Update Disk" + rm /tmp/dd_args_ks fi
# replay udev events to trigger actions @@ -257,3 +250,17 @@ wait_for_kickstart() { wait_for_updates() { echo "[ -e /tmp/liveupdates.done ]" > $hookdir/initqueue/finished/updates.sh } + +start_driver_update() { + local title="$1" + + tty=$(find_tty) + + # save module state + cat /proc/modules > /tmp/dd_modules + + info "Starting $title Service on $tty" + systemctl start driver-updates@$tty.service + status=$(systemctl -p ExecMainStatus show driver-updates@$tty.service) + info "DD status=$status" +} diff --git a/dracut/driver-updates-net.sh b/dracut/driver-updates-net.sh index d4a503f..f8bed52 100755 --- a/dracut/driver-updates-net.sh +++ b/dracut/driver-updates-net.sh @@ -5,15 +5,6 @@ command -v getarg >/dev/null || . /lib/dracut-lib.sh . /lib/anaconda-lib.sh
if [ -n "$(ls /tmp/DD-net)" ]; then - # Run the systemd service for network drivers - tty=$(find_tty) - - # Update module list so we don't unload the network driver - cat /proc/modules > /tmp/dd_modules - - info "Starting Network Driver Update Disk Service on $tty" - systemctl start driver-updates-net@$tty.service - status=$(systemctl -p ExecMainStatus show driver-updates-net@$tty.service) - info "Network DD status=$status" + start_driver_update "Network Driver Update Disk" rm -rf /tmp/DD-net fi diff --git a/dracut/driver-updates-net@.service b/dracut/driver-updates-net@.service deleted file mode 100644 index b457502..0000000 --- a/dracut/driver-updates-net@.service +++ /dev/null @@ -1,17 +0,0 @@ -[Unit] -Description=Network Driver Update Disk UI on %I -DefaultDependencies=no -Before=shutdown.target - -[Service] -Type=oneshot -RemainAfterExit=no -WorkingDirectory=/tmp -Environment=LANG=en_US.UTF-8 -ExecStart=/bin/driver-updates /tmp/DD-net/ -StandardInput=tty-force -StandardOutput=inherit -StandardError=inherit -TTYPath=/dev/%I -TTYReset=yes -TimeoutSec=0 diff --git a/dracut/driver-updates.sh b/dracut/driver-updates.sh index 99ca245..e2cc887 100755 --- a/dracut/driver-updates.sh +++ b/dracut/driver-updates.sh @@ -12,23 +12,13 @@ blkid_rc=$?
command -v getarg >/dev/null || . /lib/dracut-lib.sh dd_args="$(getargs dd= inst.dd=)" - -# /tmp/dd_args will have been set by parse-anaconda-dd.sh cmdline hook if [ -n "$dd_args" -o $blkid_rc -eq 0 ]; then command -v getarg >/dev/null || . /lib/dracut-lib.sh . /lib/anaconda-lib.sh
- tty=$(find_tty) # kludge to let kernel spit out some extra info w/o stomping on our UI sleep 5 - - # save module state - cat /proc/modules > /tmp/dd_modules - echo "$dd_args" > /tmp/dd_args - info "Starting Driver Update Disk Service on $tty" - systemctl start driver-updates@$tty.service - status=$(systemctl -p ExecMainStatus show driver-updates@$tty.service) - info "DD status=$status" + start_driver_update "Driver Update Disk" + rm /tmp/dd_args fi - diff --git a/dracut/module-setup.sh b/dracut/module-setup.sh index 4dd8a4c..f40645d 100755 --- a/dracut/module-setup.sh +++ b/dracut/module-setup.sh @@ -45,13 +45,12 @@ install() { inst "$moddir/parse-kickstart" "/sbin/parse-kickstart" # Driver Update Disks inst_hook cmdline 29 "$moddir/parse-anaconda-dd.sh" - inst_hook initqueue/online 10 "$moddir/fetch-driver-net.sh" + inst_hook initqueue/online 20 "$moddir/fetch-driver-net.sh" inst_hook pre-trigger 40 "$moddir/driver-updates.sh" inst_hook pre-pivot 10 "$moddir/driver-updates-net.sh" inst_hook pre-pivot 50 "$moddir/anaconda-depmod.sh" inst "$moddir/driver-updates" "/bin/driver-updates" inst_simple "$moddir/driver-updates@.service" "/etc/systemd/system/driver-updates@.service" - inst_simple "$moddir/driver-updates-net@.service" "/etc/systemd/system/driver-updates-net@.service" # rpm configuration file (needed by dd_extract) inst "/usr/lib/rpm/rpmrc" # python deps for parse-kickstart. DOUBLE WOOOO
This implements the kickstart driverdisk command. The changes are mostly re-structuring things a bit to make it cleaner for the kickstart code. In a couple places in the first 3 commits you may notice comments that aren't quite right, and I changed from using /tmp/dd_ks to /tmp/dd_args_ks in another place. Everything matches up by the end.
I have tested this with a current (3.10.0-83) driverdisk iso and both partition and kickstart driverdisk sources work, as well as the previously working commandline inst.dd options.
These look fine to me.
- Chris
anaconda-patches@lists.fedorahosted.org