Commit Graph

5 Commits

Author SHA1 Message Date
Michael Johnson
fae8004e4d squash-package-install to use the correct python
99-squash-package-install in the package-installs element does not
know which python environments the requirements were installed into.
This can cause it to select the wrong python to run the
package-installs-squash script.

Co-Authored-By: Adam Harwell <flux.adam@gmail.com>
Change-Id: I5fab0e192c3a2dad8f60e821c184479e24e33bcd
2017-03-13 20:24:39 +11:00
Ian Wienand
85985cdadc Make our virtualenv source py3 safe
execfile() has gone in python3, and if you google various
stackoverflow results, python-dev mailing list threads and other
projects it seems runpy is considered one of the better solutions.
This should be py2.7 safe too.

Change-Id: I18077ba9d603752492cc81f260e12710981f4dff
2017-03-13 20:22:27 +11:00
Ian Wienand
04208e7c79 Activate virtualenv in disk-image-create
Because we're still fundamentally a python program calling a
shell-script, there's some oddities like not having the virtualenv
bin/ in the $PATH if we call disk-image-create directly.

We can detect this, however, and activate the virtualenv before we
fork the disk-image-create shell script so everything "just works".

See also nodepool change I0537cbf167bb18edf26f84ac269cbd9c8a1ea6a2

Change-Id: Ibfea6cf6a6fd0c7f1e468d501c61ae0b58992042
2016-11-30 06:11:09 +11:00
Ian Wienand
3c6e589226 Remove execute perm from disk-image-create
Remove the x bit from lib/disk-image-create; because it's called
directly by the entry-point, it doesn't need to be exectuable.
This should also be clearer that you're not supposed to run it
by hand.

Remove some boilerplate from old file

Change-Id: Ibb6cdae613e6c9cf21dd6aecc8e1f739bc3a2643
2016-11-04 17:11:27 +11:00
Ian Wienand
7446c32197 Move diskimage-image-create to an entry point
It has always been a weird thing that dib is a python package, but
is totally driven by the disk-image-create script.  It creates this
strange division that is hard to explain.

This moves disk-image-create to a regular python entry-point

Currently, this simply exec()s the original disk-image-create script.

However, we now have a (private) interface between disk-image-create
written in python and the driver shell script.  Here's some things we
could do, for example:

* Argument parsing is generally nicer in Python, and then end result
  is mostly just setting environment variables to flag different things
  in the shell script.  I could see us moving the argument-parsing into
  diskimage_builder.disk_image_create:main() and just setting things in
  os.environ before the exec()).

* I7092e1845942f249175933d67ab121188f3511fd sets IMAGE_ELEMENT_YAML in
  disk-image-create by calling-back to element-info.  We can just call
  element_dependencies.find_all_elements() in here an export is to
  os.environ before disk-image-create starts.

* remove need for ramdisk-image-create symlink by just exporting
  IS_RAMDISK based on sys.argv[1] value

* you could even unit test some of this :)

Change-Id: I69ca3d26fede0506a6353c077c69f735c8d84d28
2016-11-02 05:12:11 +00:00