Merge lp:~ltrager/flash-kernel/get_machine_deps into lp:flash-kernel

Proposed by Lee Trager
Status: Needs review
Proposed branch: lp:~ltrager/flash-kernel/get_machine_deps
Merge into: lp:flash-kernel
Diff against target: 15 lines (+5/-0)
1 file modified
functions (+5/-0)
To merge this branch: bzr merge lp:~ltrager/flash-kernel/get_machine_deps
Reviewer Review Type Date Requested Status
Ubuntu Installer Team Pending
Review via email: mp+311210@code.launchpad.net

Commit message

Add --get-machine-required-packages to show the required packages needed to run.

Description of the change

In lp:~ltrager/curtin/lp1640519 I needed to modify curtin to install the required machine dependencies so flash-kernel successfully runs. There wasn't a straight forward way to do this so I ended up writing my own script which sources the flash-kernel functions and retrieves the 'Required-Packages' field. This adds a command line option to do just that.

To post a comment you must log in.
Revision history for this message
Scott Moser (smoser) wrote :

So someone would use this by then doing something like:

if flash-kernel --supported; then
   pkgs=$(flash-kernel --get-machine-required-packages) || fail "failed getting required packages"
   apt-get install -qy $pkgs
fi

right ? I'm not sure that the 'check_supported' usage in your addition helps at all, because the user of this somehow has to determine the difference between failure due to "not supported" or other failure. So they end up having to do the above, right?

One thing i might suggest is just changing it to be more generic and allow getting of any field.

if [ "$1" = "--get-machine-field" ]; then
   get_machine_field "$machine" "$2"
   exit
fi

Revision history for this message
Scott Moser (smoser) wrote :

Lee, Thanks for doing this!

994. By Lee Trager

* Add generic --get-machine-field
* Remove check_supported, get_machien_field will return 0 if the machine isn't support

Revision history for this message
Lee Trager (ltrager) wrote :

Thanks for the review. I've made the argument more generic as you suggested. I also confirmed check_supported isn't needed, get_machine_field will exit 1 if its not found.

Revision history for this message
Scott Moser (smoser) wrote :

"I also confirmed check_supported isn't needed, get_machine_field will exit 1 if its not found."

Well, thats unfortunate.

What we want to have a program do is say : give me a list of packages that I shoudl install

and allow for that list to be "".

As I understand it right now, if the hardware should not install any, it will exit 1.

But then the caller cannot determine the differnce between failure for unexpected return
and "no packages to install".

Perhaps we then almost need a specific path for this.

Does that make sense ?

995. By Lee Trager

Always exit 0 when using --get-machine-field

Revision history for this message
Lee Trager (ltrager) wrote :

I've updated the MP so --get-machine-field always exit's 0. If the machine isn't supported or doesn't have the matching field nothing will be printed.

Unmerged revisions

995. By Lee Trager

Always exit 0 when using --get-machine-field

994. By Lee Trager

* Add generic --get-machine-field
* Remove check_supported, get_machien_field will return 0 if the machine isn't support

993. By Lee Trager

Add --get-machine-required-packages to show the required packages needed to run.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'functions'
--- functions 2016-08-06 02:00:32 +0000
+++ functions 2016-12-01 00:14:08 +0000
@@ -646,6 +646,11 @@
646 exit 1646 exit 1
647fi647fi
648648
649if [ "x$1" = "x--get-machine-field" ]; then
650 get_machine_field "$machine" $2 ||:
651 exit 0
652fi
653
649# $FK_KERNEL_HOOK_SCRIPT is set when main() is called from654# $FK_KERNEL_HOOK_SCRIPT is set when main() is called from
650# /etc/kernel/* to be able to differentiate between being called655# /etc/kernel/* to be able to differentiate between being called
651# upon kernel installation or kernel removal656# upon kernel installation or kernel removal

Subscribers

People subscribed via source and target branches