Skip to contentSkip to conversation

wic: diet and refactor

PATCH In review Tom Zanussi 2 participants 38 messages Aug 8, 2014 – Sep 9, 2014

lore
Share & tools
lore
#0 lore raw

cover wic: diet and refactor

This patchset refactors wic to have the code better reflect what it actually does, rather than look like something shoehorned into the existing mic codebase, which is essentially what it was.

It also removes most of code inherited from mic but sitting essentially unused; there's no reason to be carrying it around other than some vague intention of reusing it, but that can still be done - anything needed can always be added back. As it stands, it's only taking up space and obscuring a clear view of what's actually used.

Removing the bsp subdir from scripts/lib, and taking a size measurement using 'du -bh lib', we get:

before:
1.2M lib

after:
385K lib

About half the code remaining after this exercise belongs to the parser and related infrastructure, which could be drop-in replaced by something lighter:

116K	    lib/wic/3rdparty
7.9K	    lib/wic/msger.py
3.2K	    lib/wic/conf.py
3.1K	    lib/wic/utils/runner.py

57K lib/wic/utils/cmdln.py
1.6K lib/wic/utils/errors.py

And about 50k of it is wic command boilerplate and help text patterned after other tools in yocto such as yocto-bsp:

52K lib/image

That leaves about 150k related to the actual image creation infrastructure, which should be much more easily digestible than the previous code.

[NOTE: this patchset supersedes the 'phase1' patchset ('[PATCH 00/24]
wic: Remove unused code') from Aug 5.]

The following changes since commit 4a226369b7bb37a971c77d4abc88df81033f56c5:

dev-manual: Updates for checksums and wic (2014-08-02 10:00:26 +0100)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib.git tzanussi/wic-diet-v1
http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=tzanussi/wic-diet-v1

Tom Zanussi (35):
wic: Make exec_cmd() error out instead of warn
wic: Remove unused custom commands
wic: Remove packaging, config commands
wic: Remove mic bootstrap
wic: Remove mic chroot
wic: Remove rt_util
wic: Remove mic package managers
wic: Remove bmap support
wic: Remove fiemap support
wic: Remove grabber implementation
wic: Remove proxy support
wic: Remove rpmmisc
wic: Remove unused fs_related code
wic: Remove unused misc code
wic: Remove 3rdparty/urlgrabber
wic: Remove unused 3rdparty/commands
wic: Remove gpt_parser
wic: Remove unused plugin and error code
wic: Clean up BaseImageCreator
wic: Clean up DirectImageCreator
wic: Clean up PartitionedMount
wic: Clean up Creator
wic: Remove unused command versioning support
wic: Update 'Background and Motivation' help section
wic: Remove unused conf support
wic: Remove Mount object
wic: Update/rename/delete mount-related code
wic: Update cleanup/unmount-related code
wic: Update/rename install-related code
wic: Update/rename configure-related code
wic: Rename PartitionedMount
wic: Rename MountError
wic: Update Disk description
wic: Rename /mic to /wic
wic: Bump the version to 2.0

 scripts/lib/image/config/wic.conf                  |    1 -
 scripts/lib/image/engine.py                        |   12 +-
 scripts/lib/image/help.py                          |   22 +-
 .../mic/3rdparty/pykickstart/commands/__init__.py  |   26 -
 .../3rdparty/pykickstart/commands/authconfig.py    |   40 -
 .../mic/3rdparty/pykickstart/commands/autopart.py  |  119 --
 .../mic/3rdparty/pykickstart/commands/autostep.py  |   55 -
 .../mic/3rdparty/pykickstart/commands/clearpart.py |   86 --
 .../mic/3rdparty/pykickstart/commands/device.py    |  125 --
 .../3rdparty/pykickstart/commands/deviceprobe.py   |   40 -
 .../3rdparty/pykickstart/commands/displaymode.py   |   68 -
 .../mic/3rdparty/pykickstart/commands/dmraid.py    |   91 --
 .../3rdparty/pykickstart/commands/driverdisk.py    |  184 ---
 .../lib/mic/3rdparty/pykickstart/commands/fcoe.py  |  114 --
 .../mic/3rdparty/pykickstart/commands/firewall.py  |  193 ---
 .../mic/3rdparty/pykickstart/commands/firstboot.py |   62 -
 .../lib/mic/3rdparty/pykickstart/commands/group.py |   88 --
 .../3rdparty/pykickstart/commands/ignoredisk.py    |  139 --
 .../3rdparty/pykickstart/commands/interactive.py   |   58 -
 .../lib/mic/3rdparty/pykickstart/commands/iscsi.py |  133 --
 .../mic/3rdparty/pykickstart/commands/iscsiname.py |   54 -
 .../lib/mic/3rdparty/pykickstart/commands/key.py   |   64 -
 .../mic/3rdparty/pykickstart/commands/keyboard.py  |   55 -
 .../lib/mic/3rdparty/pykickstart/commands/lang.py  |   60 -
 .../3rdparty/pykickstart/commands/langsupport.py   |   58 -
 .../mic/3rdparty/pykickstart/commands/lilocheck.py |   54 -
 .../mic/3rdparty/pykickstart/commands/logging.py   |   66 -
 .../mic/3rdparty/pykickstart/commands/logvol.py    |  304 ----
 .../3rdparty/pykickstart/commands/mediacheck.py    |   53 -
 .../mic/3rdparty/pykickstart/commands/method.py    |  186 ---
 .../mic/3rdparty/pykickstart/commands/monitor.py   |  106 --
 .../lib/mic/3rdparty/pykickstart/commands/mouse.py |   70 -
 .../mic/3rdparty/pykickstart/commands/multipath.py |  111 --
 .../mic/3rdparty/pykickstart/commands/network.py   |  363 -----
 .../lib/mic/3rdparty/pykickstart/commands/raid.py  |  365 -----
 .../mic/3rdparty/pykickstart/commands/reboot.py    |   79 --
 .../lib/mic/3rdparty/pykickstart/commands/repo.py  |  249 ----
 .../mic/3rdparty/pykickstart/commands/rescue.py    |   68 -
 .../mic/3rdparty/pykickstart/commands/rootpw.py    |   93 --
 .../mic/3rdparty/pykickstart/commands/selinux.py   |   64 -
 .../mic/3rdparty/pykickstart/commands/services.py  |   71 -
 .../lib/mic/3rdparty/pykickstart/commands/skipx.py |   54 -
 .../lib/mic/3rdparty/pykickstart/commands/sshpw.py |  105 --
 .../mic/3rdparty/pykickstart/commands/timezone.py  |   86 --
 .../mic/3rdparty/pykickstart/commands/updates.py   |   60 -
 .../mic/3rdparty/pykickstart/commands/upgrade.py   |  106 --
 .../lib/mic/3rdparty/pykickstart/commands/user.py  |  173 ---
 .../lib/mic/3rdparty/pykickstart/commands/vnc.py   |  114 --
 .../mic/3rdparty/pykickstart/commands/volgroup.py  |  102 --
 .../mic/3rdparty/pykickstart/commands/xconfig.py   |  184 ---
 .../mic/3rdparty/pykickstart/commands/zerombr.py   |   69 -
 .../lib/mic/3rdparty/pykickstart/commands/zfcp.py  |  134 --
 .../mic/3rdparty/pykickstart/handlers/control.py   | 1307 -----------------
 .../lib/mic/3rdparty/pykickstart/handlers/f10.py   |   24 -
 .../lib/mic/3rdparty/pykickstart/handlers/f13.py   |   24 -
 .../lib/mic/3rdparty/pykickstart/handlers/f14.py   |   24 -
 .../lib/mic/3rdparty/pykickstart/handlers/f15.py   |   24 -
 .../lib/mic/3rdparty/pykickstart/handlers/f7.py    |   24 -
 .../lib/mic/3rdparty/pykickstart/handlers/f8.py    |   24 -
 .../lib/mic/3rdparty/pykickstart/handlers/f9.py    |   24 -
 .../lib/mic/3rdparty/pykickstart/handlers/fc3.py   |   24 -
 .../lib/mic/3rdparty/pykickstart/handlers/fc4.py   |   24 -
 .../lib/mic/3rdparty/pykickstart/handlers/fc5.py   |   24 -
 .../lib/mic/3rdparty/pykickstart/handlers/fc6.py   |   24 -
 .../lib/mic/3rdparty/pykickstart/handlers/rhel3.py |   24 -
 .../lib/mic/3rdparty/pykickstart/handlers/rhel4.py |   24 -
 .../lib/mic/3rdparty/pykickstart/handlers/rhel5.py |   24 -
 .../lib/mic/3rdparty/pykickstart/handlers/rhel6.py |   24 -
 .../3rdparty/pykickstart/urlgrabber/__init__.py    |   53 -
 .../3rdparty/pykickstart/urlgrabber/byterange.py   |  463 ------
 .../mic/3rdparty/pykickstart/urlgrabber/grabber.py | 1477 --------------------
 .../3rdparty/pykickstart/urlgrabber/keepalive.py   |  617 --------
 .../mic/3rdparty/pykickstart/urlgrabber/mirror.py  |  458 ------
 .../3rdparty/pykickstart/urlgrabber/progress.py    |  530 -------
 .../3rdparty/pykickstart/urlgrabber/sslfactory.py  |   90 --
 scripts/lib/mic/__version__.py                     |    1 -
 scripts/lib/mic/bootstrap.py                       |  279 ----
 scripts/lib/mic/chroot.py                          |  343 -----
 scripts/lib/mic/imager/baseimager.py               | 1263 -----------------
 scripts/lib/mic/imager/fs.py                       |   99 --
 scripts/lib/mic/imager/livecd.py                   |  750 ----------
 scripts/lib/mic/imager/liveusb.py                  |  308 ----
 scripts/lib/mic/imager/loop.py                     |  418 ------
 scripts/lib/mic/imager/raw.py                      |  501 -------
 scripts/lib/mic/kickstart/__init__.py              |  892 ------------
 .../lib/mic/kickstart/custom_commands/desktop.py   |   95 --
 .../mic/kickstart/custom_commands/installerfw.py   |   63 -
 .../lib/mic/kickstart/custom_commands/micrepo.py   |  127 --
 scripts/lib/mic/plugins/backend/yumpkgmgr.py       |  490 -------
 scripts/lib/mic/plugins/backend/zypppkgmgr.py      |  973 -------------
 scripts/lib/mic/plugins/hook/.py                   |    0
 scripts/lib/mic/plugins/hook/empty_hook.py         |    3 -
 scripts/lib/mic/plugins/imager/fs_plugin.py        |  143 --
 scripts/lib/mic/plugins/imager/livecd_plugin.py    |  255 ----
 scripts/lib/mic/plugins/imager/liveusb_plugin.py   |  260 ----
 scripts/lib/mic/plugins/imager/loop_plugin.py      |  255 ----
 scripts/lib/mic/plugins/imager/raw_plugin.py       |  275 ----
 scripts/lib/mic/rt_util.py                         |  223 ---
 scripts/lib/mic/utils/BmapCreate.py                |  298 ----
 scripts/lib/mic/utils/Fiemap.py                    |  252 ----
 scripts/lib/mic/utils/fs_related.py                | 1060 --------------
 scripts/lib/mic/utils/gpt_parser.py                |  331 -----
 scripts/lib/mic/utils/grabber.py                   |   97 --
 scripts/lib/mic/utils/misc.py                      | 1065 --------------
 scripts/lib/mic/utils/partitionedfs.py             |  782 -----------
 scripts/lib/mic/utils/proxy.py                     |  183 ---
 scripts/lib/mic/utils/rpmmisc.py                   |  600 --------
 .../{mic => wic}/3rdparty/pykickstart/__init__.py  |    0
 .../lib/{mic => wic}/3rdparty/pykickstart/base.py  |    0
 .../3rdparty/pykickstart/commands/__init__.py}     |    6 +-
 .../3rdparty/pykickstart/commands/bootloader.py    |   49 -
 .../3rdparty/pykickstart/commands/partition.py     |   39 -
 .../{mic => wic}/3rdparty/pykickstart/constants.py |    0
 .../{mic => wic}/3rdparty/pykickstart/errors.py    |    0
 .../3rdparty/pykickstart/handlers/__init__.py      |    0
 .../3rdparty/pykickstart/handlers/control.py}      |   30 +-
 .../3rdparty/pykickstart/handlers/f16.py           |    0
 .../lib/{mic => wic}/3rdparty/pykickstart/ko.py    |    0
 .../{mic => wic}/3rdparty/pykickstart/options.py   |    0
 .../{mic => wic}/3rdparty/pykickstart/parser.py    |    0
 .../{mic => wic}/3rdparty/pykickstart/sections.py  |    0
 .../{mic => wic}/3rdparty/pykickstart/version.py   |    0
 scripts/lib/{mic => wic}/__init__.py               |    0
 scripts/lib/wic/__version__.py                     |    1 +
 scripts/lib/{mic => wic}/conf.py                   |  107 +-
 scripts/lib/{mic => wic}/creator.py                |  188 +--
 scripts/lib/{mic => wic}/imager/__init__.py        |    0
 scripts/lib/wic/imager/baseimager.py               |  193 +++
 scripts/lib/{mic => wic}/imager/direct.py          |  133 +-
 scripts/lib/wic/kickstart/__init__.py              |  125 ++
 .../kickstart/custom_commands/__init__.py          |    7 -
 .../kickstart/custom_commands/micboot.py           |    0
 .../kickstart/custom_commands/micpartition.py      |    0
 .../kickstart/custom_commands/partition.py         |   50 +-
 .../kickstart/custom_commands/wicboot.py           |    2 +-
 scripts/lib/{mic => wic}/msger.py                  |    0
 scripts/lib/{mic => wic}/plugin.py                 |   18 +-
 scripts/lib/{mic => wic}/pluginbase.py             |   65 +-
 .../{mic => wic}/plugins/imager/direct_plugin.py   |   27 +-
 .../lib/{mic => wic}/plugins/source/bootimg-efi.py |   29 +-
 .../{mic => wic}/plugins/source/bootimg-pcbios.py  |   37 +-
 scripts/lib/{mic => wic}/plugins/source/rootfs.py  |   17 +-
 scripts/lib/{mic => wic}/test                      |    0
 scripts/lib/{mic => wic}/utils/__init__.py         |    0
 scripts/lib/{mic => wic}/utils/cmdln.py            |    0
 scripts/lib/{mic => wic}/utils/errors.py           |   26 +-
 scripts/lib/wic/utils/fs_related.py                |  111 ++
 scripts/lib/wic/utils/misc.py                      |   59 +
 scripts/lib/{mic => wic}/utils/oe/__init__.py      |    2 +-
 scripts/lib/{mic => wic}/utils/oe/misc.py          |   39 +-
 scripts/lib/wic/utils/partitionedfs.py             |  360 +++++
 scripts/lib/{mic => wic}/utils/runner.py           |    2 +-
 152 files changed, 1078 insertions(+), 24119 deletions(-)
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/__init__.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/authconfig.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/autopart.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/autostep.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/clearpart.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/device.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/deviceprobe.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/displaymode.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/dmraid.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/driverdisk.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/fcoe.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/firewall.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/firstboot.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/group.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/ignoredisk.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/interactive.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/iscsi.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/iscsiname.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/key.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/keyboard.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/lang.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/langsupport.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/lilocheck.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/logging.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/logvol.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/mediacheck.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/method.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/monitor.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/mouse.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/multipath.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/network.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/raid.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/reboot.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/repo.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/rescue.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/rootpw.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/selinux.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/services.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/skipx.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/sshpw.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/timezone.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/updates.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/upgrade.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/user.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/vnc.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/volgroup.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/xconfig.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/zerombr.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/zfcp.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/control.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/f10.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/f13.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/f14.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/f15.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/f7.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/f8.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/f9.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/fc3.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/fc4.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/fc5.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/fc6.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/rhel3.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/rhel4.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/rhel5.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/rhel6.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/urlgrabber/__init__.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/urlgrabber/byterange.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/urlgrabber/grabber.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/urlgrabber/keepalive.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/urlgrabber/mirror.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/urlgrabber/progress.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/urlgrabber/sslfactory.py
 delete mode 100644 scripts/lib/mic/__version__.py
 delete mode 100644 scripts/lib/mic/bootstrap.py
 delete mode 100644 scripts/lib/mic/chroot.py
 delete mode 100644 scripts/lib/mic/imager/baseimager.py
 delete mode 100644 scripts/lib/mic/imager/fs.py
 delete mode 100644 scripts/lib/mic/imager/livecd.py
 delete mode 100644 scripts/lib/mic/imager/liveusb.py
 delete mode 100644 scripts/lib/mic/imager/loop.py
 delete mode 100644 scripts/lib/mic/imager/raw.py
 delete mode 100644 scripts/lib/mic/kickstart/__init__.py
 delete mode 100644 scripts/lib/mic/kickstart/custom_commands/desktop.py
 delete mode 100644 scripts/lib/mic/kickstart/custom_commands/installerfw.py
 delete mode 100644 scripts/lib/mic/kickstart/custom_commands/micrepo.py
 delete mode 100644 scripts/lib/mic/plugins/backend/yumpkgmgr.py
 delete mode 100755 scripts/lib/mic/plugins/backend/zypppkgmgr.py
 delete mode 100644 scripts/lib/mic/plugins/hook/.py
 delete mode 100644 scripts/lib/mic/plugins/hook/empty_hook.py
 delete mode 100644 scripts/lib/mic/plugins/imager/fs_plugin.py
 delete mode 100644 scripts/lib/mic/plugins/imager/livecd_plugin.py
 delete mode 100644 scripts/lib/mic/plugins/imager/liveusb_plugin.py
 delete mode 100644 scripts/lib/mic/plugins/imager/loop_plugin.py
 delete mode 100644 scripts/lib/mic/plugins/imager/raw_plugin.py
 delete mode 100644 scripts/lib/mic/rt_util.py
 delete mode 100644 scripts/lib/mic/utils/BmapCreate.py
 delete mode 100644 scripts/lib/mic/utils/Fiemap.py
 delete mode 100644 scripts/lib/mic/utils/fs_related.py
 delete mode 100644 scripts/lib/mic/utils/gpt_parser.py
 delete mode 100644 scripts/lib/mic/utils/grabber.py
 delete mode 100644 scripts/lib/mic/utils/misc.py
 delete mode 100644 scripts/lib/mic/utils/partitionedfs.py
 delete mode 100644 scripts/lib/mic/utils/proxy.py
 delete mode 100644 scripts/lib/mic/utils/rpmmisc.py
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/__init__.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/base.py (100%)
 rename scripts/lib/{mic/3rdparty/pykickstart/handlers/f12.py => wic/3rdparty/pykickstart/commands/__init__.py} (89%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/commands/bootloader.py (83%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/commands/partition.py (89%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/constants.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/errors.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/handlers/__init__.py (100%)
 rename scripts/lib/{mic/3rdparty/pykickstart/handlers/f11.py => wic/3rdparty/pykickstart/handlers/control.py} (47%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/handlers/f16.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/ko.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/options.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/parser.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/sections.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/version.py (100%)
 rename scripts/lib/{mic => wic}/__init__.py (100%)
 create mode 100644 scripts/lib/wic/__version__.py
 rename scripts/lib/{mic => wic}/conf.py (44%)
 rename scripts/lib/{mic => wic}/creator.py (41%)
 rename scripts/lib/{mic => wic}/imager/__init__.py (100%)
 create mode 100644 scripts/lib/wic/imager/baseimager.py
 rename scripts/lib/{mic => wic}/imager/direct.py (72%)
 create mode 100644 scripts/lib/wic/kickstart/__init__.py
 rename scripts/lib/{mic => wic}/kickstart/custom_commands/__init__.py (52%)
 rename scripts/lib/{mic => wic}/kickstart/custom_commands/micboot.py (100%)
 rename scripts/lib/{mic => wic}/kickstart/custom_commands/micpartition.py (100%)
 rename scripts/lib/{mic => wic}/kickstart/custom_commands/partition.py (93%)
 rename scripts/lib/{mic => wic}/kickstart/custom_commands/wicboot.py (97%)
 rename scripts/lib/{mic => wic}/msger.py (100%)
 rename scripts/lib/{mic => wic}/plugin.py (93%)
 rename scripts/lib/{mic => wic}/pluginbase.py (66%)
 rename scripts/lib/{mic => wic}/plugins/imager/direct_plugin.py (77%)
 rename scripts/lib/{mic => wic}/plugins/source/bootimg-efi.py (88%)
 rename scripts/lib/{mic => wic}/plugins/source/bootimg-pcbios.py (87%)
 rename scripts/lib/{mic => wic}/plugins/source/rootfs.py (88%)
 rename scripts/lib/{mic => wic}/test (100%)
 rename scripts/lib/{mic => wic}/utils/__init__.py (100%)
 rename scripts/lib/{mic => wic}/utils/cmdln.py (100%)
 rename scripts/lib/{mic => wic}/utils/errors.py (75%)
 create mode 100644 scripts/lib/wic/utils/fs_related.py
 create mode 100644 scripts/lib/wic/utils/misc.py
 rename scripts/lib/{mic => wic}/utils/oe/__init__.py (95%)
 rename scripts/lib/{mic => wic}/utils/oe/misc.py (85%)
 create mode 100644 scripts/lib/wic/utils/partitionedfs.py
 rename scripts/lib/{mic => wic}/utils/runner.py (99%)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/35 wic: Make exec_cmd() error out instead of warn

The reason exec_cmd() warns but doesn't error out (broken parted) doesn't really make sense, since the parted invocations don't even use exec_cmd(). It really should just fail since by not doing so it's actually enabling invalid images in some cases.

Also, since the return code is now always zero, there's no point in having a return code, so remove it. This represents a change in the API, so we also need to update all callers.

---
 .../lib/mic/kickstart/custom_commands/partition.py | 44 +++++++++++-----------
 scripts/lib/mic/plugins/source/bootimg-efi.py      |  8 ++--
 scripts/lib/mic/plugins/source/bootimg-pcbios.py   | 10 ++---
 scripts/lib/mic/utils/fs_related.py                |  2 +-
 scripts/lib/mic/utils/oe/misc.py                   | 33 +++++++++-------
 scripts/lib/mic/utils/partitionedfs.py             |  2 +-
 6 files changed, 53 insertions(+), 46 deletions(-)
scripts/lib/mic/kickstart/custom_commands/partition.py +22 -22
index 3b652b3..101b90e 100644
@@ -161,7 +161,7 @@ class Wic_PartData(Mic_PartData):
         """
         rootfs = oe_builddir
         du_cmd = "du -Lbms %s" % rootfs
-        rc, out = exec_cmd(du_cmd)
+        out = exec_cmd(du_cmd)
         rootfs_size = out.split()[0]
 
         self.size = rootfs_size
@@ -209,7 +209,7 @@ class Wic_PartData(Mic_PartData):
         rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype)
 
         du_cmd = "du -ks %s" % image_rootfs
-        rc, out = exec_cmd(du_cmd)
+        out = exec_cmd(du_cmd)
         actual_rootfs_size = int(out.split()[0])
 
         extra_blocks = self.get_extra_block_count(actual_rootfs_size)
@@ -224,18 +224,18 @@ class Wic_PartData(Mic_PartData):
 
         dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=0 bs=1k" % \
             (rootfs, rootfs_size)
-        rc, out = exec_cmd(dd_cmd)
+        exec_cmd(dd_cmd)
 
         extra_imagecmd = "-i 8192"
 
         mkfs_cmd = "mkfs.%s -F %s %s -d %s" % \
             (self.fstype, extra_imagecmd, rootfs, image_rootfs)
-        rc, out = exec_native_cmd(pseudo + mkfs_cmd, native_sysroot)
+        exec_native_cmd(pseudo + mkfs_cmd, native_sysroot)
 
 
         # get the rootfs size in the right units for kickstart (Mb)
         du_cmd = "du -Lbms %s" % rootfs
-        rc, out = exec_cmd(du_cmd)
+        out = exec_cmd(du_cmd)
         rootfs_size = out.split()[0]
 
         self.size = rootfs_size
@@ -254,7 +254,7 @@ class Wic_PartData(Mic_PartData):
         rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype)
 
         du_cmd = "du -ks %s" % image_rootfs
-        rc, out = exec_cmd(du_cmd)
+        out = exec_cmd(du_cmd)
         actual_rootfs_size = int(out.split()[0])
 
         extra_blocks = self.get_extra_block_count(actual_rootfs_size)
@@ -269,15 +269,15 @@ class Wic_PartData(Mic_PartData):
 
         dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=0 bs=1k" % \
             (rootfs, rootfs_size)
-        rc, out = exec_cmd(dd_cmd)
+        exec_cmd(dd_cmd)
 
         mkfs_cmd = "mkfs.%s -b %d -r %s %s" % \
             (self.fstype, rootfs_size * 1024, image_rootfs, rootfs)
-        rc, out = exec_native_cmd(pseudo + mkfs_cmd, native_sysroot)
+        exec_native_cmd(pseudo + mkfs_cmd, native_sysroot)
 
         # get the rootfs size in the right units for kickstart (Mb)
         du_cmd = "du -Lbms %s" % rootfs
-        rc, out = exec_cmd(du_cmd)
+        out = exec_cmd(du_cmd)
         rootfs_size = out.split()[0]
 
         self.size = rootfs_size
@@ -292,7 +292,7 @@ class Wic_PartData(Mic_PartData):
         rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype)
 
         du_cmd = "du -bks %s" % image_rootfs
-        rc, out = exec_cmd(du_cmd)
+        out = exec_cmd(du_cmd)
         blocks = int(out.split()[0])
 
         extra_blocks = self.get_extra_block_count(blocks)
@@ -324,7 +324,7 @@ class Wic_PartData(Mic_PartData):
 
         # get the rootfs size in the right units for kickstart (Mb)
         du_cmd = "du -Lbms %s" % rootfs
-        rc, out = exec_cmd(du_cmd)
+        out = exec_cmd(du_cmd)
         rootfs_size = out.split()[0]
 
         self.set_size(rootfs_size)
@@ -340,11 +340,11 @@ class Wic_PartData(Mic_PartData):
 
         squashfs_cmd = "mksquashfs %s %s -noappend" % \
                        (image_rootfs, rootfs)
-        rc, out = exec_native_cmd(pseudo + squashfs_cmd, native_sysroot)
+        exec_native_cmd(pseudo + squashfs_cmd, native_sysroot)
 
         # get the rootfs size in the right units for kickstart (Mb)
         du_cmd = "du -Lbms %s" % rootfs
-        rc, out = exec_cmd(du_cmd)
+        out = exec_cmd(du_cmd)
         rootfs_size = out.split()[0]
 
         self.size = rootfs_size
@@ -378,12 +378,12 @@ class Wic_PartData(Mic_PartData):
 
         dd_cmd = "dd if=/dev/zero of=%s bs=1M seek=%d count=0" % \
             (fs, self.size)
-        rc, out = exec_cmd(dd_cmd)
+        exec_cmd(dd_cmd)
 
         extra_imagecmd = "-i 8192"
 
         mkfs_cmd = "mkfs.%s -F %s %s" % (self.fstype, extra_imagecmd, fs)
-        rc, out = exec_native_cmd(mkfs_cmd, native_sysroot)
+        exec_native_cmd(mkfs_cmd, native_sysroot)
 
         self.source_file = fs
 
@@ -398,13 +398,13 @@ class Wic_PartData(Mic_PartData):
 
         dd_cmd = "dd if=/dev/zero of=%s bs=1M seek=%d count=0" % \
             (fs, self.size)
-        rc, out = exec_cmd(dd_cmd)
+        exec_cmd(dd_cmd)
 
         mkfs_cmd = "mkfs.%s -b %d %s" % (self.fstype, self.size * 1024, rootfs)
-        rc, out = exec_native_cmd(mkfs_cmd, native_sysroot)
+        exec_native_cmd(mkfs_cmd, native_sysroot)
 
         mkfs_cmd = "mkfs.%s -F %s %s" % (self.fstype, extra_imagecmd, fs)
-        rc, out = exec_native_cmd(mkfs_cmd, native_sysroot)
+        exec_native_cmd(mkfs_cmd, native_sysroot)
 
         self.source_file = fs
 
@@ -445,13 +445,13 @@ class Wic_PartData(Mic_PartData):
 
         squashfs_cmd = "mksquashfs %s %s -noappend" % \
                        (tmpdir, fs)
-        rc, out = exec_native_cmd(squashfs_cmd, native_sysroot)
+        exec_native_cmd(squashfs_cmd, native_sysroot)
 
         os.rmdir(tmpdir)
 
         # get the rootfs size in the right units for kickstart (Mb)
         du_cmd = "du -Lbms %s" % fs
-        rc, out = exec_cmd(du_cmd)
+        out = exec_cmd(du_cmd)
         fs_size = out.split()[0]
 
         self.size = fs_size
@@ -467,14 +467,14 @@ class Wic_PartData(Mic_PartData):
 
         dd_cmd = "dd if=/dev/zero of=%s bs=1M seek=%d count=0" % \
             (fs, self.size)
-        rc, out = exec_cmd(dd_cmd)
+        exec_cmd(dd_cmd)
 
         import uuid
         label_str = ""
         if self.label:
             label_str = "-L %s" % self.label
         mkswap_cmd = "mkswap %s -U %s %s" % (label_str, str(uuid.uuid1()), fs)
-        rc, out = exec_native_cmd(mkswap_cmd, native_sysroot)
+        exec_native_cmd(mkswap_cmd, native_sysroot)
 
         self.source_file = fs
 
scripts/lib/mic/plugins/source/bootimg-efi.py +4 -4
index 0dd9152..aecda6b 100644
@@ -53,7 +53,7 @@ class BootimgEFIPlugin(SourcePlugin):
         exec_cmd(rm_cmd)
 
         install_cmd = "install -d %s/EFI/BOOT" % hdddir
-        tmp = exec_cmd(install_cmd)
+        exec_cmd(install_cmd)
 
         splash = os.path.join(cr_workdir, "/EFI/boot/splash.jpg")
         if os.path.exists(splash):
@@ -116,7 +116,7 @@ class BootimgEFIPlugin(SourcePlugin):
 
         install_cmd = "install -m 0644 %s/bzImage %s/bzImage" % \
             (staging_kernel_dir, hdddir)
-        tmp = exec_cmd(install_cmd)
+        exec_cmd(install_cmd)
 
         shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir,
                         "%s/grub.cfg" % cr_workdir)
@@ -128,7 +128,7 @@ class BootimgEFIPlugin(SourcePlugin):
                     "%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir)
 
         du_cmd = "du -bks %s" % hdddir
-        rc, out = exec_cmd(du_cmd)
+        out = exec_cmd(du_cmd)
         blocks = int(out.split()[0])
 
         extra_blocks = part.get_extra_block_count(blocks)
@@ -160,7 +160,7 @@ class BootimgEFIPlugin(SourcePlugin):
         exec_cmd(chmod_cmd)
 
         du_cmd = "du -Lbms %s" % bootimg
-        rc, out = exec_cmd(du_cmd)
+        out = exec_cmd(du_cmd)
         bootimg_size = out.split()[0]
 
         part.set_size(bootimg_size)
scripts/lib/mic/plugins/source/bootimg-pcbios.py +5 -5
index 1211e5c..6488ae9 100644
@@ -78,7 +78,7 @@ class BootimgPcbiosPlugin(SourcePlugin):
         exec_cmd(rm_cmd)
 
         install_cmd = "install -d %s" % hdddir
-        tmp = exec_cmd(install_cmd)
+        exec_cmd(install_cmd)
 
         splash = os.path.join(cr_workdir, "/hdd/boot/splash.jpg")
         if os.path.exists(splash):
@@ -144,14 +144,14 @@ class BootimgPcbiosPlugin(SourcePlugin):
 
         install_cmd = "install -m 0644 %s/bzImage %s/vmlinuz" \
             % (staging_kernel_dir, hdddir)
-        tmp = exec_cmd(install_cmd)
+        exec_cmd(install_cmd)
 
         install_cmd = "install -m 444 %s/syslinux/ldlinux.sys %s/ldlinux.sys" \
             % (staging_data_dir, hdddir)
-        tmp = exec_cmd(install_cmd)
+        exec_cmd(install_cmd)
 
         du_cmd = "du -bks %s" % hdddir
-        rc, out = exec_cmd(du_cmd)
+        out = exec_cmd(du_cmd)
         blocks = int(out.split()[0])
 
         extra_blocks = part.get_extra_block_count(blocks)
@@ -186,7 +186,7 @@ class BootimgPcbiosPlugin(SourcePlugin):
         exec_cmd(chmod_cmd)
 
         du_cmd = "du -Lbms %s" % bootimg
-        rc, out = exec_cmd(du_cmd)
+        out = exec_cmd(du_cmd)
         bootimg_size = out.split()[0]
 
         part.set_size(bootimg_size)
scripts/lib/mic/utils/fs_related.py +1 -1
index dd420e8..182171f 100644
@@ -306,7 +306,7 @@ class DiskImage(Disk):
         # create disk image
         dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=1" % \
             (self.image_file, blocks)
-        rc, out = exec_cmd(dd_cmd)
+        exec_cmd(dd_cmd)
 
         self.device = self.image_file
 
scripts/lib/mic/utils/oe/misc.py +20 -13
index 16c250a..bed2750 100644
@@ -28,13 +28,13 @@
 from mic import msger
 from mic.utils import runner
 
-def exec_cmd(cmd_and_args, as_shell = False, catch = 3):
+def __exec_cmd(cmd_and_args, as_shell = False, catch = 3):
     """
     Execute command, catching stderr, stdout
 
     Need to execute as_shell if the command uses wildcards
     """
-    msger.debug("exec_cmd: %s" % cmd_and_args)
+    msger.debug("__exec_cmd: %s" % cmd_and_args)
     args = cmd_and_args.split()
     msger.debug(args)
 
@@ -43,24 +43,31 @@ def exec_cmd(cmd_and_args, as_shell = False, catch = 3):
     else:
         rc, out = runner.runtool(args, catch)
     out = out.strip()
-    msger.debug("exec_cmd: output for %s (rc = %d): %s" % \
-                    (cmd_and_args, rc, out))
+    msger.debug("__exec_cmd: output for %s (rc = %d): %s" % \
+                (cmd_and_args, rc, out))
+
+    return (rc, out)
+
+
+def exec_cmd(cmd_and_args, as_shell = False, catch = 3):
+    """
+    Execute command, catching stderr, stdout
+
+    Exits if rc non-zero
+    """
+    rc, out = __exec_cmd(cmd_and_args, as_shell, catch)
 
     if rc != 0:
-        # We don't throw exception when return code is not 0, because
-        # parted always fails to reload part table with loop devices. This
-        # prevents us from distinguishing real errors based on return
-        # code.
-        msger.warning("WARNING: %s returned '%s' instead of 0" % (cmd_and_args, rc))
+        msger.error("exec_cmd: %s returned '%s' instead of 0" % (cmd_and_args, rc))
 
-    return (rc, out)
+    return out
 
 
 def exec_cmd_quiet(cmd_and_args, as_shell = False):
     """
     Execute command, catching nothing in the output
 
-    Need to execute as_shell if the command uses wildcards
+    Exits if rc non-zero
     """
     return exec_cmd(cmd_and_args, as_shell, 0)
 
@@ -82,7 +89,7 @@ def exec_native_cmd(cmd_and_args, native_sysroot, catch = 3):
     args = cmd_and_args.split()
     msger.debug(args)
 
-    rc, out = exec_cmd(native_cmd_and_args, True, catch)
+    rc, out = __exec_cmd(native_cmd_and_args, True, catch)
 
     if rc == 127: # shell command-not-found
         msger.error("A native (host) program required to build the image "
@@ -135,7 +142,7 @@ def find_bitbake_env_lines(image_name):
         bitbake_env_cmd = "bitbake -e %s" % image_name
     else:
         bitbake_env_cmd = "bitbake -e"
-    rc, bitbake_env_lines = exec_cmd(bitbake_env_cmd)
+    rc, bitbake_env_lines = __exec_cmd(bitbake_env_cmd)
     if rc != 0:
         print "Couldn't get '%s' output." % bitbake_env_cmd
         return None
scripts/lib/mic/utils/partitionedfs.py +1 -1
index 593cf1f..83ce869 100644
@@ -744,7 +744,7 @@ class PartitionedMount(Mount):
 
         dd_cmd = "dd if=%s of=%s bs=%d seek=%d count=%d conv=notrunc" % \
             (source_file, self.image_file, self.sector_size, start, size)
-        rc, out = exec_cmd(dd_cmd)
+        exec_cmd(dd_cmd)
 
 
     def install(self, image_file):
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/35 wic: Remove unused custom commands

installer, repo, desktop-related stuff

---
 scripts/lib/mic/kickstart/__init__.py              |   6 +-
 .../lib/mic/kickstart/custom_commands/__init__.py  |   7 --
 .../lib/mic/kickstart/custom_commands/desktop.py   |  95 ---------------
 .../mic/kickstart/custom_commands/installerfw.py   |  63 ----------
 .../lib/mic/kickstart/custom_commands/micrepo.py   | 127 ---------------------
 5 files changed, 1 insertion(+), 297 deletions(-)
 delete mode 100644 scripts/lib/mic/kickstart/custom_commands/desktop.py
 delete mode 100644 scripts/lib/mic/kickstart/custom_commands/installerfw.py
 delete mode 100644 scripts/lib/mic/kickstart/custom_commands/micrepo.py
scripts/lib/mic/kickstart/__init__.py +1 -5
index 72f3ca6..11cdf63 100644
@@ -32,7 +32,7 @@ from pykickstart.handlers.control import dataMap
 
 from mic import msger
 from mic.utils import errors, misc, runner, fs_related as fs
-from custom_commands import desktop, micrepo, wicboot, partition, installerfw
+from custom_commands import wicboot, partition
 
 
 AUTH_URL_PTN = r"(?P<scheme>.*)://(?P<username>.*)(:?P<password>.*)?@(?P<url>.*)"
@@ -96,13 +96,9 @@ def read_kickstart(path):
     #ks = ksparser.KickstartParser(version)
 
     using_version = ksversion.DEVEL
-    commandMap[using_version]["desktop"] = desktop.Mic_Desktop
-    commandMap[using_version]["repo"] = micrepo.Mic_Repo
     commandMap[using_version]["bootloader"] = wicboot.Wic_Bootloader
     commandMap[using_version]["part"] = partition.Wic_Partition
     commandMap[using_version]["partition"] = partition.Wic_Partition
-    commandMap[using_version]["installerfw"] = installerfw.Mic_installerfw
-    dataMap[using_version]["RepoData"] = micrepo.Mic_RepoData
     dataMap[using_version]["PartData"] = partition.Wic_PartData
     superclass = ksversion.returnClassForVersion(version=using_version)
 
scripts/lib/mic/kickstart/custom_commands/__init__.py +0 -7
index 6aed0ff..f84c6d9 100644
@@ -1,17 +1,10 @@
-from desktop import Mic_Desktop
-from micrepo import Mic_Repo, Mic_RepoData
 from micpartition import Mic_Partition
 from micpartition import Mic_PartData
-from installerfw import Mic_installerfw
 from partition import Wic_Partition
 
 __all__ = (
-    "Mic_Desktop",
-    "Mic_Repo",
-    "Mic_RepoData",
     "Mic_Partition",
     "Mic_PartData",
-    "Mic_installerfw",
     "Wic_Partition",
     "Wic_PartData",
 )
scripts/lib/mic/kickstart/custom_commands/desktop.py deleted +0 -95

95 lines not on this page · raw message

scripts/lib/mic/kickstart/custom_commands/installerfw.py deleted +0 -63

63 lines not on this page · raw message

scripts/lib/mic/kickstart/custom_commands/micrepo.py deleted +0 -127

127 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#3 lore raw

PATCH 3/35 wic: Remove packaging, config commands

In reply to Tom Zanussi

Remove commands related to repos, packaging, configuration

---
 scripts/lib/mic/kickstart/__init__.py | 763 ----------------------------------
 1 file changed, 763 deletions(-)
scripts/lib/mic/kickstart/__init__.py +0 -763
index 11cdf63..590bf47 100644
@@ -34,54 +34,6 @@ from mic import msger
 from mic.utils import errors, misc, runner, fs_related as fs
 from custom_commands import wicboot, partition
 
-
-AUTH_URL_PTN = r"(?P<scheme>.*)://(?P<username>.*)(:?P<password>.*)?@(?P<url>.*)"
-
-
-class PrepackageSection(kssections.Section):
-    sectionOpen = "%prepackages"
-
-    def handleLine(self, line):
-        if not self.handler:
-            return
-
-        (h, s, t) = line.partition('#')
-        line = h.rstrip()
-
-        self.handler.prepackages.add([line])
-
-    def handleHeader(self, lineno, args):
-        kssections.Section.handleHeader(self, lineno, args)
-
-class AttachmentSection(kssections.Section):
-    sectionOpen = "%attachment"
-
-    def handleLine(self, line):
-        if not self.handler:
-            return
-
-        (h, s, t) = line.partition('#')
-        line = h.rstrip()
-
-        self.handler.attachment.add([line])
-
-    def handleHeader(self, lineno, args):
-        kssections.Section.handleHeader(self, lineno, args)
-
-def apply_wrapper(func):
-    def wrapper(*kargs, **kwargs):
-        try:
-            func(*kargs, **kwargs)
-        except (OSError, IOError, errors.KsError), err:
-            cfgcls = kargs[0].__class__.__name__
-            if msger.ask("Failed to apply %s, skip and continue?" % cfgcls):
-                msger.warning("%s" % err)
-                pass
-            else:
-                # just throw out the exception
-                raise
-    return wrapper
-
 def read_kickstart(path):
     """Parse a kickstart file and return a KickstartParser instance.
 
@@ -105,12 +57,8 @@ def read_kickstart(path):
     class KSHandlers(superclass):
         def __init__(self):
             superclass.__init__(self, mapping=commandMap[using_version])
-            self.prepackages = ksparser.Packages()
-            self.attachment = ksparser.Packages()
 
     ks = ksparser.KickstartParser(KSHandlers(), errorsAreFatal=False)
-    ks.registerSection(PrepackageSection(ks.handler))
-    ks.registerSection(AttachmentSection(ks.handler))
 
     try:
         ks.readKickstart(path)
@@ -123,526 +71,6 @@ def read_kickstart(path):
 
     return ks
 
-class KickstartConfig(object):
-    """A base class for applying kickstart configurations to a system."""
-    def __init__(self, instroot):
-        self.instroot = instroot
-
-    def path(self, subpath):
-        return self.instroot + subpath
-
-    def _check_sysconfig(self):
-        if not os.path.exists(self.path("/etc/sysconfig")):
-            fs.makedirs(self.path("/etc/sysconfig"))
-
-    def chroot(self):
-        os.chroot(self.instroot)
-        os.chdir("/")
-
-    def call(self, args):
-        if not os.path.exists("%s/%s" %(self.instroot, args[0])):
-            raise errors.KsError("Can't find %s in chroot" % args[0])
-        subprocess.call(args, preexec_fn = self.chroot)
-
-    def apply(self):
-        pass
-
-class LanguageConfig(KickstartConfig):
-    """A class to apply a kickstart language configuration to a system."""
-    @apply_wrapper
-    def apply(self, kslang):
-        self._check_sysconfig()
-        if kslang.lang:
-            f = open(self.path("/etc/sysconfig/i18n"), "w+")
-            f.write("LANG=\"" + kslang.lang + "\"\n")
-            f.close()
-
-class KeyboardConfig(KickstartConfig):
-    """A class to apply a kickstart keyboard configuration to a system."""
-    @apply_wrapper
-    def apply(self, kskeyboard):
-        #
-        # FIXME:
-        #   should this impact the X keyboard config too?
-        #   or do we want to make X be able to do this mapping?
-        #
-        #k = rhpl.keyboard.Keyboard()
-        #if kskeyboard.keyboard:
-        #   k.set(kskeyboard.keyboard)
-        #k.write(self.instroot)
-        pass
-
-class TimezoneConfig(KickstartConfig):
-    """A class to apply a kickstart timezone configuration to a system."""
-    @apply_wrapper
-    def apply(self, kstimezone):
-        self._check_sysconfig()
-        tz = kstimezone.timezone or "America/New_York"
-        utc = str(kstimezone.isUtc)
-
-        f = open(self.path("/etc/sysconfig/clock"), "w+")
-        f.write("ZONE=\"" + tz + "\"\n")
-        f.write("UTC=" + utc + "\n")
-        f.close()
-        tz_source = "/usr/share/zoneinfo/%s" % (tz)
-        tz_dest = "/etc/localtime"
-        try:
-            cpcmd = fs.find_binary_inchroot('cp', self.instroot)
-            if cpcmd:
-                self.call([cpcmd, "-f", tz_source, tz_dest])
-            else:
-                cpcmd = fs.find_binary_path('cp')
-                subprocess.call([cpcmd, "-f",
-                                 self.path(tz_source),
-                                 self.path(tz_dest)])
-        except (IOError, OSError), (errno, msg):
-            raise errors.KsError("Timezone setting error: %s" % msg)
-
-class AuthConfig(KickstartConfig):
-    """A class to apply a kickstart authconfig configuration to a system."""
-    @apply_wrapper
-    def apply(self, ksauthconfig):
-        auth = ksauthconfig.authconfig or "--useshadow --enablemd5"
-        args = ["/usr/share/authconfig/authconfig.py", "--update", "--nostart"]
-        self.call(args + auth.split())
-
-class FirewallConfig(KickstartConfig):
-    """A class to apply a kickstart firewall configuration to a system."""
-    @apply_wrapper
-    def apply(self, ksfirewall):
-        #
-        # FIXME: should handle the rest of the options
-        #
-        if not os.path.exists(self.path("/usr/sbin/lokkit")):
-            return
-        if ksfirewall.enabled:
-            status = "--enabled"
-        else:
-            status = "--disabled"
-
-        self.call(["/usr/sbin/lokkit",
-                   "-f", "--quiet", "--nostart", status])
-
-class RootPasswordConfig(KickstartConfig):
-    """A class to apply a kickstart root password configuration to a system."""
-    def unset(self):
-        self.call(["/usr/bin/passwd", "-d", "root"])
-
-    def set_encrypted(self, password):
-        self.call(["/usr/sbin/usermod", "-p", password, "root"])
-
-    def set_unencrypted(self, password):
-        for p in ("/bin/echo", "/usr/sbin/chpasswd"):
-            if not os.path.exists("%s/%s" %(self.instroot, p)):
-                raise errors.KsError("Unable to set unencrypted password due "
-                                     "to lack of %s" % p)
-
-        p1 = subprocess.Popen(["/bin/echo", "root:%s" %password],
-                              stdout = subprocess.PIPE,
-                              preexec_fn = self.chroot)
-        p2 = subprocess.Popen(["/usr/sbin/chpasswd", "-m"],
-                              stdin = p1.stdout,
-                              stdout = subprocess.PIPE,
-                              preexec_fn = self.chroot)
-        p2.communicate()
-
-    @apply_wrapper
-    def apply(self, ksrootpw):
-        if ksrootpw.isCrypted:
-            self.set_encrypted(ksrootpw.password)
-        elif ksrootpw.password != "":
-            self.set_unencrypted(ksrootpw.password)
-        else:
-            self.unset()
-
-class UserConfig(KickstartConfig):
-    def set_empty_passwd(self, user):
-        self.call(["/usr/bin/passwd", "-d", user])
-
-    def set_encrypted_passwd(self, user, password):
-        self.call(["/usr/sbin/usermod", "-p", "%s" % password, user])
-
-    def set_unencrypted_passwd(self, user, password):
-        for p in ("/bin/echo", "/usr/sbin/chpasswd"):
-            if not os.path.exists("%s/%s" %(self.instroot, p)):
-                raise errors.KsError("Unable to set unencrypted password due "
-                                     "to lack of %s" % p)
-
-        p1 = subprocess.Popen(["/bin/echo", "%s:%s" %(user, password)],
-                              stdout = subprocess.PIPE,
-                              preexec_fn = self.chroot)
-        p2 = subprocess.Popen(["/usr/sbin/chpasswd", "-m"],
-                              stdin = p1.stdout,
-                              stdout = subprocess.PIPE,
-                              preexec_fn = self.chroot)
-        p2.communicate()
-
-    def addUser(self, userconfig):
-        args = [ "/usr/sbin/useradd" ]
-        if userconfig.groups:
-            args += [ "--groups", string.join(userconfig.groups, ",") ]
-        if userconfig.name:
-            args += [ "-m"]
-            args += [ "-d", "/home/%s" % userconfig.name  ]
-            args.append(userconfig.name)
-            try:
-                dev_null = os.open("/dev/null", os.O_WRONLY)
-                msger.debug('adding user with %s' % args)
-                subprocess.call(args,
-                                 stdout = dev_null,
-                                 stderr = dev_null,
-                                 preexec_fn = self.chroot)
-                os.close(dev_null)
-            except:
-                msger.warning('Cannot add user using "useradd"')
-
-            if userconfig.password not in (None, ""):
-                if userconfig.isCrypted:
-                    self.set_encrypted_passwd(userconfig.name,
-                                              userconfig.password)
-                else:
-                    self.set_unencrypted_passwd(userconfig.name,
-                                                userconfig.password)
-            else:
-                self.set_empty_passwd(userconfig.name)
-        else:
-            raise errors.KsError("Invalid kickstart command: %s" \
-                                 % userconfig.__str__())
-
-    @apply_wrapper
-    def apply(self, user):
-        for userconfig in user.userList:
-            self.addUser(userconfig)
-
-class ServicesConfig(KickstartConfig):
-    """A class to apply a kickstart services configuration to a system."""
-    @apply_wrapper
-    def apply(self, ksservices):
-        if not os.path.exists(self.path("/sbin/chkconfig")):
-            return
-        for s in ksservices.enabled:
-            self.call(["/sbin/chkconfig", s, "on"])
-        for s in ksservices.disabled:
-            self.call(["/sbin/chkconfig", s, "off"])
-
-class XConfig(KickstartConfig):
-    """A class to apply a kickstart X configuration to a system."""
-    @apply_wrapper
-    def apply(self, ksxconfig):
-        if ksxconfig.startX and os.path.exists(self.path("/etc/inittab")):
-            f = open(self.path("/etc/inittab"), "rw+")
-            buf = f.read()
-            buf = buf.replace("id:3:initdefault", "id:5:initdefault")
-            f.seek(0)
-            f.write(buf)
-            f.close()
-        if ksxconfig.defaultdesktop:
-            self._check_sysconfig()
-            f = open(self.path("/etc/sysconfig/desktop"), "w")
-            f.write("DESKTOP="+ksxconfig.defaultdesktop+"\n")
-            f.close()
-
-class DesktopConfig(KickstartConfig):
-    """A class to apply a kickstart desktop configuration to a system."""
-    @apply_wrapper
-    def apply(self, ksdesktop):
-        if ksdesktop.defaultdesktop:
-            self._check_sysconfig()
-            f = open(self.path("/etc/sysconfig/desktop"), "w")
-            f.write("DESKTOP="+ksdesktop.defaultdesktop+"\n")
-            f.close()
-            if os.path.exists(self.path("/etc/gdm/custom.conf")):
-                f = open(self.path("/etc/skel/.dmrc"), "w")
-                f.write("[Desktop]\n")
-                f.write("Session="+ksdesktop.defaultdesktop.lower()+"\n")
-                f.close()
-        if ksdesktop.session:
-            if os.path.exists(self.path("/etc/sysconfig/uxlaunch")):
-                f = open(self.path("/etc/sysconfig/uxlaunch"), "a+")
-                f.write("session="+ksdesktop.session.lower()+"\n")
-                f.close()
-        if ksdesktop.autologinuser:
-            self._check_sysconfig()
-            f = open(self.path("/etc/sysconfig/desktop"), "a+")
-            f.write("AUTOLOGIN_USER=" + ksdesktop.autologinuser + "\n")
-            f.close()
-            if os.path.exists(self.path("/etc/gdm/custom.conf")):
-                f = open(self.path("/etc/gdm/custom.conf"), "w")
-                f.write("[daemon]\n")
-                f.write("AutomaticLoginEnable=true\n")
-                f.write("AutomaticLogin=" + ksdesktop.autologinuser + "\n")
-                f.close()
-
-class MoblinRepoConfig(KickstartConfig):
-    """A class to apply a kickstart desktop configuration to a system."""
-    def __create_repo_section(self, repo, type, fd):
-        baseurl = None
-        mirrorlist = None
-        reposuffix = {"base":"", "debuginfo":"-debuginfo", "source":"-source"}
-        reponame = repo.name + reposuffix[type]
-        if type == "base":
-            if repo.baseurl:
-                baseurl = repo.baseurl
-            if repo.mirrorlist:
-                mirrorlist = repo.mirrorlist
-
-        elif type == "debuginfo":
-            if repo.baseurl:
-                if repo.baseurl.endswith("/"):
-                    baseurl = os.path.dirname(os.path.dirname(repo.baseurl))
-                else:
-                    baseurl = os.path.dirname(repo.baseurl)
-                baseurl += "/debug"
-
-            if repo.mirrorlist:
-                variant = repo.mirrorlist[repo.mirrorlist.find("$"):]
-                mirrorlist = repo.mirrorlist[0:repo.mirrorlist.find("$")]
-                mirrorlist += "debug" + "-" + variant
-
-        elif type == "source":
-            if repo.baseurl:
-                if repo.baseurl.endswith("/"):
-                    baseurl = os.path.dirname(
-                                 os.path.dirname(
-                                    os.path.dirname(repo.baseurl)))
-                else:
-                    baseurl = os.path.dirname(os.path.dirname(repo.baseurl))
-                baseurl += "/source"
-
-            if repo.mirrorlist:
-                variant = repo.mirrorlist[repo.mirrorlist.find("$"):]
-                mirrorlist = repo.mirrorlist[0:repo.mirrorlist.find("$")]
-                mirrorlist += "source" + "-" + variant
-
-        fd.write("[" + reponame + "]\n")
-        fd.write("name=" + reponame + "\n")
-        fd.write("failovermethod=priority\n")
-        if baseurl:
-            auth_url = re.compile(AUTH_URL_PTN)
-            m = auth_url.match(baseurl)
-            if m:
-                baseurl = "%s://%s" % (m.group('scheme'), m.group('url'))
-            fd.write("baseurl=" + baseurl + "\n")
-        if mirrorlist:
-            fd.write("mirrorlist=" + mirrorlist + "\n")
-        """ Skip saving proxy settings """
-        #if repo.proxy:
-        #    fd.write("proxy=" + repo.proxy + "\n")
-        #if repo.proxy_username:
-        #    fd.write("proxy_username=" + repo.proxy_username + "\n")
-        #if repo.proxy_password:
-        #    fd.write("proxy_password=" + repo.proxy_password + "\n")
-        if repo.gpgkey:
-            fd.write("gpgkey=" + repo.gpgkey + "\n")
-            fd.write("gpgcheck=1\n")
-        else:
-            fd.write("gpgcheck=0\n")
-        if type == "source" or type == "debuginfo" or repo.disable:
-            fd.write("enabled=0\n")
-        else:
-            fd.write("enabled=1\n")
-        fd.write("\n")
-
-    def __create_repo_file(self, repo, repodir):
-        fs.makedirs(self.path(repodir))
-        f = open(self.path(repodir + "/" + repo.name + ".repo"), "w")
-        self.__create_repo_section(repo, "base", f)
-        if repo.debuginfo:
-            self.__create_repo_section(repo, "debuginfo", f)
-        if repo.source:
-            self.__create_repo_section(repo, "source", f)
-        f.close()
-
-    @apply_wrapper
-    def apply(self, ksrepo, repodata, repourl):
-        for repo in ksrepo.repoList:
-            if repo.name in repourl:
-                repo.baseurl = repourl[repo.name]
-            if repo.save:
-                #self.__create_repo_file(repo, "/etc/yum.repos.d")
-                self.__create_repo_file(repo, "/etc/zypp/repos.d")
-        """ Import repo gpg keys """
-        if repodata:
-            for repo in repodata:
-                if repo['repokey']:
-                    runner.quiet(['rpm',
-                                  "--root=%s" % self.instroot,
-                                  "--import",
-                                  repo['repokey']])
-
-class RPMMacroConfig(KickstartConfig):
-    """A class to apply the specified rpm macros to the filesystem"""
-    @apply_wrapper
-    def apply(self, ks):
-        if not ks:
-            return
-        if not os.path.exists(self.path("/etc/rpm")):
-            os.mkdir(self.path("/etc/rpm"))
-        f = open(self.path("/etc/rpm/macros.imgcreate"), "w+")
-        if exclude_docs(ks):
-            f.write("%_excludedocs 1\n")
-        f.write("%__file_context_path %{nil}\n")
-        if inst_langs(ks) != None:
-            f.write("%_install_langs ")
-            f.write(inst_langs(ks))
-            f.write("\n")
-        f.close()
-
-class NetworkConfig(KickstartConfig):
-    """A class to apply a kickstart network configuration to a system."""
-    def write_ifcfg(self, network):
-        p = self.path("/etc/sysconfig/network-scripts/ifcfg-" + network.device)
-
-        f = file(p, "w+")
-        os.chmod(p, 0644)
-
-        f.write("DEVICE=%s\n" % network.device)
-        f.write("BOOTPROTO=%s\n" % network.bootProto)
-
-        if network.bootProto.lower() == "static":
-            if network.ip:
-                f.write("IPADDR=%s\n" % network.ip)
-            if network.netmask:
-                f.write("NETMASK=%s\n" % network.netmask)
-
-        if network.onboot:
-            f.write("ONBOOT=on\n")
-        else:
-            f.write("ONBOOT=off\n")
-
-        if network.essid:
-            f.write("ESSID=%s\n" % network.essid)
-
-        if network.ethtool:
-            if network.ethtool.find("autoneg") == -1:
-                network.ethtool = "autoneg off " + network.ethtool
-            f.write("ETHTOOL_OPTS=%s\n" % network.ethtool)
-
-        if network.bootProto.lower() == "dhcp":
-            if network.hostname:
-                f.write("DHCP_HOSTNAME=%s\n" % network.hostname)
-            if network.dhcpclass:
-                f.write("DHCP_CLASSID=%s\n" % network.dhcpclass)
-
-        if network.mtu:
-            f.write("MTU=%s\n" % network.mtu)
-
-        f.close()
-
-    def write_wepkey(self, network):
-        if not network.wepkey:
-            return
-
-        p = self.path("/etc/sysconfig/network-scripts/keys-" + network.device)
-        f = file(p, "w+")
-        os.chmod(p, 0600)
-        f.write("KEY=%s\n" % network.wepkey)
-        f.close()
-
-    def write_sysconfig(self, useipv6, hostname, gateway):
-        path = self.path("/etc/sysconfig/network")
-        f = file(path, "w+")
-        os.chmod(path, 0644)
-
-        f.write("NETWORKING=yes\n")
-
-        if useipv6:
-            f.write("NETWORKING_IPV6=yes\n")
-        else:
-            f.write("NETWORKING_IPV6=no\n")
-
-        if hostname:
-            f.write("HOSTNAME=%s\n" % hostname)
-        else:
-            f.write("HOSTNAME=localhost.localdomain\n")
-
-        if gateway:
-            f.write("GATEWAY=%s\n" % gateway)
-
-        f.close()
-
-    def write_hosts(self, hostname):
-        localline = ""
-        if hostname and hostname != "localhost.localdomain":
-            localline += hostname + " "
-            l = hostname.split(".")
-            if len(l) > 1:
-                localline += l[0] + " "
-        localline += "localhost.localdomain localhost"
-
-        path = self.path("/etc/hosts")
-        f = file(path, "w+")
-        os.chmod(path, 0644)
-        f.write("127.0.0.1\t\t%s\n" % localline)
-        f.write("::1\t\tlocalhost6.localdomain6 localhost6\n")
-        f.close()
-
-    def write_resolv(self, nodns, nameservers):
-        if nodns or not nameservers:
-            return
-
-        path = self.path("/etc/resolv.conf")
-        f = file(path, "w+")
-        os.chmod(path, 0644)
-
-        for ns in (nameservers):
-            if ns:
-                f.write("nameserver %s\n" % ns)
-
-        f.close()
-
-    @apply_wrapper
-    def apply(self, ksnet):
-        fs.makedirs(self.path("/etc/sysconfig/network-scripts"))
-
-        useipv6 = False
-        nodns = False
-        hostname = None
-        gateway = None
-        nameservers = None
-
-        for network in ksnet.network:
-            if not network.device:
-                raise errors.KsError("No --device specified with "
-                                            "network kickstart command")
-
-            if (network.onboot and network.bootProto.lower() != "dhcp" and
-                not (network.ip and network.netmask)):
-                raise errors.KsError("No IP address and/or netmask "
-                                            "specified with static "
-                                            "configuration for '%s'" %
-                                            network.device)
-
-            self.write_ifcfg(network)
-            self.write_wepkey(network)
-
-            if network.ipv6:
-                useipv6 = True
-            if network.nodns:
-                nodns = True
-
-            if network.hostname:
-                hostname = network.hostname
-            if network.gateway:
-                gateway = network.gateway
-
-            if network.nameserver:
-                nameservers = network.nameserver.split(",")
-
-        self.write_sysconfig(useipv6, hostname, gateway)
-        self.write_hosts(hostname)
-        self.write_resolv(nodns, nameservers)
-
-def use_installerfw(ks, feature):
-    """ Check if the installer framework has to be used for a feature
-    "feature". """
-
-    features = ks.handler.installerfw.features
-    if features:
-        if feature in features or "all" in features:
-            return True
-    return False
-
 def get_image_size(ks, default = None):
     __size = 0
     for p in ks.handler.partition.partitions:
@@ -665,21 +93,6 @@ def get_image_fsopts(ks, default = None):
             return p.fsopts
     return default
 
-def get_modules(ks):
-    devices = []
-    if isinstance(ks.handler.device, kscommands.device.FC3_Device):
-        devices.append(ks.handler.device)
-    else:
-        devices.extend(ks.handler.device.deviceList)
-
-    modules = []
-    for device in devices:
-        if not device.moduleName:
-            continue
-        modules.extend(device.moduleName.split(":"))
-
-    return modules
-
 def get_timeout(ks, default = None):
     if not hasattr(ks.handler.bootloader, "timeout"):
         return default
@@ -708,181 +121,5 @@ def get_default_kernel(ks, default = None):
         return default
     return ks.handler.bootloader.default
 
-def get_repos(ks, repo_urls=None):
-    repos = {}
-    for repo in ks.handler.repo.repoList:
-        inc = []
-        if hasattr(repo, "includepkgs"):
-            inc.extend(repo.includepkgs)
-
-        exc = []
-        if hasattr(repo, "excludepkgs"):
-            exc.extend(repo.excludepkgs)
-
-        baseurl = repo.baseurl
-        mirrorlist = repo.mirrorlist
-
-        if repo_urls and repo.name in repo_urls:
-            baseurl = repo_urls[repo.name]
-            mirrorlist = None
-
-        if repos.has_key(repo.name):
-            msger.warning("Overriding already specified repo %s" %(repo.name,))
-
-        proxy = None
-        if hasattr(repo, "proxy"):
-            proxy = repo.proxy
-        proxy_username = None
-        if hasattr(repo, "proxy_username"):
-            proxy_username = repo.proxy_username
-        proxy_password = None
-        if hasattr(repo, "proxy_password"):
-            proxy_password = repo.proxy_password
-        if hasattr(repo, "debuginfo"):
-            debuginfo = repo.debuginfo
-        if hasattr(repo, "source"):
-            source = repo.source
-        if hasattr(repo, "gpgkey"):
-            gpgkey = repo.gpgkey
-        if hasattr(repo, "disable"):
-            disable = repo.disable
-        ssl_verify = True
-        if hasattr(repo, "ssl_verify"):
-            ssl_verify = repo.ssl_verify == "yes"
-        nocache = False
-        if hasattr(repo, "nocache"):
-            nocache = repo.nocache
-        cost = None
-        if hasattr(repo, "cost"):
-            cost = repo.cost
-        priority = None
-        if hasattr(repo, "priority"):
-            priority = repo.priority
-
-        repos[repo.name] = (repo.name, baseurl, mirrorlist, inc, exc,
-                            proxy, proxy_username, proxy_password, debuginfo,
-                            source, gpgkey, disable, ssl_verify, nocache,
-                            cost, priority)
-
-    return repos.values()
-
-def convert_method_to_repo(ks):
-    try:
-        ks.handler.repo.methodToRepo()
-    except (AttributeError, kserrors.KickstartError):
-        pass
-
-def get_attachment(ks, required=()):
-    return ks.handler.attachment.packageList + list(required)
-
-def get_pre_packages(ks, required=()):
-    return ks.handler.prepackages.packageList + list(required)
-
-def get_packages(ks, required=()):
-    return ks.handler.packages.packageList + list(required)
-
-def get_groups(ks, required=()):
-    return ks.handler.packages.groupList + list(required)
-
-def get_excluded(ks, required=()):
-    return ks.handler.packages.excludedList + list(required)
-
 def get_partitions(ks):
     return ks.handler.partition.partitions
-
-def ignore_missing(ks):
-    return ks.handler.packages.handleMissing == ksconstants.KS_MISSING_IGNORE
-
-def exclude_docs(ks):
-    return ks.handler.packages.excludeDocs
-
-def inst_langs(ks):
-    if hasattr(ks.handler.packages, "instLange"):
-        return ks.handler.packages.instLange
-    elif hasattr(ks.handler.packages, "instLangs"):
-        return ks.handler.packages.instLangs
-    return ""
-
-def get_post_scripts(ks):
-    scripts = []
-    for s in ks.handler.scripts:
-        if s.type != ksparser.KS_SCRIPT_POST:
-            continue
-        scripts.append(s)
-    return scripts
-
-def add_repo(ks, repostr):
-    args = repostr.split()
-    repoobj = ks.handler.repo.parse(args[1:])
-    if repoobj and repoobj not in ks.handler.repo.repoList:
-        ks.handler.repo.repoList.append(repoobj)
-
-def remove_all_repos(ks):
-    while len(ks.handler.repo.repoList) != 0:
-        del ks.handler.repo.repoList[0]
-
-def remove_duplicate_repos(ks):
-    i = 0
-    j = i + 1
-    while True:
-        if len(ks.handler.repo.repoList) < 2:
-            break
-        if i >= len(ks.handler.repo.repoList) - 1:
-            break
-        name = ks.handler.repo.repoList[i].name
-        baseurl = ks.handler.repo.repoList[i].baseurl
-        if j < len(ks.handler.repo.repoList):
-            if (ks.handler.repo.repoList[j].name == name or \
-                ks.handler.repo.repoList[j].baseurl == baseurl):
-                del ks.handler.repo.repoList[j]
-            else:
-                j += 1
-            if j >= len(ks.handler.repo.repoList):
-                i += 1
-                j = i + 1
-        else:
-            i += 1
-            j = i + 1
-
-def resolve_groups(creatoropts, repometadata):
-    iszypp = False
-    if 'zypp' == creatoropts['pkgmgr']:
-        iszypp = True
-    ks = creatoropts['ks']
-
-    for repo in repometadata:
-        """ Mustn't replace group with package list if repo is ready for the
-            corresponding package manager.
-        """
-
-        if iszypp and repo["patterns"]:
-            continue
-        if not iszypp and repo["comps"]:
-            continue
-
-        # But we also must handle such cases, use zypp but repo only has comps,
-        # use yum but repo only has patterns, use zypp but use_comps is true,
-        # use yum but use_comps is false.
-        groupfile = None
-        if iszypp and repo["comps"]:
-            groupfile = repo["comps"]
-            get_pkglist_handler = misc.get_pkglist_in_comps
-        if not iszypp and repo["patterns"]:
-            groupfile = repo["patterns"]
-            get_pkglist_handler = misc.get_pkglist_in_patterns
-
-        if groupfile:
-            i = 0
-            while True:
-                if i >= len(ks.handler.packages.groupList):
-                    break
-                pkglist = get_pkglist_handler(
-                                        ks.handler.packages.groupList[i].name,
-                                        groupfile)
-                if pkglist:
-                    del ks.handler.packages.groupList[i]
-                    for pkg in pkglist:
-                        if pkg not in ks.handler.packages.packageList:
-                            ks.handler.packages.packageList.append(pkg)
-                else:
-                    i = i + 1
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH 4/35 wic: Remove mic bootstrap

In reply to Tom Zanussi

packaging bootstrap, not needed

---
 scripts/lib/mic/bootstrap.py | 279 -------------------------------------------
 1 file changed, 279 deletions(-)
 delete mode 100644 scripts/lib/mic/bootstrap.py
scripts/lib/mic/bootstrap.py deleted +0 -279
deleted file mode 100644
index 66c291b..0000000
@@ -1,279 +0,0 @@
-#!/usr/bin/python -tt
-#
-# Copyright (c) 2009, 2010, 2011 Intel, Inc.
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the Free
-# Software Foundation; version 2 of the License
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc., 59
-# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-from __future__ import with_statement
-import os
-import sys
-import tempfile
-import shutil
-import subprocess
-import rpm
-from mic import msger
-from mic.utils import errors, proxy, misc
-from mic.utils.rpmmisc import readRpmHeader, RPMInstallCallback
-from mic.chroot import cleanup_mounts, setup_chrootenv, cleanup_chrootenv
-
-PATH_BOOTSTRAP = "/usr/sbin:/usr/bin:/sbin:/bin"
-
-RPMTRANS_FLAGS = [
-                   rpm.RPMTRANS_FLAG_ALLFILES,
-                   rpm.RPMTRANS_FLAG_NOSCRIPTS,
-                   rpm.RPMTRANS_FLAG_NOTRIGGERS,
-                 ]
-
-RPMVSF_FLAGS = [
-                 rpm._RPMVSF_NOSIGNATURES,
-                 rpm._RPMVSF_NODIGESTS
-               ]
-
-RPMPROB_FLAGS = [
-                  rpm.RPMPROB_FILTER_OLDPACKAGE,
-                  rpm.RPMPROB_FILTER_REPLACEPKG,
-                  rpm.RPMPROB_FILTER_IGNOREARCH
-                ]
-
-class MiniBackend(object):
-    def __init__(self, rootdir, arch=None, repomd=None):
-        self._ts = None
-        self.rootdir = os.path.abspath(rootdir)
-        self.arch = arch
-        self.repomd = repomd
-        self.dlpkgs = []
-        self.localpkgs = {}
-        self.optionals = []
-        self.preins = {}
-        self.postins = {}
-        self.scriptlets = False
-
-    def __del__(self):
-        try:
-            del self.ts
-        except:
-            pass
-
-    def get_ts(self):
-        if not self._ts:
-            self._ts = rpm.TransactionSet(self.rootdir)
-            self._ts.setFlags(reduce(lambda x, y: x|y, RPMTRANS_FLAGS))
-            self._ts.setVSFlags(reduce(lambda x, y: x|y, RPMVSF_FLAGS))
-            self._ts.setProbFilter(reduce(lambda x, y: x|y, RPMPROB_FLAGS))
-
-        return self._ts
-
-    def del_ts(self):
-        if self._ts:
-            self._ts.closeDB()
-            self._ts = None
-
-    ts = property(fget = lambda self: self.get_ts(),
-                  fdel = lambda self: self.del_ts(),
-                  doc="TransactionSet object")
-
-    def selectPackage(self, pkg):
-        if not pkg in self.dlpkgs:
-            self.dlpkgs.append(pkg)
-
-    def runInstall(self):
-        # FIXME: check space
-        self.downloadPkgs()
-        self.installPkgs()
-
-        if not self.scriptlets:
-            return
-
-        for pkg in self.preins.keys():
-            prog, script = self.preins[pkg]
-            self.run_pkg_script(pkg, prog, script, '0')
-        for pkg in self.postins.keys():
-            prog, script = self.postins[pkg]
-            self.run_pkg_script(pkg, prog, script, '1')
-
-    def downloadPkgs(self):
-        nonexist = []
-        for pkg in self.dlpkgs:
-            localpth = misc.get_package(pkg, self.repomd, self.arch)
-            if localpth:
-                self.localpkgs[pkg] = localpth
-            elif pkg in self.optionals:
-                # skip optional rpm
-                continue
-            else:
-                # mark nonexist rpm
-                nonexist.append(pkg)
-
-        if nonexist:
-            raise errors.BootstrapError("Can't get rpm binary: %s" %
-                                        ','.join(nonexist))
-
-    def installPkgs(self):
-        for pkg in self.localpkgs.keys():
-            rpmpath = self.localpkgs[pkg]
-
-            hdr = readRpmHeader(self.ts, rpmpath)
-
-            # save prein and postin scripts
-            self.preins[pkg] = (hdr['PREINPROG'], hdr['PREIN'])
-            self.postins[pkg] = (hdr['POSTINPROG'], hdr['POSTIN'])
-
-            # mark pkg as install
-            self.ts.addInstall(hdr, rpmpath, 'u')
-
-        # run transaction
-        self.ts.order()
-        cb = RPMInstallCallback(self.ts)
-        self.ts.run(cb.callback, '')
-
-    def run_pkg_script(self, pkg, prog, script, arg):
-        mychroot = lambda: os.chroot(self.rootdir)
-
-        if not script:
-            return
-
-        if prog == "<lua>":
-            prog = "/usr/bin/lua"
-
-        tmpdir = os.path.join(self.rootdir, "tmp")
-        if not os.path.exists(tmpdir):
-            os.makedirs(tmpdir)
-        tmpfd, tmpfp = tempfile.mkstemp(dir=tmpdir, prefix="%s.pre-" % pkg)
-        script = script.replace('\r', '')
-        os.write(tmpfd, script)
-        os.close(tmpfd)
-        os.chmod(tmpfp, 0700)
-
-        try:
-            script_fp = os.path.join('/tmp', os.path.basename(tmpfp))
-            subprocess.call([prog, script_fp, arg], preexec_fn=mychroot)
-        except (OSError, IOError), err:
-            msger.warning(str(err))
-        finally:
-            os.unlink(tmpfp)
-
-class Bootstrap(object):
-    def __init__(self, rootdir, distro, arch=None):
-        self.rootdir = misc.mkdtemp(dir=rootdir, prefix=distro)
-        self.distro = distro
-        self.arch = arch
-        self.logfile = None
-        self.pkgslist = []
-        self.repomd = None
-
-    def __del__(self):
-        self.cleanup()
-
-    def get_rootdir(self):
-        if os.path.exists(self.rootdir):
-            shutil.rmtree(self.rootdir, ignore_errors=True)
-        os.makedirs(self.rootdir)
-        return self.rootdir
-
-    def dirsetup(self, rootdir=None):
-        _path = lambda pth: os.path.join(rootdir, pth.lstrip('/'))
-
-        if not rootdir:
-            rootdir = self.rootdir
-
-        try:
-            # make /tmp and /etc path
-            tmpdir = _path('/tmp')
-            if not os.path.exists(tmpdir):
-                os.makedirs(tmpdir)
-            etcdir = _path('/etc')
-            if not os.path.exists(etcdir):
-                os.makedirs(etcdir)
-
-            # touch distro file
-            tzdist = _path('/etc/%s-release' % self.distro)
-            if not os.path.exists(tzdist):
-                with open(tzdist, 'w') as wf:
-                    wf.write("bootstrap")
-        except:
-            pass
-
-    def create(self, repomd, pkglist, optlist=()):
-        try:
-            pkgmgr = MiniBackend(self.get_rootdir())
-            pkgmgr.arch = self.arch
-            pkgmgr.repomd = repomd
-            pkgmgr.optionals = list(optlist)
-            map(pkgmgr.selectPackage, pkglist + list(optlist))
-            pkgmgr.runInstall()
-        except (OSError, IOError, errors.CreatorError), err:
-            raise errors.BootstrapError("%s" % err)
-
-    def run(self, cmd, chdir, rootdir=None, bindmounts=None):
-        def mychroot():
-            os.chroot(rootdir)
-            os.chdir(chdir)
-
-        def sync_timesetting(rootdir):
-            try:
-                # sync time and zone info to bootstrap
-                if os.path.exists(rootdir + "/etc/localtime"):
-                    os.unlink(rootdir + "/etc/localtime")
-                shutil.copyfile("/etc/localtime", rootdir + "/etc/localtime")
-            except:
-                pass
-
-        def sync_passwdfile(rootdir):
-            try:
-                # sync passwd file to bootstrap, saving the user info
-                if os.path.exists(rootdir + "/etc/passwd"):
-                    os.unlink(rootdir + "/etc/passwd")
-                shutil.copyfile("/etc/passwd", rootdir + "/etc/passwd")
-            except:
-                pass
-
-        if not rootdir:
-            rootdir = self.rootdir
-
-        if isinstance(cmd, list):
-            shell = False
-        else:
-            shell = True
-
-        env = os.environ
-        env['PATH'] = "%s:%s" % (PATH_BOOTSTRAP, env['PATH'])
-
-        retcode = 0
-        gloablmounts = None
-        try:
-            proxy.set_proxy_environ()
-            gloablmounts = setup_chrootenv(rootdir, bindmounts, False)
-            sync_timesetting(rootdir)
-            sync_passwdfile(rootdir)
-            retcode = subprocess.call(cmd, preexec_fn=mychroot, env=env, shell=shell)
-        except (OSError, IOError):
-            # add additional information to original exception
-            value, tb = sys.exc_info()[1:]
-            value = '%s: %s' % (value, ' '.join(cmd))
-            raise RuntimeError, value, tb
-        finally:
-            if self.logfile and os.path.isfile(self.logfile):
-                msger.log(file(self.logfile).read())
-            cleanup_chrootenv(rootdir, bindmounts, gloablmounts)
-            proxy.unset_proxy_environ()
-        return retcode
-
-    def cleanup(self):
-        try:
-            # clean mounts
-            cleanup_mounts(self.rootdir)
-            # remove rootdir
-            shutil.rmtree(self.rootdir, ignore_errors=True)
-        except:
-            pass
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH 5/35 wic: Remove mic chroot

In reply to Tom Zanussi

mic chroot allows users to chroot into an existing mic image and isn't used by wic, so remove it.

Removing chroot.py leads in turn to various plugin-loading failures for a number of plugins that wic doesn't use either, so remove those as well.

The existing source plugins refer to chroot but don't use it, so fix those up.

---
 scripts/lib/mic/chroot.py                        | 343 -----------
 scripts/lib/mic/imager/fs.py                     |  99 ---
 scripts/lib/mic/imager/livecd.py                 | 750 -----------------------
 scripts/lib/mic/imager/liveusb.py                | 308 ----------
 scripts/lib/mic/imager/loop.py                   | 418 -------------
 scripts/lib/mic/imager/raw.py                    | 501 ---------------
 scripts/lib/mic/plugins/imager/direct_plugin.py  |   2 +-
 scripts/lib/mic/plugins/imager/fs_plugin.py      | 143 -----
 scripts/lib/mic/plugins/imager/livecd_plugin.py  | 255 --------
 scripts/lib/mic/plugins/imager/liveusb_plugin.py | 260 --------
 scripts/lib/mic/plugins/imager/loop_plugin.py    | 255 --------
 scripts/lib/mic/plugins/imager/raw_plugin.py     | 275 ---------
 scripts/lib/mic/plugins/source/bootimg-efi.py    |   2 +-
 scripts/lib/mic/plugins/source/bootimg-pcbios.py |   2 +-
 scripts/lib/mic/plugins/source/rootfs.py         |   2 +-
 15 files changed, 4 insertions(+), 3611 deletions(-)
 delete mode 100644 scripts/lib/mic/chroot.py
 delete mode 100644 scripts/lib/mic/imager/fs.py
 delete mode 100644 scripts/lib/mic/imager/livecd.py
 delete mode 100644 scripts/lib/mic/imager/liveusb.py
 delete mode 100644 scripts/lib/mic/imager/loop.py
 delete mode 100644 scripts/lib/mic/imager/raw.py
 delete mode 100644 scripts/lib/mic/plugins/imager/fs_plugin.py
 delete mode 100644 scripts/lib/mic/plugins/imager/livecd_plugin.py
 delete mode 100644 scripts/lib/mic/plugins/imager/liveusb_plugin.py
 delete mode 100644 scripts/lib/mic/plugins/imager/loop_plugin.py
 delete mode 100644 scripts/lib/mic/plugins/imager/raw_plugin.py

Patch too large to post - see git repository.

Signature · 1 line
1.8.3.1
#6 lore raw

PATCH 6/35 wic: Remove rt_util

In reply to Tom Zanussi

More package-related stuff we don't need.

---
 scripts/lib/mic/rt_util.py | 223 ---------------------------------------------
 1 file changed, 223 deletions(-)
 delete mode 100644 scripts/lib/mic/rt_util.py
scripts/lib/mic/rt_util.py deleted +0 -223
deleted file mode 100644
index 2a31f4a..0000000
@@ -1,223 +0,0 @@
-#!/usr/bin/python -tt
-#
-# Copyright (c) 2009, 2010, 2011 Intel, Inc.
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the Free
-# Software Foundation; version 2 of the License
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc., 59
-# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-from __future__ import with_statement
-import os
-import sys
-import glob
-import re
-import shutil
-import subprocess
-
-from mic import bootstrap, msger
-from mic.conf import configmgr
-from mic.utils import errors, proxy
-from mic.utils.fs_related import find_binary_path, makedirs
-from mic.chroot import setup_chrootenv, cleanup_chrootenv
-
-expath = lambda p: os.path.abspath(os.path.expanduser(p))
-
-def bootstrap_mic(argv=None):
-
-
-    def mychroot():
-        os.chroot(rootdir)
-        os.chdir(cwd)
-
-    # by default, sys.argv is used to run mic in bootstrap
-    if not argv:
-        argv = sys.argv
-    if argv[0] not in ('/usr/bin/mic', 'mic'):
-        argv[0] = '/usr/bin/mic'
-
-    cropts = configmgr.create
-    bsopts = configmgr.bootstrap
-    distro = bsopts['distro_name'].lower()
-
-    rootdir = bsopts['rootdir']
-    pkglist = bsopts['packages']
-    cwd = os.getcwd()
-
-    # create bootstrap and run mic in bootstrap
-    bsenv = bootstrap.Bootstrap(rootdir, distro, cropts['arch'])
-    bsenv.logfile = cropts['logfile']
-    # rootdir is regenerated as a temp dir
-    rootdir = bsenv.rootdir
-
-    if 'optional' in bsopts:
-        optlist = bsopts['optional']
-    else:
-        optlist = []
-
-    try:
-        msger.info("Creating %s bootstrap ..." % distro)
-        bsenv.create(cropts['repomd'], pkglist, optlist)
-
-        # bootstrap is relocated under "bootstrap"
-        if os.path.exists(os.path.join(rootdir, "bootstrap")):
-            rootdir = os.path.join(rootdir, "bootstrap")
-
-        bsenv.dirsetup(rootdir)
-        sync_mic(rootdir)
-
-        #FIXME: sync the ks file to bootstrap
-        if "/" == os.path.dirname(os.path.abspath(configmgr._ksconf)):
-            safecopy(configmgr._ksconf, rootdir)
-
-        msger.info("Start mic in bootstrap: %s\n" % rootdir)
-        bindmounts = get_bindmounts(cropts)
-        ret = bsenv.run(argv, cwd, rootdir, bindmounts)
-
-    except errors.BootstrapError, err:
-        msger.warning('\n%s' % err)
-        if msger.ask("Switch to native mode and continue?"):
-            return
-        raise
-    except RuntimeError, err:
-        #change exception type but keep the trace back
-        value, tb = sys.exc_info()[1:]
-        raise errors.BootstrapError, value, tb
-    else:
-        sys.exit(ret)
-    finally:
-        bsenv.cleanup()
-
-def get_bindmounts(cropts):
-    binddirs =  [
-                  os.getcwd(),
-                  cropts['tmpdir'],
-                  cropts['cachedir'],
-                  cropts['outdir'],
-                  cropts['local_pkgs_path'],
-                ]
-    bindfiles = [
-                  cropts['logfile'],
-                  configmgr._ksconf,
-                ]
-
-    for lrepo in cropts['localrepos']:
-        binddirs.append(lrepo)
-
-    bindlist = map(expath, filter(None, binddirs))
-    bindlist += map(os.path.dirname, map(expath, filter(None, bindfiles)))
-    bindlist = sorted(set(bindlist))
-    bindmounts = ';'.join(bindlist)
-    return bindmounts
-
-
-def get_mic_binpath():
-    fp = None
-    try:
-        import pkg_resources # depends on 'setuptools'
-    except ImportError:
-        pass
-    else:
-        dist = pkg_resources.get_distribution('mic')
-        # the real script is under EGG_INFO/scripts
-        if dist.has_metadata('scripts/mic'):
-            fp = os.path.join(dist.egg_info, "scripts/mic")
-
-    if fp:
-        return fp
-
-    # not found script if 'flat' egg installed
-    try:
-        return find_binary_path('mic')
-    except errors.CreatorError:
-        raise errors.BootstrapError("Can't find mic binary in host OS")
-
-
-def get_mic_modpath():
-    try:
-        import mic
-    except ImportError:
-        raise errors.BootstrapError("Can't find mic module in host OS")
-    path = os.path.abspath(mic.__file__)
-    return os.path.dirname(path)
-
-def get_mic_libpath():
-    # TBD: so far mic lib path is hard coded
-    return "/usr/lib/mic"
-
-# the hard code path is prepared for bootstrap
-def sync_mic(bootstrap, binpth = '/usr/bin/mic',
-             libpth='/usr/lib',
-             pylib = '/usr/lib/python2.7/site-packages',
-             conf = '/etc/mic/mic.conf'):
-    _path = lambda p: os.path.join(bootstrap, p.lstrip('/'))
-
-    micpaths = {
-                 'binpth': get_mic_binpath(),
-                 'libpth': get_mic_libpath(),
-                 'pylib': get_mic_modpath(),
-                 'conf': '/etc/mic/mic.conf',
-               }
-
-    if not os.path.exists(_path(pylib)):
-        pyptn = '/usr/lib/python?.?/site-packages'
-        pylibs = glob.glob(_path(pyptn))
-        if pylibs:
-            pylib = pylibs[0].replace(bootstrap, '')
-        else:
-            raise errors.BootstrapError("Can't find python site dir in: %s" %
-                                        bootstrap)
-
-    for key, value in micpaths.items():
-        try:
-            safecopy(value, _path(eval(key)), False, ["*.pyc", "*.pyo"])
-        except (OSError, IOError), err:
-            raise errors.BootstrapError(err)
-
-    # auto select backend
-    conf_str = file(_path(conf)).read()
-    conf_str = re.sub("pkgmgr\s*=\s*.*", "pkgmgr=auto", conf_str)
-    with open(_path(conf), 'w') as wf:
-        wf.write(conf_str)
-
-    # chmod +x /usr/bin/mic
-    os.chmod(_path(binpth), 0777)
-
-    # correct python interpreter
-    mic_cont = file(_path(binpth)).read()
-    mic_cont = "#!/usr/bin/python\n" + mic_cont
-    with open(_path(binpth), 'w') as wf:
-        wf.write(mic_cont)
-
-
-def safecopy(src, dst, symlinks=False, ignore_ptns=()):
-    if os.path.isdir(src):
-        if os.path.isdir(dst):
-            dst = os.path.join(dst, os.path.basename(src))
-        if os.path.exists(dst):
-            shutil.rmtree(dst, ignore_errors=True)
-
-        src = src.rstrip('/')
-        # check common prefix to ignore copying itself
-        if dst.startswith(src + '/'):
-            ignore_ptns = list(ignore_ptns) + [ os.path.basename(src) ]
-
-        ignores = shutil.ignore_patterns(*ignore_ptns)
-        try:
-            shutil.copytree(src, dst, symlinks, ignores)
-        except (OSError, IOError):
-            shutil.rmtree(dst, ignore_errors=True)
-            raise
-    else:
-        if not os.path.isdir(dst):
-            makedirs(os.path.dirname(dst))
-
-        shutil.copy2(src, dst)
Signature · 1 line
1.8.3.1
#7 lore raw

PATCH 7/35 wic: Remove mic package managers

In reply to Tom Zanussi

wic doesn't use the yum or zypp package managers, remove them.

---
 scripts/lib/mic/plugins/backend/yumpkgmgr.py  | 490 -------------
 scripts/lib/mic/plugins/backend/zypppkgmgr.py | 973 --------------------------
 2 files changed, 1463 deletions(-)
 delete mode 100644 scripts/lib/mic/plugins/backend/yumpkgmgr.py
 delete mode 100755 scripts/lib/mic/plugins/backend/zypppkgmgr.py

Patch too large to post - see git repository.

Signature · 1 line
1.8.3.1
#8 lore raw

PATCH 8/35 wic: Remove bmap support

In reply to Tom Zanussi

wic doesn't use it, so remove it.

---
 scripts/lib/mic/utils/BmapCreate.py | 298 ------------------------------------
 1 file changed, 298 deletions(-)
 delete mode 100644 scripts/lib/mic/utils/BmapCreate.py
scripts/lib/mic/utils/BmapCreate.py deleted +0 -298
deleted file mode 100644
index 65b19a5..0000000
@@ -1,298 +0,0 @@
-""" This module implements the block map (bmap) creation functionality and
-provides the corresponding API in form of the 'BmapCreate' class.
-
-The idea is that while images files may generally be very large (e.g., 4GiB),
-they may nevertheless contain only little real data, e.g., 512MiB. This data
-are files, directories, file-system meta-data, partition table, etc. When
-copying the image to the target device, you do not have to copy all the 4GiB of
-data, you can copy only 512MiB of it, which is 4 times less, so copying should
-presumably be 4 times faster.
-
-The block map file is an XML file which contains a list of blocks which have to
-be copied to the target device. The other blocks are not used and there is no
-need to copy them. The XML file also contains some additional information like
-block size, image size, count of mapped blocks, etc. There are also many
-commentaries, so it is human-readable.
-
-The image has to be a sparse file. Generally, this means that when you generate
-this image file, you should start with a huge sparse file which contains a
-single hole spanning the entire file. Then you should partition it, write all
-the data (probably by means of loop-back mounting the image or parts of it),
-etc. The end result should be a sparse file where mapped areas represent useful
-parts of the image and holes represent useless parts of the image, which do not
-have to be copied when copying the image to the target device.
-
-This module uses the FIBMAP ioctl to detect holes. """
-
-# Disable the following pylint recommendations:
-#   *  Too many instance attributes - R0902
-#   *  Too few public methods - R0903
-# pylint: disable=R0902,R0903
-
-import hashlib
-from mic.utils.misc import human_size
-from mic.utils import Fiemap
-
-# The bmap format version we generate
-SUPPORTED_BMAP_VERSION = "1.3"
-
-_BMAP_START_TEMPLATE = \
-"""<?xml version="1.0" ?>
-<!-- This file contains the block map for an image file, which is basically
-     a list of useful (mapped) block numbers in the image file. In other words,
-     it lists only those blocks which contain data (boot sector, partition
-     table, file-system metadata, files, directories, extents, etc). These
-     blocks have to be copied to the target device. The other blocks do not
-     contain any useful data and do not have to be copied to the target
-     device.
-
-     The block map an optimization which allows to copy or flash the image to
-     the image quicker than copying of flashing the entire image. This is
-     because with bmap less data is copied: <MappedBlocksCount> blocks instead
-     of <BlocksCount> blocks.
-
-     Besides the machine-readable data, this file contains useful commentaries
-     which contain human-readable information like image size, percentage of
-     mapped data, etc.
-
-     The 'version' attribute is the block map file format version in the
-     'major.minor' format. The version major number is increased whenever an
-     incompatible block map format change is made. The minor number changes
-     in case of minor backward-compatible changes. -->
-
-<bmap version="%s">
-    <!-- Image size in bytes: %s -->
-    <ImageSize> %u </ImageSize>
-
-    <!-- Size of a block in bytes -->
-    <BlockSize> %u </BlockSize>
-
-    <!-- Count of blocks in the image file -->
-    <BlocksCount> %u </BlocksCount>
-
-"""
-
-class Error(Exception):
-    """ A class for exceptions generated by this module. We currently support
-    only one type of exceptions, and we basically throw human-readable problem
-    description in case of errors. """
-    pass
-
-class BmapCreate:
-    """ This class implements the bmap creation functionality. To generate a
-    bmap for an image (which is supposedly a sparse file), you should first
-    create an instance of 'BmapCreate' and provide:
-
-    * full path or a file-like object of the image to create bmap for
-    * full path or a file object to use for writing the results to
-
-    Then you should invoke the 'generate()' method of this class. It will use
-    the FIEMAP ioctl to generate the bmap. """
-
-    def _open_image_file(self):
-        """ Open the image file. """
-
-        try:
-            self._f_image = open(self._image_path, 'rb')
-        except IOError as err:
-            raise Error("cannot open image file '%s': %s" \
-                        % (self._image_path, err))
-
-        self._f_image_needs_close = True
-
-    def _open_bmap_file(self):
-        """ Open the bmap file. """
-
-        try:
-            self._f_bmap = open(self._bmap_path, 'w+')
-        except IOError as err:
-            raise Error("cannot open bmap file '%s': %s" \
-                        % (self._bmap_path, err))
-
-        self._f_bmap_needs_close = True
-
-    def __init__(self, image, bmap):
-        """ Initialize a class instance:
-        * image - full path or a file-like object of the image to create bmap
-                  for
-        * bmap  - full path or a file object to use for writing the resulting
-                  bmap to """
-
-        self.image_size = None
-        self.image_size_human = None
-        self.block_size = None
-        self.blocks_cnt = None
-        self.mapped_cnt = None
-        self.mapped_size = None
-        self.mapped_size_human = None
-        self.mapped_percent = None
-
-        self._mapped_count_pos1 = None
-        self._mapped_count_pos2 = None
-        self._sha1_pos = None
-
-        self._f_image_needs_close = False
-        self._f_bmap_needs_close = False
-
-        if hasattr(image, "read"):
-            self._f_image = image
-            self._image_path = image.name
-        else:
-            self._image_path = image
-            self._open_image_file()
-
-        if hasattr(bmap, "read"):
-            self._f_bmap = bmap
-            self._bmap_path = bmap.name
-        else:
-            self._bmap_path = bmap
-            self._open_bmap_file()
-
-        self.fiemap = Fiemap.Fiemap(self._f_image)
-
-        self.image_size = self.fiemap.image_size
-        self.image_size_human = human_size(self.image_size)
-        if self.image_size == 0:
-            raise Error("cannot generate bmap for zero-sized image file '%s'" \
-                        % self._image_path)
-
-        self.block_size = self.fiemap.block_size
-        self.blocks_cnt = self.fiemap.blocks_cnt
-
-    def _bmap_file_start(self):
-        """ A helper function which generates the starting contents of the
-        block map file: the header comment, image size, block size, etc. """
-
-        # We do not know the amount of mapped blocks at the moment, so just put
-        # whitespaces instead of real numbers. Assume the longest possible
-        # numbers.
-        mapped_count = ' ' * len(str(self.image_size))
-        mapped_size_human = ' ' * len(self.image_size_human)
-
-        xml = _BMAP_START_TEMPLATE \
-               % (SUPPORTED_BMAP_VERSION, self.image_size_human,
-                  self.image_size, self.block_size, self.blocks_cnt)
-        xml += "    <!-- Count of mapped blocks: "
-
-        self._f_bmap.write(xml)
-        self._mapped_count_pos1 = self._f_bmap.tell()
-
-        # Just put white-spaces instead of real information about mapped blocks
-        xml  = "%s or %.1f    -->\n" % (mapped_size_human, 100.0)
-        xml += "    <MappedBlocksCount> "
-
-        self._f_bmap.write(xml)
-        self._mapped_count_pos2 = self._f_bmap.tell()
-
-        xml  = "%s </MappedBlocksCount>\n\n" % mapped_count
-
-        # pylint: disable=C0301
-        xml += "    <!-- The checksum of this bmap file. When it is calculated, the value of\n"
-        xml += "         the SHA1 checksum has be zeoro (40 ASCII \"0\" symbols). -->\n"
-        xml += "    <BmapFileSHA1> "
-
-        self._f_bmap.write(xml)
-        self._sha1_pos = self._f_bmap.tell()
-
-        xml = "0" * 40 + " </BmapFileSHA1>\n\n"
-        xml += "    <!-- The block map which consists of elements which may either be a\n"
-        xml += "         range of blocks or a single block. The 'sha1' attribute (if present)\n"
-        xml += "         is the SHA1 checksum of this blocks range. -->\n"
-        xml += "    <BlockMap>\n"
-        # pylint: enable=C0301
-
-        self._f_bmap.write(xml)
-
-    def _bmap_file_end(self):
-        """ A helper function which generates the final parts of the block map
-        file: the ending tags and the information about the amount of mapped
-        blocks. """
-
-        xml =  "    </BlockMap>\n"
-        xml += "</bmap>\n"
-
-        self._f_bmap.write(xml)
-
-        self._f_bmap.seek(self._mapped_count_pos1)
-        self._f_bmap.write("%s or %.1f%%" % \
-                           (self.mapped_size_human, self.mapped_percent))
-
-        self._f_bmap.seek(self._mapped_count_pos2)
-        self._f_bmap.write("%u" % self.mapped_cnt)
-
-        self._f_bmap.seek(0)
-        sha1 = hashlib.sha1(self._f_bmap.read()).hexdigest()
-        self._f_bmap.seek(self._sha1_pos)
-        self._f_bmap.write("%s" % sha1)
-
-    def _calculate_sha1(self, first, last):
-        """ A helper function which calculates SHA1 checksum for the range of
-        blocks of the image file: from block 'first' to block 'last'. """
-
-        start = first * self.block_size
-        end = (last + 1) * self.block_size
-
-        self._f_image.seek(start)
-        hash_obj = hashlib.new("sha1")
-
-        chunk_size = 1024*1024
-        to_read = end - start
-        read = 0
-
-        while read < to_read:
-            if read + chunk_size > to_read:
-                chunk_size = to_read - read
-            chunk = self._f_image.read(chunk_size)
-            hash_obj.update(chunk)
-            read += chunk_size
-
-        return hash_obj.hexdigest()
-
-    def generate(self, include_checksums = True):
-        """ Generate bmap for the image file. If 'include_checksums' is 'True',
-        also generate SHA1 checksums for block ranges. """
-
-        # Save image file position in order to restore it at the end
-        image_pos = self._f_image.tell()
-
-        self._bmap_file_start()
-
-        # Generate the block map and write it to the XML block map
-        # file as we go.
-        self.mapped_cnt = 0
-        for first, last in self.fiemap.get_mapped_ranges(0, self.blocks_cnt):
-            self.mapped_cnt += last - first + 1
-            if include_checksums:
-                sha1 = self._calculate_sha1(first, last)
-                sha1 = " sha1=\"%s\"" % sha1
-            else:
-                sha1 = ""
-
-            if first != last:
-                self._f_bmap.write("        <Range%s> %s-%s </Range>\n" \
-                                   % (sha1, first, last))
-            else:
-                self._f_bmap.write("        <Range%s> %s </Range>\n" \
-                                   % (sha1, first))
-
-        self.mapped_size = self.mapped_cnt * self.block_size
-        self.mapped_size_human = human_size(self.mapped_size)
-        self.mapped_percent = (self.mapped_cnt * 100.0) /  self.blocks_cnt
-
-        self._bmap_file_end()
-
-        try:
-            self._f_bmap.flush()
-        except IOError as err:
-            raise Error("cannot flush the bmap file '%s': %s" \
-                        % (self._bmap_path, err))
-
-        self._f_image.seek(image_pos)
-
-    def __del__(self):
-        """ The class destructor which closes the opened files. """
-
-        if self._f_image_needs_close:
-            self._f_image.close()
-        if self._f_bmap_needs_close:
-            self._f_bmap.close()
Signature · 1 line
1.8.3.1
#9 lore raw

PATCH 9/35 wic: Remove fiemap support

In reply to Tom Zanussi

wic doesn't use it, so remove it.

---
 scripts/lib/mic/utils/Fiemap.py | 252 ----------------------------------------
 1 file changed, 252 deletions(-)
 delete mode 100644 scripts/lib/mic/utils/Fiemap.py
scripts/lib/mic/utils/Fiemap.py deleted +0 -252
deleted file mode 100644
index f2db6ff..0000000
@@ -1,252 +0,0 @@
-""" This module implements python API for the FIEMAP ioctl. The FIEMAP ioctl
-allows to find holes and mapped areas in a file. """
-
-# Note, a lot of code in this module is not very readable, because it deals
-# with the rather complex FIEMAP ioctl. To understand the code, you need to
-# know the FIEMAP interface, which is documented in the
-# Documentation/filesystems/fiemap.txt file in the Linux kernel sources.
-
-# Disable the following pylint recommendations:
-#   * Too many instance attributes (R0902)
-# pylint: disable=R0902
-
-import os
-import struct
-import array
-import fcntl
-from mic.utils.misc import get_block_size
-
-# Format string for 'struct fiemap'
-_FIEMAP_FORMAT = "=QQLLLL"
-# sizeof(struct fiemap)
-_FIEMAP_SIZE = struct.calcsize(_FIEMAP_FORMAT)
-# Format string for 'struct fiemap_extent'
-_FIEMAP_EXTENT_FORMAT = "=QQQQQLLLL"
-# sizeof(struct fiemap_extent)
-_FIEMAP_EXTENT_SIZE = struct.calcsize(_FIEMAP_EXTENT_FORMAT)
-# The FIEMAP ioctl number
-_FIEMAP_IOCTL = 0xC020660B
-
-# Minimum buffer which is required for 'class Fiemap' to operate
-MIN_BUFFER_SIZE = _FIEMAP_SIZE + _FIEMAP_EXTENT_SIZE
-# The default buffer size for 'class Fiemap'
-DEFAULT_BUFFER_SIZE = 256 * 1024
-
-class Error(Exception):
-    """ A class for exceptions generated by this module. We currently support
-    only one type of exceptions, and we basically throw human-readable problem
-    description in case of errors. """
-    pass
-
-class Fiemap:
-    """ This class provides API to the FIEMAP ioctl. Namely, it allows to
-    iterate over all mapped blocks and over all holes. """
-
-    def _open_image_file(self):
-        """ Open the image file. """
-
-        try:
-            self._f_image = open(self._image_path, 'rb')
-        except IOError as err:
-            raise Error("cannot open image file '%s': %s" \
-                        % (self._image_path, err))
-
-        self._f_image_needs_close = True
-
-    def __init__(self, image, buf_size = DEFAULT_BUFFER_SIZE):
-        """ Initialize a class instance. The 'image' argument is full path to
-        the file to operate on, or a file object to operate on.
-
-        The 'buf_size' argument is the size of the buffer for 'struct
-        fiemap_extent' elements which will be used when invoking the FIEMAP
-        ioctl. The larger is the buffer, the less times the FIEMAP ioctl will
-        be invoked. """
-
-        self._f_image_needs_close = False
-
-        if hasattr(image, "fileno"):
-            self._f_image = image
-            self._image_path = image.name
-        else:
-            self._image_path = image
-            self._open_image_file()
-
-        # Validate 'buf_size'
-        if buf_size < MIN_BUFFER_SIZE:
-            raise Error("too small buffer (%d bytes), minimum is %d bytes" \
-                    % (buf_size, MIN_BUFFER_SIZE))
-
-        # How many 'struct fiemap_extent' elements fit the buffer
-        buf_size -= _FIEMAP_SIZE
-        self._fiemap_extent_cnt = buf_size / _FIEMAP_EXTENT_SIZE
-        self._buf_size = self._fiemap_extent_cnt * _FIEMAP_EXTENT_SIZE
-        self._buf_size += _FIEMAP_SIZE
-
-        # Allocate a mutable buffer for the FIEMAP ioctl
-        self._buf = array.array('B', [0] * self._buf_size)
-
-        self.image_size = os.fstat(self._f_image.fileno()).st_size
-
-        try:
-            self.block_size = get_block_size(self._f_image)
-        except IOError as err:
-            raise Error("cannot get block size for '%s': %s" \
-                        % (self._image_path, err))
-
-        self.blocks_cnt = self.image_size + self.block_size - 1
-        self.blocks_cnt /= self.block_size
-
-        # Synchronize the image file to make sure FIEMAP returns correct values
-        try:
-            self._f_image.flush()
-        except IOError as err:
-            raise Error("cannot flush image file '%s': %s" \
-                        % (self._image_path, err))
-        try:
-            os.fsync(self._f_image.fileno()),
-        except OSError as err:
-            raise Error("cannot synchronize image file '%s': %s " \
-                        % (self._image_path, err.strerror))
-
-        # Check if the FIEMAP ioctl is supported
-        self.block_is_mapped(0)
-
-    def __del__(self):
-        """ The class destructor which closes the opened files. """
-
-        if self._f_image_needs_close:
-            self._f_image.close()
-
-    def _invoke_fiemap(self, block, count):
-        """ Invoke the FIEMAP ioctl for 'count' blocks of the file starting from
-        block number 'block'.
-
-        The full result of the operation is stored in 'self._buf' on exit.
-        Returns the unpacked 'struct fiemap' data structure in form of a python
-        list (just like 'struct.upack()'). """
-
-        if block < 0 or block >= self.blocks_cnt:
-            raise Error("bad block number %d, should be within [0, %d]" \
-                        % (block, self.blocks_cnt))
-
-        # Initialize the 'struct fiemap' part of the buffer
-        struct.pack_into(_FIEMAP_FORMAT, self._buf, 0, block * self.block_size,
-                         count * self.block_size, 0, 0,
-                         self._fiemap_extent_cnt, 0)
-
-        try:
-            fcntl.ioctl(self._f_image, _FIEMAP_IOCTL, self._buf, 1)
-        except IOError as err:
-            error_msg = "the FIEMAP ioctl failed for '%s': %s" \
-                        % (self._image_path, err)
-            if err.errno == os.errno.EPERM or err.errno == os.errno.EACCES:
-                # The FIEMAP ioctl was added in kernel version 2.6.28 in 2008
-                error_msg += " (looks like your kernel does not support FIEMAP)"
-
-            raise Error(error_msg)
-
-        return struct.unpack(_FIEMAP_FORMAT, self._buf[:_FIEMAP_SIZE])
-
-    def block_is_mapped(self, block):
-        """ This function returns 'True' if block number 'block' of the image
-        file is mapped and 'False' otherwise. """
-
-        struct_fiemap = self._invoke_fiemap(block, 1)
-
-        # The 3rd element of 'struct_fiemap' is the 'fm_mapped_extents' field.
-        # If it contains zero, the block is not mapped, otherwise it is
-        # mapped.
-        return bool(struct_fiemap[3])
-
-    def block_is_unmapped(self, block):
-        """ This function returns 'True' if block number 'block' of the image
-        file is not mapped (hole) and 'False' otherwise. """
-
-        return not self.block_is_mapped(block)
-
-    def _unpack_fiemap_extent(self, index):
-        """ Unpack a 'struct fiemap_extent' structure object number 'index'
-        from the internal 'self._buf' buffer. """
-
-        offset = _FIEMAP_SIZE + _FIEMAP_EXTENT_SIZE * index
-        return struct.unpack(_FIEMAP_EXTENT_FORMAT,
-                             self._buf[offset : offset + _FIEMAP_EXTENT_SIZE])
-
-    def _do_get_mapped_ranges(self, start, count):
-        """ Implements most the functionality for the  'get_mapped_ranges()'
-        generator: invokes the FIEMAP ioctl, walks through the mapped
-        extents and yields mapped block ranges. However, the ranges may be
-        consecutive (e.g., (1, 100), (100, 200)) and 'get_mapped_ranges()'
-        simply merges them. """
-
-        block = start
-        while block < start + count:
-            struct_fiemap = self._invoke_fiemap(block, count)
-
-            mapped_extents = struct_fiemap[3]
-            if mapped_extents == 0:
-                # No more mapped blocks
-                return
-
-            extent = 0
-            while extent < mapped_extents:
-                fiemap_extent = self._unpack_fiemap_extent(extent)
-
-                # Start of the extent
-                extent_start = fiemap_extent[0]
-                # Starting block number of the extent
-                extent_block = extent_start / self.block_size
-                # Length of the extent
-                extent_len = fiemap_extent[2]
-                # Count of blocks in the extent
-                extent_count = extent_len / self.block_size
-
-                # Extent length and offset have to be block-aligned
-                assert extent_start % self.block_size == 0
-                assert extent_len % self.block_size == 0
-
-                if extent_block > start + count - 1:
-                    return
-
-                first = max(extent_block, block)
-                last = min(extent_block + extent_count, start + count) - 1
-                yield (first, last)
-
-                extent += 1
-
-            block = extent_block + extent_count
-
-    def get_mapped_ranges(self, start, count):
-        """ A generator which yields ranges of mapped blocks in the file. The
-        ranges are tuples of 2 elements: [first, last], where 'first' is the
-        first mapped block and 'last' is the last mapped block.
-
-        The ranges are yielded for the area of the file of size 'count' blocks,
-        starting from block 'start'. """
-
-        iterator = self._do_get_mapped_ranges(start, count)
-
-        first_prev, last_prev = iterator.next()
-
-        for first, last in iterator:
-            if last_prev == first - 1:
-                last_prev = last
-            else:
-                yield (first_prev, last_prev)
-                first_prev, last_prev = first, last
-
-        yield (first_prev, last_prev)
-
-    def get_unmapped_ranges(self, start, count):
-        """ Just like 'get_mapped_ranges()', but yields unmapped block ranges
-        instead (holes). """
-
-        hole_first = start
-        for first, last in self._do_get_mapped_ranges(start, count):
-            if first > hole_first:
-                yield (hole_first, first - 1)
-
-            hole_first = last + 1
-
-        if hole_first < start + count:
-            yield (hole_first, start + count - 1)
Signature · 1 line
1.8.3.1
#10 lore raw

PATCH 10/35 wic: Remove grabber implementation

In reply to Tom Zanussi

wic doesn't need to grab any urls, so remove it.

---
 scripts/lib/mic/utils/grabber.py | 97 ----------------------------------------
 1 file changed, 97 deletions(-)
 delete mode 100644 scripts/lib/mic/utils/grabber.py
scripts/lib/mic/utils/grabber.py deleted +0 -97
deleted file mode 100644
index 45e30b4..0000000
@@ -1,97 +0,0 @@
-#!/usr/bin/python
-
-import os
-import sys
-import rpm
-import fcntl
-import struct
-import termios
-
-from mic import msger
-from mic.utils import runner
-from mic.utils.errors import CreatorError
-
-from urlgrabber import grabber
-from urlgrabber import __version__ as grabber_version
-
-if rpm.labelCompare(grabber_version.split('.'), '3.9.0'.split('.')) == -1:
-    msger.warning("Version of python-urlgrabber is %s, lower than '3.9.0', "
-                  "you may encounter some network issues" % grabber_version)
-
-def myurlgrab(url, filename, proxies, progress_obj = None):
-    g = grabber.URLGrabber()
-    if progress_obj is None:
-        progress_obj = TextProgress()
-
-    if url.startswith("file:/"):
-        filepath = "/%s" % url.replace("file:", "").lstrip('/')
-        if not os.path.exists(filepath):
-            raise CreatorError("URLGrabber error: can't find file %s" % url)
-        if url.endswith('.rpm'):
-            return filepath
-        else:
-            # untouch repometadata in source path
-            runner.show(['cp', '-f', filepath, filename])
-
-    else:
-        try:
-            filename = g.urlgrab(url=str(url),
-                                 filename=filename,
-                                 ssl_verify_host=False,
-                                 ssl_verify_peer=False,
-                                 proxies=proxies,
-                                 http_headers=(('Pragma', 'no-cache'),),
-                                 quote=0,
-                                 progress_obj=progress_obj)
-        except grabber.URLGrabError, err:
-            msg = str(err)
-            if msg.find(url) < 0:
-                msg += ' on %s' % url
-            raise CreatorError(msg)
-
-    return filename
-
-def terminal_width(fd=1):
-    """ Get the real terminal width """
-    try:
-        buf = 'abcdefgh'
-        buf = fcntl.ioctl(fd, termios.TIOCGWINSZ, buf)
-        return struct.unpack('hhhh', buf)[1]
-    except: # IOError
-        return 80
-
-def truncate_url(url, width):
-    return os.path.basename(url)[0:width]
-
-class TextProgress(object):
-    # make the class as singleton
-    _instance = None
-    def __new__(cls, *args, **kwargs):
-        if not cls._instance:
-            cls._instance = super(TextProgress, cls).__new__(cls, *args, **kwargs)
-
-        return cls._instance
-
-    def __init__(self, totalnum = None):
-        self.total = totalnum
-        self.counter = 1
-
-    def start(self, filename, url, *args, **kwargs):
-        self.url = url
-        self.termwidth = terminal_width()
-        msger.info("\r%-*s" % (self.termwidth, " "))
-        if self.total is None:
-            msger.info("\rRetrieving %s ..." % truncate_url(self.url, self.termwidth - 15))
-        else:
-            msger.info("\rRetrieving %s [%d/%d] ..." % (truncate_url(self.url, self.termwidth - 25), self.counter, self.total))
-
-    def update(self, *args):
-        pass
-
-    def end(self, *args):
-        if self.counter == self.total:
-            msger.raw("\n")
-
-        if self.total is not None:
-            self.counter += 1
-
Signature · 1 line
1.8.3.1
#11 lore raw

PATCH 11/35 wic: Remove proxy support

In reply to Tom Zanussi

wic doesn't use proxy support, so remove it.

Also remove anything related to proxies in misc and conf, and while we're at it, remove all the obviously unneeded code from those files - it's easier to just remove it than to figure out the callchain to the proxy code usages.

Basically the extra stuff relates to packaging, images, and config files we don't use.

---
 scripts/lib/mic/conf.py        |  58 +--
 scripts/lib/mic/utils/misc.py  | 782 -----------------------------------------
 scripts/lib/mic/utils/proxy.py | 183 ----------
 3 files changed, 1 insertion(+), 1022 deletions(-)
 delete mode 100644 scripts/lib/mic/utils/proxy.py
scripts/lib/mic/conf.py +1 -57
index b850d80..1fe6edd 100644
@@ -20,7 +20,7 @@ import ConfigParser
 
 from mic import msger
 from mic import kickstart
-from mic.utils import misc, runner, proxy, errors
+from mic.utils import misc, runner, errors
 
 
 def get_siteconf():
@@ -55,8 +55,6 @@ class ConfigMgr(object):
                     "pack_to": None,
                     "name_prefix": None,
                     "name_suffix": None,
-                    "proxy": None,
-                    "no_proxy": None,
                     "copy_kernel": False,
                     "install_pkgs": None,
                     "repourl": {},
@@ -104,16 +102,6 @@ class ConfigMgr(object):
         for sec, vals in self.DEFAULTS.iteritems():
             setattr(self, sec, vals)
 
-    def __set_siteconf(self, siteconf):
-        try:
-            self.__siteconf = siteconf
-            self._parse_siteconf(siteconf)
-        except ConfigParser.Error, error:
-            raise errors.ConfigError("%s" % error)
-    def __get_siteconf(self):
-        return self.__siteconf
-    _siteconf = property(__get_siteconf, __set_siteconf)
-
     def __set_ksconf(self, ksconf):
         if not os.path.isfile(ksconf):
             msger.error('Cannot find ks file: %s' % ksconf)
@@ -124,50 +112,6 @@ class ConfigMgr(object):
         return self.__ksconf
     _ksconf = property(__get_ksconf, __set_ksconf)
 
-    def _parse_siteconf(self, siteconf):
-        if not siteconf:
-            return
-
-        if not os.path.exists(siteconf):
-            msger.warning("cannot read config file: %s" % siteconf)
-            return
-
-        parser = ConfigParser.SafeConfigParser()
-        parser.read(siteconf)
-
-        for section in parser.sections():
-            if section in self.DEFAULTS:
-                getattr(self, section).update(dict(parser.items(section)))
-
-        # append common section items to other sections
-        for section in self.DEFAULTS.keys():
-            if section != "common":
-                getattr(self, section).update(self.common)
-
-        # check and normalize the scheme of proxy url
-        if self.create['proxy']:
-            m = re.match('^(\w+)://.*', self.create['proxy'])
-            if m:
-                scheme = m.group(1)
-                if scheme not in ('http', 'https', 'ftp', 'socks'):
-                    msger.error("%s: proxy scheme is incorrect" % siteconf)
-            else:
-                msger.warning("%s: proxy url w/o scheme, use http as default"
-                              % siteconf)
-                self.create['proxy'] = "http://" + self.create['proxy']
-
-        proxy.set_proxies(self.create['proxy'], self.create['no_proxy'])
-
-        # bootstrap option handling
-        self.set_runtime(self.create['runtime'])
-        if isinstance(self.bootstrap['packages'], basestring):
-            packages = self.bootstrap['packages'].replace('\n', ' ')
-            if packages.find(',') != -1:
-                packages = packages.split(',')
-            else:
-                packages = packages.split()
-            self.bootstrap['packages'] = packages
-
     def _parse_kickstart(self, ksconf=None):
         if not ksconf:
             return
scripts/lib/mic/utils/misc.py +0 -782

820 lines not on this page · raw message

scripts/lib/mic/utils/proxy.py deleted +0 -183

183 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#12 lore raw

PATCH 12/35 wic: Remove rpmmisc

In reply to Tom Zanussi

wic doesn't use it, so remove it.

---
 scripts/lib/mic/utils/rpmmisc.py | 600 ---------------------------------------
 1 file changed, 600 deletions(-)
 delete mode 100644 scripts/lib/mic/utils/rpmmisc.py
scripts/lib/mic/utils/rpmmisc.py deleted +0 -600
deleted file mode 100644
index af15763..0000000
@@ -1,600 +0,0 @@
-#!/usr/bin/python -tt
-#
-# Copyright (c) 2008, 2009, 2010, 2011 Intel, Inc.
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the Free
-# Software Foundation; version 2 of the License
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc., 59
-# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-import os
-import sys
-import re
-import rpm
-
-from mic import msger
-from mic.utils.errors import CreatorError
-from mic.utils.proxy import get_proxy_for
-from mic.utils import runner
-
-
-class RPMInstallCallback:
-    """ Command line callback class for callbacks from the RPM library.
-    """
-
-    def __init__(self, ts, output=1):
-        self.output = output
-        self.callbackfilehandles = {}
-        self.total_actions = 0
-        self.total_installed = 0
-        self.installed_pkg_names = []
-        self.total_removed = 0
-        self.mark = "+"
-        self.marks = 40
-        self.lastmsg = None
-        self.tsInfo = None # this needs to be set for anything else to work
-        self.ts = ts
-        self.filelog = False
-        self.logString = []
-        self.headmsg = "Installing"
-
-    def _dopkgtup(self, hdr):
-        tmpepoch = hdr['epoch']
-        if tmpepoch is None: epoch = '0'
-        else: epoch = str(tmpepoch)
-
-        return (hdr['name'], hdr['arch'], epoch, hdr['version'], hdr['release'])
-
-    def _makeHandle(self, hdr):
-        handle = '%s:%s.%s-%s-%s' % (hdr['epoch'], hdr['name'], hdr['version'],
-          hdr['release'], hdr['arch'])
-
-        return handle
-
-    def _localprint(self, msg):
-        if self.output:
-            msger.info(msg)
-
-    def _makefmt(self, percent, progress = True):
-        l = len(str(self.total_actions))
-        size = "%s.%s" % (l, l)
-        fmt_done = "[%" + size + "s/%" + size + "s]"
-        done = fmt_done % (self.total_installed + self.total_removed,
-                           self.total_actions)
-        marks = self.marks - (2 * l)
-        width = "%s.%s" % (marks, marks)
-        fmt_bar = "%-" + width + "s"
-        if progress:
-            bar = fmt_bar % (self.mark * int(marks * (percent / 100.0)), )
-            fmt = "\r  %-10.10s: %-20.20s " + bar + " " + done
-        else:
-            bar = fmt_bar % (self.mark * marks, )
-            fmt = "  %-10.10s: %-20.20s "  + bar + " " + done
-        return fmt
-
-    def _logPkgString(self, hdr):
-        """return nice representation of the package for the log"""
-        (n,a,e,v,r) = self._dopkgtup(hdr)
-        if e == '0':
-            pkg = '%s.%s %s-%s' % (n, a, v, r)
-        else:
-            pkg = '%s.%s %s:%s-%s' % (n, a, e, v, r)
-
-        return pkg
-
-    def callback(self, what, bytes, total, h, user):
-        if what == rpm.RPMCALLBACK_TRANS_START:
-            if bytes == 6:
-                self.total_actions = total
-
-        elif what == rpm.RPMCALLBACK_TRANS_PROGRESS:
-            pass
-
-        elif what == rpm.RPMCALLBACK_TRANS_STOP:
-            pass
-
-        elif what == rpm.RPMCALLBACK_INST_OPEN_FILE:
-            self.lastmsg = None
-            hdr = None
-            if h is not None:
-                try:
-                    hdr, rpmloc = h
-                except:
-                    rpmloc = h
-                    hdr = readRpmHeader(self.ts, h)
-
-                handle = self._makeHandle(hdr)
-                fd = os.open(rpmloc, os.O_RDONLY)
-                self.callbackfilehandles[handle]=fd
-                if hdr['name'] not in self.installed_pkg_names:
-                    self.installed_pkg_names.append(hdr['name'])
-                    self.total_installed += 1
-                return fd
-            else:
-                self._localprint("No header - huh?")
-
-        elif what == rpm.RPMCALLBACK_INST_CLOSE_FILE:
-            hdr = None
-            if h is not None:
-                try:
-                    hdr, rpmloc = h
-                except:
-                    rpmloc = h
-                    hdr = readRpmHeader(self.ts, h)
-
-                handle = self._makeHandle(hdr)
-                os.close(self.callbackfilehandles[handle])
-                fd = 0
-
-                # log stuff
-                #pkgtup = self._dopkgtup(hdr)
-                self.logString.append(self._logPkgString(hdr))
-
-        elif what == rpm.RPMCALLBACK_INST_PROGRESS:
-            if h is not None:
-                percent = (self.total_installed*100L)/self.total_actions
-                if total > 0:
-                    try:
-                        hdr, rpmloc = h
-                    except:
-                        rpmloc = h
-
-                    m = re.match("(.*)-(\d+.*)-(\d+\.\d+)\.(.+)\.rpm", os.path.basename(rpmloc))
-                    if m:
-                        pkgname = m.group(1)
-                    else:
-                        pkgname = os.path.basename(rpmloc)
-                if self.output:
-                    fmt = self._makefmt(percent)
-                    msg = fmt % (self.headmsg, pkgname)
-                    if msg != self.lastmsg:
-                        self.lastmsg = msg
-
-                        msger.info(msg)
-
-                        if self.total_installed == self.total_actions:
-                            msger.raw('')
-                            msger.verbose('\n'.join(self.logString))
-
-        elif what == rpm.RPMCALLBACK_UNINST_START:
-            pass
-
-        elif what == rpm.RPMCALLBACK_UNINST_PROGRESS:
-            pass
-
-        elif what == rpm.RPMCALLBACK_UNINST_STOP:
-            self.total_removed += 1
-
-        elif what == rpm.RPMCALLBACK_REPACKAGE_START:
-            pass
-
-        elif what == rpm.RPMCALLBACK_REPACKAGE_STOP:
-            pass
-
-        elif what == rpm.RPMCALLBACK_REPACKAGE_PROGRESS:
-            pass
-
-def readRpmHeader(ts, filename):
-    """ Read an rpm header. """
-
-    fd = os.open(filename, os.O_RDONLY)
-    h = ts.hdrFromFdno(fd)
-    os.close(fd)
-    return h
-
-def splitFilename(filename):
-    """ Pass in a standard style rpm fullname
-
-        Return a name, version, release, epoch, arch, e.g.::
-            foo-1.0-1.i386.rpm returns foo, 1.0, 1, i386
-            1:bar-9-123a.ia64.rpm returns bar, 9, 123a, 1, ia64
-    """
-
-    if filename[-4:] == '.rpm':
-        filename = filename[:-4]
-
-    archIndex = filename.rfind('.')
-    arch = filename[archIndex+1:]
-
-    relIndex = filename[:archIndex].rfind('-')
-    rel = filename[relIndex+1:archIndex]
-
-    verIndex = filename[:relIndex].rfind('-')
-    ver = filename[verIndex+1:relIndex]
-
-    epochIndex = filename.find(':')
-    if epochIndex == -1:
-        epoch = ''
-    else:
-        epoch = filename[:epochIndex]
-
-    name = filename[epochIndex + 1:verIndex]
-    return name, ver, rel, epoch, arch
-
-def getCanonX86Arch(arch):
-    #
-    if arch == "i586":
-        f = open("/proc/cpuinfo", "r")
-        lines = f.readlines()
-        f.close()
-        for line in lines:
-            if line.startswith("model name") and line.find("Geode(TM)") != -1:
-                return "geode"
-        return arch
-    # only athlon vs i686 isn't handled with uname currently
-    if arch != "i686":
-        return arch
-
-    # if we're i686 and AuthenticAMD, then we should be an athlon
-    f = open("/proc/cpuinfo", "r")
-    lines = f.readlines()
-    f.close()
-    for line in lines:
-        if line.startswith("vendor") and line.find("AuthenticAMD") != -1:
-            return "athlon"
-        # i686 doesn't guarantee cmov, but we depend on it
-        elif line.startswith("flags") and line.find("cmov") == -1:
-            return "i586"
-
-    return arch
-
-def getCanonX86_64Arch(arch):
-    if arch != "x86_64":
-        return arch
-
-    vendor = None
-    f = open("/proc/cpuinfo", "r")
-    lines = f.readlines()
-    f.close()
-    for line in lines:
-        if line.startswith("vendor_id"):
-            vendor = line.split(':')[1]
-            break
-    if vendor is None:
-        return arch
-
-    if vendor.find("Authentic AMD") != -1 or vendor.find("AuthenticAMD") != -1:
-        return "amd64"
-    if vendor.find("GenuineIntel") != -1:
-        return "ia32e"
-    return arch
-
-def getCanonArch():
-    arch = os.uname()[4]
-
-    if (len(arch) == 4 and arch[0] == "i" and arch[2:4] == "86"):
-        return getCanonX86Arch(arch)
-
-    if arch == "x86_64":
-        return getCanonX86_64Arch(arch)
-
-    return arch
-
-# Copy from libsatsolver:poolarch.c, with cleanup
-archPolicies = {
-    "x86_64":       "x86_64:i686:i586:i486:i386",
-    "i686":         "i686:i586:i486:i386",
-    "i586":         "i586:i486:i386",
-    "ia64":         "ia64:i686:i586:i486:i386",
-    "armv7tnhl":    "armv7tnhl:armv7thl:armv7nhl:armv7hl",
-    "armv7thl":     "armv7thl:armv7hl",
-    "armv7nhl":     "armv7nhl:armv7hl",
-    "armv7hl":      "armv7hl",
-    "armv7l":       "armv7l:armv6l:armv5tejl:armv5tel:armv5l:armv4tl:armv4l:armv3l",
-    "armv6l":       "armv6l:armv5tejl:armv5tel:armv5l:armv4tl:armv4l:armv3l",
-    "armv5tejl":    "armv5tejl:armv5tel:armv5l:armv4tl:armv4l:armv3l",
-    "armv5tel":     "armv5tel:armv5l:armv4tl:armv4l:armv3l",
-    "armv5l":       "armv5l:armv4tl:armv4l:armv3l",
-}
-
-# dict mapping arch -> ( multicompat, best personality, biarch personality )
-multilibArches = {
-    "x86_64":  ( "athlon", "x86_64", "athlon" ),
-}
-
-# from yumUtils.py
-arches = {
-    # ia32
-    "athlon": "i686",
-    "i686": "i586",
-    "geode": "i586",
-    "i586": "i486",
-    "i486": "i386",
-    "i386": "noarch",
-
-    # amd64
-    "x86_64": "athlon",
-    "amd64": "x86_64",
-    "ia32e": "x86_64",
-
-    # arm
-    "armv7tnhl": "armv7nhl",
-    "armv7nhl": "armv7hl",
-    "armv7hl": "noarch",
-    "armv7l": "armv6l",
-    "armv6l": "armv5tejl",
-    "armv5tejl": "armv5tel",
-    "armv5tel": "noarch",
-
-    #itanium
-    "ia64": "noarch",
-}
-
-def isMultiLibArch(arch=None):
-    """returns true if arch is a multilib arch, false if not"""
-    if arch is None:
-        arch = getCanonArch()
-
-    if not arches.has_key(arch): # or we could check if it is noarch
-        return False
-
-    if multilibArches.has_key(arch):
-        return True
-
-    if multilibArches.has_key(arches[arch]):
-        return True
-
-    return False
-
-def getBaseArch():
-    myarch = getCanonArch()
-    if not arches.has_key(myarch):
-        return myarch
-
-    if isMultiLibArch(arch=myarch):
-        if multilibArches.has_key(myarch):
-            return myarch
-        else:
-            return arches[myarch]
-
-    if arches.has_key(myarch):
-        basearch = myarch
-        value = arches[basearch]
-        while value != 'noarch':
-            basearch = value
-            value = arches[basearch]
-
-        return basearch
-
-def checkRpmIntegrity(bin_rpm, package):
-    return runner.quiet([bin_rpm, "-K", "--nosignature", package])
-
-def checkSig(ts, package):
-    """ Takes a transaction set and a package, check it's sigs,
-        return 0 if they are all fine
-        return 1 if the gpg key can't be found
-        return 2 if the header is in someway damaged
-        return 3 if the key is not trusted
-        return 4 if the pkg is not gpg or pgp signed
-    """
-
-    value = 0
-    currentflags = ts.setVSFlags(0)
-    fdno = os.open(package, os.O_RDONLY)
-    try:
-        hdr = ts.hdrFromFdno(fdno)
-
-    except rpm.error, e:
-        if str(e) == "public key not availaiable":
-            value = 1
-        if str(e) == "public key not available":
-            value = 1
-        if str(e) == "public key not trusted":
-            value = 3
-        if str(e) == "error reading package header":
-            value = 2
-    else:
-        error, siginfo = getSigInfo(hdr)
-        if error == 101:
-            os.close(fdno)
-            del hdr
-            value = 4
-        else:
-            del hdr
-
-    try:
-        os.close(fdno)
-    except OSError:
-        pass
-
-    ts.setVSFlags(currentflags) # put things back like they were before
-    return value
-
-def getSigInfo(hdr):
-    """ checks signature from an hdr hand back signature information and/or
-        an error code
-    """
-
-    import locale
-    locale.setlocale(locale.LC_ALL, 'C')
-
-    string = '%|DSAHEADER?{%{DSAHEADER:pgpsig}}:{%|RSAHEADER?{%{RSAHEADER:pgpsig}}:{%|SIGGPG?{%{SIGGPG:pgpsig}}:{%|SIGPGP?{%{SIGPGP:pgpsig}}:{(none)}|}|}|}|'
-    siginfo = hdr.sprintf(string)
-    if siginfo != '(none)':
-        error = 0
-        sigtype, sigdate, sigid = siginfo.split(',')
-    else:
-        error = 101
-        sigtype = 'MD5'
-        sigdate = 'None'
-        sigid = 'None'
-
-    infotuple = (sigtype, sigdate, sigid)
-    return error, infotuple
-
-def checkRepositoryEULA(name, repo):
-    """ This function is to check the EULA file if provided.
-        return True: no EULA or accepted
-        return False: user declined the EULA
-    """
-
-    import tempfile
-    import shutil
-    import urlparse
-    import urllib2 as u2
-    import httplib
-    from mic.utils.errors import CreatorError
-
-    def _check_and_download_url(u2opener, url, savepath):
-        try:
-            if u2opener:
-                f = u2opener.open(url)
-            else:
-                f = u2.urlopen(url)
-        except u2.HTTPError, httperror:
-            if httperror.code in (404, 503):
-                return None
-            else:
-                raise CreatorError(httperror)
-        except OSError, oserr:
-            if oserr.errno == 2:
-                return None
-            else:
-                raise CreatorError(oserr)
-        except IOError, oserr:
-            if hasattr(oserr, "reason") and oserr.reason.errno == 2:
-                return None
-            else:
-                raise CreatorError(oserr)
-        except u2.URLError, err:
-            raise CreatorError(err)
-        except httplib.HTTPException, e:
-            raise CreatorError(e)
-
-        # save to file
-        licf = open(savepath, "w")
-        licf.write(f.read())
-        licf.close()
-        f.close()
-
-        return savepath
-
-    def _pager_file(savepath):
-
-        if os.path.splitext(savepath)[1].upper() in ('.HTM', '.HTML'):
-            pagers = ('w3m', 'links', 'lynx', 'less', 'more')
-        else:
-            pagers = ('less', 'more')
-
-        file_showed = False
-        for pager in pagers:
-            cmd = "%s %s" % (pager, savepath)
-            try:
-                os.system(cmd)
-            except OSError:
-                continue
-            else:
-                file_showed = True
-                break
-
-        if not file_showed:
-            f = open(savepath)
-            msger.raw(f.read())
-            f.close()
-            msger.pause()
-
-    # when proxy needed, make urllib2 follow it
-    proxy = repo.proxy
-    proxy_username = repo.proxy_username
-    proxy_password = repo.proxy_password
-
-    if not proxy:
-        proxy = get_proxy_for(repo.baseurl[0])
-
-    handlers = []
-    auth_handler = u2.HTTPBasicAuthHandler(u2.HTTPPasswordMgrWithDefaultRealm())
-    u2opener = None
-    if proxy:
-        if proxy_username:
-            proxy_netloc = urlparse.urlsplit(proxy).netloc
-            if proxy_password:
-                proxy_url = 'http://%s:%s@%s' % (proxy_username, proxy_password, proxy_netloc)
-            else:
-                proxy_url = 'http://%s@%s' % (proxy_username, proxy_netloc)
-        else:
-            proxy_url = proxy
-
-        proxy_support = u2.ProxyHandler({'http': proxy_url,
-                                         'https': proxy_url,
-                                         'ftp': proxy_url})
-        handlers.append(proxy_support)
-
-    # download all remote files to one temp dir
-    baseurl = None
-    repo_lic_dir = tempfile.mkdtemp(prefix = 'repolic')
-
-    for url in repo.baseurl:
-        tmphandlers = handlers[:]
-
-        (scheme, host, path, parm, query, frag) = urlparse.urlparse(url.rstrip('/') + '/')
-        if scheme not in ("http", "https", "ftp", "ftps", "file"):
-            raise CreatorError("Error: invalid url %s" % url)
-
-        if '@' in host:
-            try:
-                user_pass, host = host.split('@', 1)
-                if ':' in user_pass:
-                    user, password = user_pass.split(':', 1)
-            except ValueError, e:
-                raise CreatorError('Bad URL: %s' % url)
-
-            msger.verbose("adding HTTP auth: %s, XXXXXXXX" %(user))
-            auth_handler.add_password(None, host, user, password)
-            tmphandlers.append(auth_handler)
-            url = scheme + "://" + host + path + parm + query + frag
-
-        if tmphandlers:
-            u2opener = u2.build_opener(*tmphandlers)
-
-        # try to download
-        repo_eula_url = urlparse.urljoin(url, "LICENSE.txt")
-        repo_eula_path = _check_and_download_url(
-                                u2opener,
-                                repo_eula_url,
-                                os.path.join(repo_lic_dir, repo.id + '_LICENSE.txt'))
-        if repo_eula_path:
-            # found
-            baseurl = url
-            break
-
-    if not baseurl:
-        shutil.rmtree(repo_lic_dir) #cleanup
-        return True
-
-    # show the license file
-    msger.info('For the software packages in this yum repo:')
-    msger.info('    %s: %s' % (name, baseurl))
-    msger.info('There is an "End User License Agreement" file that need to be checked.')
-    msger.info('Please read the terms and conditions outlined in it and answer the followed qustions.')
-    msger.pause()
-
-    _pager_file(repo_eula_path)
-
-    # Asking for the "Accept/Decline"
-    if not msger.ask('Would you agree to the terms and conditions outlined in the above End User License Agreement?'):
-        msger.warning('Will not install pkgs from this repo.')
-        shutil.rmtree(repo_lic_dir) #cleanup
-        return False
-
-    # try to find support_info.html for extra infomation
-    repo_info_url = urlparse.urljoin(baseurl, "support_info.html")
-    repo_info_path = _check_and_download_url(
-                            u2opener,
-                            repo_info_url,
-                            os.path.join(repo_lic_dir, repo.id + '_support_info.html'))
-    if repo_info_path:
-        msger.info('There is one more file in the repo for additional support information, please read it')
-        msger.pause()
-        _pager_file(repo_info_path)
-
-    #cleanup
-    shutil.rmtree(repo_lic_dir)
-    return True
Signature · 1 line
1.8.3.1
#13 lore raw

PATCH 13/35 wic: Remove unused fs_related code

In reply to Tom Zanussi

wic doesn't use it, so remove it.

---
 scripts/lib/mic/utils/fs_related.py | 930 ------------------------------------
 1 file changed, 930 deletions(-)
scripts/lib/mic/utils/fs_related.py +0 -930
index 182171f..e6e362d 100644
@@ -31,19 +31,6 @@ from mic.utils import runner
 from mic.utils.errors import *
 from mic.utils.oe.misc import *
 
-def find_binary_inchroot(binary, chroot):
-    paths = ["/usr/sbin",
-             "/usr/bin",
-             "/sbin",
-             "/bin"
-            ]
-
-    for path in paths:
-        bin_path = "%s/%s" % (path, binary)
-        if os.path.exists("%s/%s" % (chroot, bin_path)):
-            return bin_path
-    return None
-
 def find_binary_path(binary):
     if os.environ.has_key("PATH"):
         paths = os.environ["PATH"].split(":")
@@ -72,176 +59,6 @@ def makedirs(dirname):
         if err.errno != errno.EEXIST:
             raise
 
-def mksquashfs(in_img, out_img):
-    fullpathmksquashfs = find_binary_path("mksquashfs")
-    args = [fullpathmksquashfs, in_img, out_img]
-
-    if not sys.stdout.isatty():
-        args.append("-no-progress")
-
-    ret = runner.show(args)
-    if ret != 0:
-        raise SquashfsError("'%s' exited with error (%d)" % (' '.join(args), ret))
-
-def resize2fs(fs, size):
-    resize2fs = find_binary_path("resize2fs")
-    if size == 0:
-        # it means to minimalize it
-        return runner.show([resize2fs, '-M', fs])
-    else:
-        return runner.show([resize2fs, fs, "%sK" % (size / 1024,)])
-
-def my_fuser(fp):
-    fuser = find_binary_path("fuser")
-    if not os.path.exists(fp):
-        return False
-
-    rc = runner.quiet([fuser, "-s", fp])
-    if rc == 0:
-        for pid in runner.outs([fuser, fp]).split():
-            fd = open("/proc/%s/cmdline" % pid, "r")
-            cmdline = fd.read()
-            fd.close()
-            if cmdline[:-1] == "/bin/bash":
-                return True
-
-    # not found
-    return False
-
-class BindChrootMount:
-    """Represents a bind mount of a directory into a chroot."""
-    def __init__(self, src, chroot, dest = None, option = None):
-        self.root = os.path.abspath(os.path.expanduser(chroot))
-        self.option = option
-
-        self.orig_src = self.src = src
-        if os.path.islink(src):
-            self.src = os.readlink(src)
-            if not self.src.startswith('/'):
-                self.src = os.path.abspath(os.path.join(os.path.dirname(src),
-                                                        self.src))
-
-        if not dest:
-            dest = self.src
-        self.dest = os.path.join(self.root, dest.lstrip('/'))
-
-        self.mounted = False
-        self.mountcmd = find_binary_path("mount")
-        self.umountcmd = find_binary_path("umount")
-
-    def ismounted(self):
-        with open('/proc/mounts') as f:
-            for line in f:
-                if line.split()[1] == os.path.abspath(self.dest):
-                    return True
-
-        return False
-
-    def has_chroot_instance(self):
-        lock = os.path.join(self.root, ".chroot.lock")
-        return my_fuser(lock)
-
-    def mount(self):
-        if self.mounted or self.ismounted():
-            return
-
-        makedirs(self.dest)
-        rc = runner.show([self.mountcmd, "--bind", self.src, self.dest])
-        if rc != 0:
-            raise MountError("Bind-mounting '%s' to '%s' failed" %
-                             (self.src, self.dest))
-        if self.option:
-            rc = runner.show([self.mountcmd, "--bind", "-o", "remount,%s" % self.option, self.dest])
-            if rc != 0:
-                raise MountError("Bind-remounting '%s' failed" % self.dest)
-
-        self.mounted = True
-        if os.path.islink(self.orig_src):
-            dest = os.path.join(self.root, self.orig_src.lstrip('/'))
-            if not os.path.exists(dest):
-                os.symlink(self.src, dest)
-
-    def unmount(self):
-        if self.has_chroot_instance():
-            return
-
-        if self.ismounted():
-            runner.show([self.umountcmd, "-l", self.dest])
-        self.mounted = False
-
-class LoopbackMount:
-    """LoopbackMount  compatibility layer for old API"""
-    def __init__(self, lofile, mountdir, fstype = None):
-        self.diskmount = DiskMount(LoopbackDisk(lofile,size = 0),mountdir,fstype,rmmountdir = True)
-        self.losetup = False
-        self.losetupcmd = find_binary_path("losetup")
-
-    def cleanup(self):
-        self.diskmount.cleanup()
-
-    def unmount(self):
-        self.diskmount.unmount()
-
-    def lounsetup(self):
-        if self.losetup:
-            runner.show([self.losetupcmd, "-d", self.loopdev])
-            self.losetup = False
-            self.loopdev = None
-
-    def loopsetup(self):
-        if self.losetup:
-            return
-
-        self.loopdev = get_loop_device(self.losetupcmd, self.lofile)
-        self.losetup = True
-
-    def mount(self):
-        self.diskmount.mount()
-
-class SparseLoopbackMount(LoopbackMount):
-    """SparseLoopbackMount  compatibility layer for old API"""
-    def __init__(self, lofile, mountdir, size, fstype = None):
-        self.diskmount = DiskMount(SparseLoopbackDisk(lofile,size),mountdir,fstype,rmmountdir = True)
-
-    def expand(self, create = False, size = None):
-        self.diskmount.disk.expand(create, size)
-
-    def truncate(self, size = None):
-        self.diskmount.disk.truncate(size)
-
-    def create(self):
-        self.diskmount.disk.create()
-
-class SparseExtLoopbackMount(SparseLoopbackMount):
-    """SparseExtLoopbackMount  compatibility layer for old API"""
-    def __init__(self, lofile, mountdir, size, fstype, blocksize, fslabel):
-        self.diskmount = ExtDiskMount(SparseLoopbackDisk(lofile,size), mountdir, fstype, blocksize, fslabel, rmmountdir = True)
-
-
-    def __format_filesystem(self):
-        self.diskmount.__format_filesystem()
-
-    def create(self):
-        self.diskmount.disk.create()
-
-    def resize(self, size = None):
-        return self.diskmount.__resize_filesystem(size)
-
-    def mount(self):
-        self.diskmount.mount()
-
-    def __fsck(self):
-        self.extdiskmount.__fsck()
-
-    def __get_size_from_filesystem(self):
-        return self.diskmount.__get_size_from_filesystem()
-
-    def __resize_to_minimal(self):
-        return self.diskmount.__resize_to_minimal()
-
-    def resparse(self, size = None):
-        return self.diskmount.resparse(size)
-
 class Disk:
     """Generic base object for a disk
 
@@ -270,20 +87,6 @@ class Disk:
     size = property(get_size)
 
 
-class RawDisk(Disk):
-    """A Disk backed by a block device.
-    Note that create() is a no-op.
-    """
-    def __init__(self, size, device):
-        Disk.__init__(self, size, device)
-
-    def fixed(self):
-        return True
-
-    def exists(self):
-        return True
-
-
 class DiskImage(Disk):
     """
     A Disk backed by a file.
@@ -311,76 +114,6 @@ class DiskImage(Disk):
         self.device = self.image_file
 
 
-class LoopbackDisk(Disk):
-    """A Disk backed by a file via the loop module."""
-    def __init__(self, lofile, size):
-        Disk.__init__(self, size)
-        self.lofile = lofile
-        self.losetupcmd = find_binary_path("losetup")
-
-    def fixed(self):
-        return False
-
-    def exists(self):
-        return os.path.exists(self.lofile)
-
-    def create(self):
-        if self.device is not None:
-            return
-
-        self.device = get_loop_device(self.losetupcmd, self.lofile)
-
-    def cleanup(self):
-        if self.device is None:
-            return
-        msger.debug("Losetup remove %s" % self.device)
-        rc = runner.show([self.losetupcmd, "-d", self.device])
-        self.device = None
-
-class SparseLoopbackDisk(LoopbackDisk):
-    """A Disk backed by a sparse file via the loop module."""
-    def __init__(self, lofile, size):
-        LoopbackDisk.__init__(self, lofile, size)
-
-    def expand(self, create = False, size = None):
-        flags = os.O_WRONLY
-        if create:
-            flags |= os.O_CREAT
-            if not os.path.exists(self.lofile):
-                makedirs(os.path.dirname(self.lofile))
-
-        if size is None:
-            size = self.size
-
-        msger.debug("Extending sparse file %s to %d" % (self.lofile, size))
-        if create:
-            fd = os.open(self.lofile, flags, 0644)
-        else:
-            fd = os.open(self.lofile, flags)
-
-        if size <= 0:
-            size = 1
-        try:
-            os.ftruncate(fd, size)
-        except:
-            # may be limited by 2G in 32bit env
-            os.ftruncate(fd, 2**31L)
-
-        os.close(fd)
-
-    def truncate(self, size = None):
-        if size is None:
-            size = self.size
-
-        msger.debug("Truncating sparse file %s to %d" % (self.lofile, size))
-        fd = os.open(self.lofile, os.O_WRONLY)
-        os.ftruncate(fd, size)
-        os.close(fd)
-
-    def create(self):
-        self.expand(create = True)
-        LoopbackDisk.create(self)
-
 class Mount:
     """A generic base class to deal with mounting things."""
     def __init__(self, mountdir):
@@ -395,666 +128,3 @@ class Mount:
     def unmount(self):
         pass
 
-class DiskMount(Mount):
-    """A Mount object that handles mounting of a Disk."""
-    def __init__(self, disk, mountdir, fstype = None, rmmountdir = True):
-        Mount.__init__(self, mountdir)
-
-        self.disk = disk
-        self.fstype = fstype
-        self.rmmountdir = rmmountdir
-
-        self.mounted = False
-        self.rmdir   = False
-        if fstype:
-            self.mkfscmd = find_binary_path("mkfs." + self.fstype)
-        else:
-            self.mkfscmd = None
-        self.mountcmd = find_binary_path("mount")
-        self.umountcmd = find_binary_path("umount")
-
-    def cleanup(self):
-        Mount.cleanup(self)
-        self.disk.cleanup()
-
-    def unmount(self):
-        if self.mounted:
-            msger.debug("Unmounting directory %s" % self.mountdir)
-            runner.quiet('sync') # sync the data on this mount point
-            rc = runner.show([self.umountcmd, "-l", self.mountdir])
-            if rc == 0:
-                self.mounted = False
-            else:
-                raise MountError("Failed to umount %s" % self.mountdir)
-        if self.rmdir and not self.mounted:
-            try:
-                os.rmdir(self.mountdir)
-            except OSError, e:
-                pass
-            self.rmdir = False
-
-
-    def __create(self):
-        self.disk.create()
-
-
-    def mount(self, options = None):
-        if self.mounted:
-            return
-
-        if not os.path.isdir(self.mountdir):
-            msger.debug("Creating mount point %s" % self.mountdir)
-            os.makedirs(self.mountdir)
-            self.rmdir = self.rmmountdir
-
-        self.__create()
-
-        msger.debug("Mounting %s at %s" % (self.disk.device, self.mountdir))
-        if options:
-            args = [ self.mountcmd, "-o", options, self.disk.device, self.mountdir ]
-        else:
-            args = [ self.mountcmd, self.disk.device, self.mountdir ]
-        if self.fstype:
-            args.extend(["-t", self.fstype])
-
-        rc = runner.show(args)
-        if rc != 0:
-            raise MountError("Failed to mount '%s' to '%s' with command '%s'. Retval: %s" %
-                             (self.disk.device, self.mountdir, " ".join(args), rc))
-
-        self.mounted = True
-
-class ExtDiskMount(DiskMount):
-    """A DiskMount object that is able to format/resize ext[23] filesystems."""
-    def __init__(self, disk, mountdir, fstype, blocksize, fslabel, rmmountdir=True, skipformat = False, fsopts = None):
-        DiskMount.__init__(self, disk, mountdir, fstype, rmmountdir)
-        self.blocksize = blocksize
-        self.fslabel = fslabel.replace("/", "")
-        self.uuid = str(uuid.uuid4())
-        self.skipformat = skipformat
-        self.fsopts = fsopts
-        self.extopts = None
-        self.dumpe2fs = find_binary_path("dumpe2fs")
-        self.tune2fs = find_binary_path("tune2fs")
-
-    def __parse_field(self, output, field):
-        for line in output.split("\n"):
-            if line.startswith(field + ":"):
-                return line[len(field) + 1:].strip()
-
-        raise KeyError("Failed to find field '%s' in output" % field)
-
-    def __format_filesystem(self):
-        if self.skipformat:
-            msger.debug("Skip filesystem format.")
-            return
-
-        msger.verbose("Formating %s filesystem on %s" % (self.fstype, self.disk.device))
-        cmdlist = [self.mkfscmd, "-F", "-L", self.fslabel, "-m", "1", "-b",
-                   str(self.blocksize), "-U", self.uuid]
-        if self.extopts:
-            cmdlist.extend(self.extopts.split())
-        cmdlist.extend([self.disk.device])
-
-        rc, errout = runner.runtool(cmdlist, catch=2)
-        if rc != 0:
-            raise MountError("Error creating %s filesystem on disk %s:\n%s" %
-                             (self.fstype, self.disk.device, errout))
-
-        if not self.extopts:
-            msger.debug("Tuning filesystem on %s" % self.disk.device)
-            runner.show([self.tune2fs, "-c0", "-i0", "-Odir_index", "-ouser_xattr,acl", self.disk.device])
-
-    def __resize_filesystem(self, size = None):
-        current_size = os.stat(self.disk.lofile)[stat.ST_SIZE]
-
-        if size is None:
-            size = self.disk.size
-
-        if size == current_size:
-            return
-
-        if size > current_size:
-            self.disk.expand(size)
-
-        self.__fsck()
-
-        resize2fs(self.disk.lofile, size)
-        return size
-
-    def __create(self):
-        resize = False
-        if not self.disk.fixed() and self.disk.exists():
-            resize = True
-
-        self.disk.create()
-
-        if resize:
-            self.__resize_filesystem()
-        else:
-            self.__format_filesystem()
-
-    def mount(self, options = None):
-        self.__create()
-        DiskMount.mount(self, options)
-
-    def __fsck(self):
-        msger.info("Checking filesystem %s" % self.disk.lofile)
-        runner.quiet(["/sbin/e2fsck", "-f", "-y", self.disk.lofile])
-
-    def __get_size_from_filesystem(self):
-        return int(self.__parse_field(runner.outs([self.dumpe2fs, '-h', self.disk.lofile]),
-                                      "Block count")) * self.blocksize
-
-    def __resize_to_minimal(self):
-        self.__fsck()
-
-        #
-        # Use a binary search to find the minimal size
-        # we can resize the image to
-        #
-        bot = 0
-        top = self.__get_size_from_filesystem()
-        while top != (bot + 1):
-            t = bot + ((top - bot) / 2)
-
-            if not resize2fs(self.disk.lofile, t):
-                top = t
-            else:
-                bot = t
-        return top
-
-    def resparse(self, size = None):
-        self.cleanup()
-        if size == 0:
-            minsize = 0
-        else:
-            minsize = self.__resize_to_minimal()
-            self.disk.truncate(minsize)
-
-        self.__resize_filesystem(size)
-        return minsize
-
-class VfatDiskMount(DiskMount):
-    """A DiskMount object that is able to format vfat/msdos filesystems."""
-    def __init__(self, disk, mountdir, fstype, blocksize, fslabel, rmmountdir=True, skipformat = False, fsopts = None):
-        DiskMount.__init__(self, disk, mountdir, fstype, rmmountdir)
-        self.blocksize = blocksize
-        self.fslabel = fslabel.replace("/", "")
-        rand1 = random.randint(0, 2**16 - 1)
-        rand2 = random.randint(0, 2**16 - 1)
-        self.uuid = "%04X-%04X" % (rand1, rand2)
-        self.skipformat = skipformat
-        self.fsopts = fsopts
-        self.fsckcmd = find_binary_path("fsck." + self.fstype)
-
-    def __format_filesystem(self):
-        if self.skipformat:
-            msger.debug("Skip filesystem format.")
-            return
-
-        msger.verbose("Formating %s filesystem on %s" % (self.fstype, self.disk.device))
-        rc = runner.show([self.mkfscmd, "-n", self.fslabel,
-                          "-i", self.uuid.replace("-", ""), self.disk.device])
-        if rc != 0:
-            raise MountError("Error creating %s filesystem on disk %s" % (self.fstype,self.disk.device))
-
-        msger.verbose("Tuning filesystem on %s" % self.disk.device)
-
-    def __resize_filesystem(self, size = None):
-        current_size = os.stat(self.disk.lofile)[stat.ST_SIZE]
-
-        if size is None:
-            size = self.disk.size
-
-        if size == current_size:
-            return
-
-        if size > current_size:
-            self.disk.expand(size)
-
-        self.__fsck()
-
-        #resize2fs(self.disk.lofile, size)
-        return size
-
-    def __create(self):
-        resize = False
-        if not self.disk.fixed() and self.disk.exists():
-            resize = True
-
-        self.disk.create()
-
-        if resize:
-            self.__resize_filesystem()
-        else:
-            self.__format_filesystem()
-
-    def mount(self, options = None):
-        self.__create()
-        DiskMount.mount(self, options)
-
-    def __fsck(self):
-        msger.debug("Checking filesystem %s" % self.disk.lofile)
-        runner.show([self.fsckcmd, "-y", self.disk.lofile])
-
-    def __get_size_from_filesystem(self):
-        return self.disk.size
-
-    def __resize_to_minimal(self):
-        self.__fsck()
-
-        #
-        # Use a binary search to find the minimal size
-        # we can resize the image to
-        #
-        bot = 0
-        top = self.__get_size_from_filesystem()
-        return top
-
-    def resparse(self, size = None):
-        self.cleanup()
-        minsize = self.__resize_to_minimal()
-        self.disk.truncate(minsize)
-        self.__resize_filesystem(size)
-        return minsize
-
-class BtrfsDiskMount(DiskMount):
-    """A DiskMount object that is able to format/resize btrfs filesystems."""
-    def __init__(self, disk, mountdir, fstype, blocksize, fslabel, rmmountdir=True, skipformat = False, fsopts = None):
-        self.__check_btrfs()
-        DiskMount.__init__(self, disk, mountdir, fstype, rmmountdir)
-        self.blocksize = blocksize
-        self.fslabel = fslabel.replace("/", "")
-        self.uuid  = None
-        self.skipformat = skipformat
-        self.fsopts = fsopts
-        self.blkidcmd = find_binary_path("blkid")
-        self.btrfsckcmd = find_binary_path("btrfsck")
-
-    def __check_btrfs(self):
-        found = False
-        """ Need to load btrfs module to mount it """
-        load_module("btrfs")
-        for line in open("/proc/filesystems").xreadlines():
-            if line.find("btrfs") > -1:
-                found = True
-                break
-        if not found:
-            raise MountError("Your system can't mount btrfs filesystem, please make sure your kernel has btrfs support and the module btrfs.ko has been loaded.")
-
-        # disable selinux, selinux will block write
-        if os.path.exists("/usr/sbin/setenforce"):
-            runner.show(["/usr/sbin/setenforce", "0"])
-
-    def __parse_field(self, output, field):
-        for line in output.split(" "):
-            if line.startswith(field + "="):
-                return line[len(field) + 1:].strip().replace("\"", "")
-
-        raise KeyError("Failed to find field '%s' in output" % field)
-
-    def __format_filesystem(self):
-        if self.skipformat:
-            msger.debug("Skip filesystem format.")
-            return
-
-        msger.verbose("Formating %s filesystem on %s" % (self.fstype, self.disk.device))
-        rc = runner.show([self.mkfscmd, "-L", self.fslabel, self.disk.device])
-        if rc != 0:
-            raise MountError("Error creating %s filesystem on disk %s" % (self.fstype,self.disk.device))
-
-        self.uuid = self.__parse_field(runner.outs([self.blkidcmd, self.disk.device]), "UUID")
-
-    def __resize_filesystem(self, size = None):
-        current_size = os.stat(self.disk.lofile)[stat.ST_SIZE]
-
-        if size is None:
-            size = self.disk.size
-
-        if size == current_size:
-            return
-
-        if size > current_size:
-            self.disk.expand(size)
-
-        self.__fsck()
-        return size
-
-    def __create(self):
-        resize = False
-        if not self.disk.fixed() and self.disk.exists():
-            resize = True
-
-        self.disk.create()
-
-        if resize:
-            self.__resize_filesystem()
-        else:
-            self.__format_filesystem()
-
-    def mount(self, options = None):
-        self.__create()
-        DiskMount.mount(self, options)
-
-    def __fsck(self):
-        msger.debug("Checking filesystem %s" % self.disk.lofile)
-        runner.quiet([self.btrfsckcmd, self.disk.lofile])
-
-    def __get_size_from_filesystem(self):
-        return self.disk.size
-
-    def __resize_to_minimal(self):
-        self.__fsck()
-
-        return self.__get_size_from_filesystem()
-
-    def resparse(self, size = None):
-        self.cleanup()
-        minsize = self.__resize_to_minimal()
-        self.disk.truncate(minsize)
-        self.__resize_filesystem(size)
-        return minsize
-
-class DeviceMapperSnapshot(object):
-    def __init__(self, imgloop, cowloop):
-        self.imgloop = imgloop
-        self.cowloop = cowloop
-
-        self.__created = False
-        self.__name = None
-        self.dmsetupcmd = find_binary_path("dmsetup")
-
-        """Load dm_snapshot if it isn't loaded"""
-        load_module("dm_snapshot")
-
-    def get_path(self):
-        if self.__name is None:
-            return None
-        return os.path.join("/dev/mapper", self.__name)
-    path = property(get_path)
-
-    def create(self):
-        if self.__created:
-            return
-
-        self.imgloop.create()
-        self.cowloop.create()
-
-        self.__name = "imgcreate-%d-%d" % (os.getpid(),
-                                           random.randint(0, 2**16))
-
-        size = os.stat(self.imgloop.lofile)[stat.ST_SIZE]
-
-        table = "0 %d snapshot %s %s p 8" % (size / 512,
-                                             self.imgloop.device,
-                                             self.cowloop.device)
-
-        args = [self.dmsetupcmd, "create", self.__name, "--table", table]
-        if runner.show(args) != 0:
-            self.cowloop.cleanup()
-            self.imgloop.cleanup()
-            raise SnapshotError("Could not create snapshot device using: " + ' '.join(args))
-
-        self.__created = True
-
-    def remove(self, ignore_errors = False):
-        if not self.__created:
-            return
-
-        time.sleep(2)
-        rc = runner.show([self.dmsetupcmd, "remove", self.__name])
-        if not ignore_errors and rc != 0:
-            raise SnapshotError("Could not remove snapshot device")
-
-        self.__name = None
-        self.__created = False
-
-        self.cowloop.cleanup()
-        self.imgloop.cleanup()
-
-    def get_cow_used(self):
-        if not self.__created:
-            return 0
-
-        #
-        # dmsetup status on a snapshot returns e.g.
-        #   "0 8388608 snapshot 416/1048576"
-        # or, more generally:
-        #   "A B snapshot C/D"
-        # where C is the number of 512 byte sectors in use
-        #
-        out = runner.outs([self.dmsetupcmd, "status", self.__name])
-        try:
-            return int((out.split()[3]).split('/')[0]) * 512
-        except ValueError:
-            raise SnapshotError("Failed to parse dmsetup status: " + out)
-
-def create_image_minimizer(path, image, minimal_size):
-    """
-    Builds a copy-on-write image which can be used to
-    create a device-mapper snapshot of an image where
-    the image's filesystem is as small as possible
-
-    The steps taken are:
-      1) Create a sparse COW
-      2) Loopback mount the image and the COW
-      3) Create a device-mapper snapshot of the image
-         using the COW
-      4) Resize the filesystem to the minimal size
-      5) Determine the amount of space used in the COW
-      6) Restroy the device-mapper snapshot
-      7) Truncate the COW, removing unused space
-      8) Create a squashfs of the COW
-    """
-    imgloop = LoopbackDisk(image, None) # Passing bogus size - doesn't matter
-
-    cowloop = SparseLoopbackDisk(os.path.join(os.path.dirname(path), "osmin"),
-                                 64L * 1024L * 1024L)
-
-    snapshot = DeviceMapperSnapshot(imgloop, cowloop)
-
-    try:
-        snapshot.create()
-
-        resize2fs(snapshot.path, minimal_size)
-
-        cow_used = snapshot.get_cow_used()
-    finally:
-        snapshot.remove(ignore_errors = (not sys.exc_info()[0] is None))
-
-    cowloop.truncate(cow_used)
-
-    mksquashfs(cowloop.lofile, path)
-
-    os.unlink(cowloop.lofile)
-
-def load_module(module):
-    found = False
-    for line in open('/proc/modules').xreadlines():
-        if line.startswith("%s " % module):
-            found = True
-            break
-    if not found:
-        msger.info("Loading %s..." % module)
-        runner.quiet(['modprobe', module])
-
-class LoopDevice(object):
-    def __init__(self, loopid=None):
-        self.device = None
-        self.loopid = loopid
-        self.created = False
-        self.kpartxcmd = find_binary_path("kpartx")
-        self.losetupcmd = find_binary_path("losetup")
-
-    def register(self, device):
-        self.device = device
-        self.loopid = None
-        self.created = True
-
-    def reg_atexit(self):
-        import atexit
-        atexit.register(self.close)
-
-    def _genloopid(self):
-        import glob
-        if not glob.glob("/dev/loop[0-9]*"):
-            return 10
-
-        fint = lambda x: x[9:].isdigit() and int(x[9:]) or 0
-        maxid = 1 + max(filter(lambda x: x<100,
-                               map(fint, glob.glob("/dev/loop[0-9]*"))))
-        if maxid < 10: maxid = 10
-        if maxid >= 100: raise
-        return maxid
-
-    def _kpseek(self, device):
-        rc, out = runner.runtool([self.kpartxcmd, '-l', '-v', device])
-        if rc != 0:
-            raise MountError("Can't query dm snapshot on %s" % device)
-        for line in out.splitlines():
-            if line and line.startswith("loop"):
-                return True
-        return False
-
-    def _loseek(self, device):
-        import re
-        rc, out = runner.runtool([self.losetupcmd, '-a'])
-        if rc != 0:
-            raise MountError("Failed to run 'losetup -a'")
-        for line in out.splitlines():
-            m = re.match("([^:]+): .*", line)
-            if m and m.group(1) == device:
-                return True
-        return False
-
-    def create(self):
-        if not self.created:
-            if not self.loopid:
-                self.loopid = self._genloopid()
-            self.device = "/dev/loop%d" % self.loopid
-            if os.path.exists(self.device):
-                if self._loseek(self.device):
-                    raise MountError("Device busy: %s" % self.device)
-                else:
-                    self.created = True
-                    return
-
-            mknod = find_binary_path('mknod')
-            rc = runner.show([mknod, '-m664', self.device, 'b', '7', str(self.loopid)])
-            if rc != 0:
-                raise MountError("Failed to create device %s" % self.device)
-            else:
-                self.created = True
-
-    def close(self):
-        if self.created:
-            try:
-                self.cleanup()
-                self.device = None
-            except MountError, e:
-                msger.error("%s" % e)
-
-    def cleanup(self):
-
-        if self.device is None:
-            return
-
-
-        if self._kpseek(self.device):
-            if self.created:
-                for i in range(3, os.sysconf("SC_OPEN_MAX")):
-                    try:
-                        os.close(i)
-                    except:
-                        pass
-            runner.quiet([self.kpartxcmd, "-d", self.device])
-        if self._loseek(self.device):
-            runner.quiet([self.losetupcmd, "-d", self.device])
-        # FIXME: should sleep a while between two loseek
-        if self._loseek(self.device):
-            msger.warning("Can't cleanup loop device %s" % self.device)
-        elif self.loopid:
-            os.unlink(self.device)
-
-DEVICE_PIDFILE_DIR = "/var/tmp/mic/device"
-DEVICE_LOCKFILE = "/var/lock/__mic_loopdev.lock"
-
-def get_loop_device(losetupcmd, lofile):
-    global DEVICE_PIDFILE_DIR
-    global DEVICE_LOCKFILE
-
-    import fcntl
-    makedirs(os.path.dirname(DEVICE_LOCKFILE))
-    fp = open(DEVICE_LOCKFILE, 'w')
-    fcntl.flock(fp, fcntl.LOCK_EX)
-    try:
-        loopdev = None
-        devinst = LoopDevice()
-
-        # clean up left loop device first
-        clean_loop_devices()
-
-        # provide an avaible loop device
-        rc, out = runner.runtool([losetupcmd, "--find"])
-        if rc == 0:
-            loopdev = out.split()[0]
-            devinst.register(loopdev)
-        if not loopdev or not os.path.exists(loopdev):
-            devinst.create()
-            loopdev = devinst.device
-
-        # setup a loop device for image file
-        rc = runner.show([losetupcmd, loopdev, lofile])
-        if rc != 0:
-            raise MountError("Failed to setup loop device for '%s'" % lofile)
-
-        devinst.reg_atexit()
-
-        # try to save device and pid
-        makedirs(DEVICE_PIDFILE_DIR)
-        pidfile = os.path.join(DEVICE_PIDFILE_DIR, os.path.basename(loopdev))
-        if os.path.exists(pidfile):
-            os.unlink(pidfile)
-        with open(pidfile, 'w') as wf:
-            wf.write(str(os.getpid()))
-
-    except MountError, err:
-        raise CreatorError("%s" % str(err))
-    except:
-        raise
-    finally:
-        try:
-            fcntl.flock(fp, fcntl.LOCK_UN)
-            fp.close()
-            os.unlink(DEVICE_LOCKFILE)
-        except:
-            pass
-
-    return loopdev
-
-def clean_loop_devices(piddir=DEVICE_PIDFILE_DIR):
-    if not os.path.exists(piddir) or not os.path.isdir(piddir):
-        return
-
-    for loopdev in os.listdir(piddir):
-        pidfile = os.path.join(piddir, loopdev)
-        try:
-            with open(pidfile, 'r') as rf:
-                devpid = int(rf.read())
-        except:
-            devpid = None
-
-        # if the process using this device is alive, skip it
-        if not devpid or os.path.exists(os.path.join('/proc', str(devpid))):
-            continue
-
-        # try to clean it up
-        try:
-            devinst = LoopDevice()
-            devinst.register(os.path.join('/dev', loopdev))
-            devinst.cleanup()
-            os.unlink(pidfile)
-        except:
-            pass
-
Signature · 1 line
1.8.3.1
#14 lore raw

PATCH 14/35 wic: Remove unused misc code

In reply to Tom Zanussi

wic doesn't use it, so remove it.

---
 scripts/lib/mic/utils/misc.py | 180 +-----------------------------------------
 1 file changed, 1 insertion(+), 179 deletions(-)
scripts/lib/mic/utils/misc.py +1 -179
index 8c1f016..010b16c 100644
@@ -18,29 +18,9 @@
 import os
 import sys
 import time
-import tempfile
-import re
-import shutil
-import glob
-import hashlib
-import subprocess
-import platform
-import traceback
-
-
-try:
-    import sqlite3 as sqlite
-except ImportError:
-    import sqlite
-
-try:
-    from xml.etree import cElementTree
-except ImportError:
-    import cElementTree
-xmlparse = cElementTree.parse
 
 from mic import msger
-from mic.utils.errors import CreatorError, SquashfsError
+from mic.utils.errors import CreatorError
 from mic.utils.fs_related import find_binary_path, makedirs
 from mic.utils import runner
 
@@ -82,115 +62,6 @@ def build_name(kscfg, release=None, prefix = None, suffix = None):
     ret = prefix + name + suffix
     return ret
 
-def get_distro():
-    """Detect linux distribution, support "meego"
-    """
-
-    support_dists = ('SuSE',
-                     'debian',
-                     'fedora',
-                     'redhat',
-                     'centos',
-                     'meego',
-                     'moblin',
-                     'tizen')
-    try:
-        (dist, ver, id) = platform.linux_distribution( \
-                              supported_dists = support_dists)
-    except:
-        (dist, ver, id) = platform.dist( \
-                              supported_dists = support_dists)
-
-    return (dist, ver, id)
-
-def get_distro_str():
-    """Get composited string for current linux distribution
-    """
-    (dist, ver, id) = get_distro()
-
-    if not dist:
-        return 'Unknown Linux Distro'
-    else:
-        distro_str = ' '.join(map(str.strip, (dist, ver, id)))
-        return distro_str.strip()
-
-_LOOP_RULE_PTH = None
-
-def human_size(size):
-    """Return human readable string for Bytes size
-    """
-
-    if size <= 0:
-        return "0M"
-    import math
-    measure = ['B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']
-    expo = int(math.log(size, 1024))
-    mant = float(size/math.pow(1024, expo))
-    return "{0:.1f}{1:s}".format(mant, measure[expo])
-
-def get_block_size(file_obj):
-    """ Returns block size for file object 'file_obj'. Errors are indicated by
-    the 'IOError' exception. """
-
-    from fcntl import ioctl
-    import struct
-
-    # Get the block size of the host file-system for the image file by calling
-    # the FIGETBSZ ioctl (number 2).
-    binary_data = ioctl(file_obj, 2, struct.pack('I', 0))
-    return struct.unpack('I', binary_data)[0]
-
-def check_space_pre_cp(src, dst):
-    """Check whether disk space is enough before 'cp' like
-    operations, else exception will be raised.
-    """
-
-    srcsize  = get_file_size(src) * 1024 * 1024
-    freesize = get_filesystem_avail(dst)
-    if srcsize > freesize:
-        raise CreatorError("space on %s(%s) is not enough for about %s files"
-                           % (dst, human_size(freesize), human_size(srcsize)))
-
-def calc_hashes(file_path, hash_names, start = 0, end = None):
-    """ Calculate hashes for a file. The 'file_path' argument is the file
-    to calculate hash functions for, 'start' and 'end' are the starting and
-    ending file offset to calculate the has functions for. The 'hash_names'
-    argument is a list of hash names to calculate. Returns the the list
-    of calculated hash values in the hexadecimal form in the same order
-    as 'hash_names'.
-    """
-    if end == None:
-        end = os.path.getsize(file_path)
-
-    chunk_size = 65536
-    to_read = end - start
-    read = 0
-
-    hashes = []
-    for hash_name in hash_names:
-        hashes.append(hashlib.new(hash_name))
-
-    with open(file_path, "rb") as f:
-        f.seek(start)
-
-        while read < to_read:
-            if read + chunk_size > to_read:
-                chunk_size = to_read - read
-            chunk = f.read(chunk_size)
-            for hash_obj in hashes:
-                hash_obj.update(chunk)
-            read += chunk_size
-
-    result = []
-    for hash_obj in hashes:
-        result.append(hash_obj.hexdigest())
-
-    return result
-
-def get_md5sum(fpath):
-    return calc_hashes(fpath, ('md5', ))[0]
-
-
 def normalize_ksfile(ksconf, release, arch):
     '''
     Return the name of a normalized ks file in which macro variables
@@ -232,52 +103,3 @@ def normalize_ksfile(ksconf, release, arch):
     atexit.register(remove_temp_ks)
 
     return ksconf
-
-
-def selinux_check(arch, fstypes):
-    try:
-        getenforce = find_binary_path('getenforce')
-    except CreatorError:
-        return
-
-    selinux_status = runner.outs([getenforce])
-    if arch and arch.startswith("arm") and selinux_status == "Enforcing":
-        raise CreatorError("Can't create arm image if selinux is enabled, "
-                           "please run 'setenforce 0' to disable selinux")
-
-    use_btrfs = filter(lambda typ: typ == 'btrfs', fstypes)
-    if use_btrfs and selinux_status == "Enforcing":
-        raise CreatorError("Can't create btrfs image if selinux is enabled,"
-                           " please run 'setenforce 0' to disable selinux")
-
-def get_file_size(filename):
-    """ Return size in MB unit """
-    cmd = ['du', "-s", "-b", "-B", "1M", filename]
-    rc, duOutput  = runner.runtool(cmd)
-    if rc != 0:
-        raise CreatorError("Failed to run: %s" % ' '.join(cmd))
-    size1 = int(duOutput.split()[0])
-
-    cmd = ['du', "-s", "-B", "1M", filename]
-    rc, duOutput = runner.runtool(cmd)
-    if rc != 0:
-        raise CreatorError("Failed to run: %s" % ' '.join(cmd))
-
-    size2 = int(duOutput.split()[0])
-    return max(size1, size2)
-
-
-def get_filesystem_avail(fs):
-    vfstat = os.statvfs(fs)
-    return vfstat.f_bavail * vfstat.f_bsize
-
-def mkdtemp(dir = "/var/tmp", prefix = "wic-tmp-"):
-    """ FIXME: use the dir in wic.conf instead """
-
-    makedirs(dir)
-    return tempfile.mkdtemp(dir = dir, prefix = prefix)
-
-def strip_end(text, suffix):
-    if not text.endswith(suffix):
-        return text
-    return text[:-len(suffix)]
Signature · 1 line
1.8.3.1
#15 lore raw

PATCH 15/35 wic: Remove 3rdparty/urlgrabber

In reply to Tom Zanussi

wic doesn't use it, so remove it.

---
 .../3rdparty/pykickstart/urlgrabber/__init__.py    |   53 -
 .../3rdparty/pykickstart/urlgrabber/byterange.py   |  463 ------
 .../mic/3rdparty/pykickstart/urlgrabber/grabber.py | 1477 --------------------
 .../3rdparty/pykickstart/urlgrabber/keepalive.py   |  617 --------
 .../mic/3rdparty/pykickstart/urlgrabber/mirror.py  |  458 ------
 .../3rdparty/pykickstart/urlgrabber/progress.py    |  530 -------
 .../3rdparty/pykickstart/urlgrabber/sslfactory.py  |   90 --
 7 files changed, 3688 deletions(-)
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/urlgrabber/__init__.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/urlgrabber/byterange.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/urlgrabber/grabber.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/urlgrabber/keepalive.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/urlgrabber/mirror.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/urlgrabber/progress.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/urlgrabber/sslfactory.py

Patch too large to post - see git repository.

Signature · 1 line
1.8.3.1
#16 lore raw

Re: [PATCH 15/35] wic: Remove 3rdparty/urlgrabber

This commit breaks wic for me.
Urlgrabber is imported from pykickstart/version.py and pykickstart/parser.py.

Having python-urlgrabber installed in your distro hides this problem.

Signature · 1 line
Ola Nilsson
Quoted 46 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Tom Zanussi
Sent: den 9 augusti 2014 00:06
To: [email protected]
Cc: Tom Zanussi
Subject: [OE-core] [PATCH 15/35] wic: Remove 3rdparty/urlgrabber

wic doesn't use it, so remove it.

---
 .../3rdparty/pykickstart/urlgrabber/__init__.py    |   53 -
 .../3rdparty/pykickstart/urlgrabber/byterange.py   |  463 ------
 .../mic/3rdparty/pykickstart/urlgrabber/grabber.py | 1477 --------------------
 .../3rdparty/pykickstart/urlgrabber/keepalive.py   |  617 --------
 .../mic/3rdparty/pykickstart/urlgrabber/mirror.py  |  458 ------
 .../3rdparty/pykickstart/urlgrabber/progress.py    |  530 -------
 .../3rdparty/pykickstart/urlgrabber/sslfactory.py  |   90 --
 7 files changed, 3688 deletions(-)
 delete mode 100644
scripts/lib/mic/3rdparty/pykickstart/urlgrabber/__init__.py
 delete mode 100644
scripts/lib/mic/3rdparty/pykickstart/urlgrabber/byterange.py
 delete mode 100644
scripts/lib/mic/3rdparty/pykickstart/urlgrabber/grabber.py
 delete mode 100644
scripts/lib/mic/3rdparty/pykickstart/urlgrabber/keepalive.py
 delete mode 100644
scripts/lib/mic/3rdparty/pykickstart/urlgrabber/mirror.py
 delete mode 100644
scripts/lib/mic/3rdparty/pykickstart/urlgrabber/progress.py
 delete mode 100644

scripts/lib/mic/3rdparty/pykickstart/urlgrabber/sslfactory.py

Patch too large to post - see git repository.

--
1.8.3.1

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#17 lore raw

Re: [PATCH 15/35] wic: Remove 3rdparty/urlgrabber

Quoted 5 lines · Ola X Nilsson

This commit breaks wic for me.
Urlgrabber is imported from pykickstart/version.py and pykickstart/parser.py.

Having python-urlgrabber installed in your distro hides this problem.

Thanks for the report - I just posted a patch to fix this to the list - please try it out.

Thanks,

Tom

#18 lore raw

PATCH 16/35 wic: Remove unused 3rdparty/commands

In reply to Tom Zanussi

wic doesn't use anything but partition and bootloader, so remove the rest.

---
 .../mic/3rdparty/pykickstart/commands/__init__.py  |    8 +-
 .../3rdparty/pykickstart/commands/authconfig.py    |   40 -
 .../mic/3rdparty/pykickstart/commands/autopart.py  |  119 ---
 .../mic/3rdparty/pykickstart/commands/autostep.py  |   55 -
 .../mic/3rdparty/pykickstart/commands/clearpart.py |   86 --
 .../mic/3rdparty/pykickstart/commands/device.py    |  125 ---
 .../3rdparty/pykickstart/commands/deviceprobe.py   |   40 -
 .../3rdparty/pykickstart/commands/displaymode.py   |   68 --
 .../mic/3rdparty/pykickstart/commands/dmraid.py    |   91 --
 .../3rdparty/pykickstart/commands/driverdisk.py    |  184 ----
 .../lib/mic/3rdparty/pykickstart/commands/fcoe.py  |  114 --
 .../mic/3rdparty/pykickstart/commands/firewall.py  |  193 ----
 .../mic/3rdparty/pykickstart/commands/firstboot.py |   62 --
 .../lib/mic/3rdparty/pykickstart/commands/group.py |   88 --
 .../3rdparty/pykickstart/commands/ignoredisk.py    |  139 ---
 .../3rdparty/pykickstart/commands/interactive.py   |   58 --
 .../lib/mic/3rdparty/pykickstart/commands/iscsi.py |  133 ---
 .../mic/3rdparty/pykickstart/commands/iscsiname.py |   54 -
 .../lib/mic/3rdparty/pykickstart/commands/key.py   |   64 --
 .../mic/3rdparty/pykickstart/commands/keyboard.py  |   55 -
 .../lib/mic/3rdparty/pykickstart/commands/lang.py  |   60 --
 .../3rdparty/pykickstart/commands/langsupport.py   |   58 --
 .../mic/3rdparty/pykickstart/commands/lilocheck.py |   54 -
 .../mic/3rdparty/pykickstart/commands/logging.py   |   66 --
 .../mic/3rdparty/pykickstart/commands/logvol.py    |  304 ------
 .../3rdparty/pykickstart/commands/mediacheck.py    |   53 -
 .../mic/3rdparty/pykickstart/commands/method.py    |  186 ----
 .../mic/3rdparty/pykickstart/commands/monitor.py   |  106 --
 .../lib/mic/3rdparty/pykickstart/commands/mouse.py |   70 --
 .../mic/3rdparty/pykickstart/commands/multipath.py |  111 --
 .../mic/3rdparty/pykickstart/commands/network.py   |  363 -------
 .../lib/mic/3rdparty/pykickstart/commands/raid.py  |  365 -------
 .../mic/3rdparty/pykickstart/commands/reboot.py    |   79 --
 .../lib/mic/3rdparty/pykickstart/commands/repo.py  |  249 -----
 .../mic/3rdparty/pykickstart/commands/rescue.py    |   68 --
 .../mic/3rdparty/pykickstart/commands/rootpw.py    |   93 --
 .../mic/3rdparty/pykickstart/commands/selinux.py   |   64 --
 .../mic/3rdparty/pykickstart/commands/services.py  |   71 --
 .../lib/mic/3rdparty/pykickstart/commands/skipx.py |   54 -
 .../lib/mic/3rdparty/pykickstart/commands/sshpw.py |  105 --
 .../mic/3rdparty/pykickstart/commands/timezone.py  |   86 --
 .../mic/3rdparty/pykickstart/commands/updates.py   |   60 --
 .../mic/3rdparty/pykickstart/commands/upgrade.py   |  106 --
 .../lib/mic/3rdparty/pykickstart/commands/user.py  |  173 ----
 .../lib/mic/3rdparty/pykickstart/commands/vnc.py   |  114 --
 .../mic/3rdparty/pykickstart/commands/volgroup.py  |  102 --
 .../mic/3rdparty/pykickstart/commands/xconfig.py   |  184 ----
 .../mic/3rdparty/pykickstart/commands/zerombr.py   |   69 --
 .../lib/mic/3rdparty/pykickstart/commands/zfcp.py  |  134 ---
 .../mic/3rdparty/pykickstart/handlers/control.py   | 1092 --------------------
 50 files changed, 1 insertion(+), 6474 deletions(-)
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/authconfig.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/autopart.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/autostep.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/clearpart.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/device.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/deviceprobe.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/displaymode.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/dmraid.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/driverdisk.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/fcoe.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/firewall.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/firstboot.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/group.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/ignoredisk.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/interactive.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/iscsi.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/iscsiname.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/key.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/keyboard.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/lang.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/langsupport.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/lilocheck.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/logging.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/logvol.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/mediacheck.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/method.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/monitor.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/mouse.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/multipath.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/network.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/raid.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/reboot.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/repo.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/rescue.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/rootpw.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/selinux.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/services.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/skipx.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/sshpw.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/timezone.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/updates.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/upgrade.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/user.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/vnc.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/volgroup.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/xconfig.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/zerombr.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/commands/zfcp.py

Patch too large to post - see git repository.

Signature · 1 line
1.8.3.1
#19 lore raw

PATCH 17/35 wic: Remove gpt_parser

In reply to Tom Zanussi

wic doesn't currently use it, so remove.

---
 scripts/lib/mic/plugins/source/bootimg-efi.py    |   4 +-
 scripts/lib/mic/plugins/source/bootimg-pcbios.py |   8 +-
 scripts/lib/mic/utils/gpt_parser.py              | 331 -----------------------
 scripts/lib/mic/utils/partitionedfs.py           |  58 +---
 4 files changed, 11 insertions(+), 390 deletions(-)
 delete mode 100644 scripts/lib/mic/utils/gpt_parser.py
scripts/lib/mic/plugins/source/bootimg-efi.py +1 -3
index 95e1c05..d4a7771 100644
@@ -78,9 +78,7 @@ class BootimgEFIPlugin(SourcePlugin):
         if cr._ptable_format == 'msdos':
             rootstr = rootdev
         else:
-            if not root_part_uuid:
-                raise MountError("Cannot find the root GPT partition UUID")
-            rootstr = "PARTUUID=%s" % root_part_uuid
+            raise MountError("Unsupported partition table format found")
 
         grubefi_conf += "linux %s root=%s rootwait %s\n" \
             % (kernel, rootstr, options)
scripts/lib/mic/plugins/source/bootimg-pcbios.py +2 -6
index 9959645..3434320 100644
@@ -50,9 +50,7 @@ class BootimgPcbiosPlugin(SourcePlugin):
         disk image.  In this case, we install the MBR.
         """
         mbrfile = "%s/syslinux/" % bootimg_dir
-        if cr._ptable_format == 'gpt':
-            mbrfile += "gptmbr.bin"
-        else:
+        if cr._ptable_format == 'msdos':
             mbrfile += "mbr.bin"
 
         if not os.path.exists(mbrfile):
@@ -110,9 +108,7 @@ class BootimgPcbiosPlugin(SourcePlugin):
         if cr._ptable_format == 'msdos':
             rootstr = rootdev
         else:
-            if not root_part_uuid:
-                raise MountError("Cannot find the root GPT partition UUID")
-            rootstr = "PARTUUID=%s" % root_part_uuid
+            raise MountError("Unsupported partition table format found")
 
         syslinux_conf += "APPEND label=boot root=%s %s\n" % (rootstr, options)
 
scripts/lib/mic/utils/gpt_parser.py deleted +0 -331

331 lines not on this page · raw message

scripts/lib/mic/utils/partitionedfs.py +8 -50

117 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#20 lore raw

PATCH 18/35 wic: Remove unused plugin and error code

In reply to Tom Zanussi

wic doesn't use it, so remove it.

---
 scripts/lib/mic/plugin.py                  |  2 +-
 scripts/lib/mic/pluginbase.py              | 45 ++----------------------------
 scripts/lib/mic/plugins/hook/.py           |  0
 scripts/lib/mic/plugins/hook/empty_hook.py |  3 --
 scripts/lib/mic/utils/errors.py            | 21 --------------
 5 files changed, 3 insertions(+), 68 deletions(-)
 delete mode 100644 scripts/lib/mic/plugins/hook/.py
 delete mode 100644 scripts/lib/mic/plugins/hook/empty_hook.py
scripts/lib/mic/plugin.py +1 -1
index f836950..43afdbc 100644
@@ -24,7 +24,7 @@ from mic.utils.oe.misc import *
 
 __ALL__ = ['PluginMgr', 'pluginmgr']
 
-PLUGIN_TYPES = ["imager", "source"] # TODO  "hook"
+PLUGIN_TYPES = ["imager", "source"]
 
 PLUGIN_DIR = "/lib/mic/plugins" # relative to scripts
 SCRIPTS_PLUGIN_DIR = "scripts" + PLUGIN_DIR
scripts/lib/mic/pluginbase.py +2 -43

63 lines not on this page · raw message

scripts/lib/mic/plugins/hook/.py deleted +0 -0
deleted file mode 100644
index e69de29..0000000
scripts/lib/mic/plugins/hook/empty_hook.py deleted +0 -3
deleted file mode 100644
index 397585d..0000000
@@ -1,3 +0,0 @@
-#!/usr/bin/python
-
-# TODO: plugin base for hooks
scripts/lib/mic/utils/errors.py +0 -21
index 8d720f9..38fda30 100644
@@ -43,29 +43,8 @@ class Usage(CreatorError):
 class Abort(CreatorError):
     keyword = ''
 
-class ConfigError(CreatorError):
-    keyword = '<config>'
-
 class KsError(CreatorError):
     keyword = '<kickstart>'
 
-class RepoError(CreatorError):
-    keyword = '<repo>'
-
-class RpmError(CreatorError):
-    keyword = '<rpm>'
-
 class MountError(CreatorError):
     keyword = '<mount>'
-
-class SnapshotError(CreatorError):
-    keyword = '<snapshot>'
-
-class SquashfsError(CreatorError):
-    keyword = '<squashfs>'
-
-class BootstrapError(CreatorError):
-    keyword = '<bootstrap>'
-
-class RuntimeError(CreatorError):
-    keyword = '<runtime>'
Signature · 1 line
1.8.3.1
#21 lore raw

PATCH 19/35 wic: Clean up BaseImageCreator

In reply to Tom Zanussi

wic doesn't use a lot of BaseImageCreator, so remove it.

---
 scripts/lib/mic/imager/baseimager.py | 1030 +---------------------------------
 scripts/lib/mic/imager/direct.py     |    4 +-
 2 files changed, 9 insertions(+), 1025 deletions(-)
scripts/lib/mic/imager/baseimager.py +7 -1023
index b721249..55f2dea 100644
@@ -18,37 +18,31 @@
 
 from __future__ import with_statement
 import os, sys
-import stat
 import tempfile
 import shutil
-import subprocess
-import re
-import tarfile
-import glob
 
 from mic import kickstart
 from mic import msger
-from mic.utils.errors import CreatorError, Abort
+from mic.utils.errors import CreatorError
 from mic.utils import misc, runner, fs_related as fs
 
 class BaseImageCreator(object):
-    """Installs a system to a chroot directory.
+    """Base class for image creation.
 
-    ImageCreator is the simplest creator class available; it will install and
-    configure a system image according to the supplied kickstart file.
+    BaseImageCreator is the simplest creator class available; it will
+    create a system image according to the supplied kickstart file.
 
     e.g.
 
       import mic.imgcreate as imgcreate
       ks = imgcreate.read_kickstart("foo.ks")
       imgcreate.ImageCreator(ks, "foo").create()
-
     """
 
     def __del__(self):
         self.cleanup()
 
-    def __init__(self, createopts = None, pkgmgr = None):
+    def __init__(self, createopts = None):
         """Initialize an ImageCreator instance.
 
         ks -- a pykickstart.KickstartParser instance; this instance will be
@@ -59,36 +53,19 @@ class BaseImageCreator(object):
                 filesystem labels
         """
 
-        self.pkgmgr = pkgmgr
-
         self.__builddir = None
-        self.__bindmounts = []
 
         self.ks = None
         self.name = "target"
         self.tmpdir = "/var/tmp/wic"
-        self.cachedir = "/var/tmp/wic/cache"
         self.workdir = "/var/tmp/wic/build"
 
-        self.destdir = "."
-        self.installerfw_prefix = "INSTALLERFW_"
-        self.target_arch = "noarch"
-        self._local_pkgs_path = None
-        self.pack_to = None
-        self.repourl = {}
-
-        # If the kernel is save to the destdir when copy_kernel cmd is called.
-        self._need_copy_kernel = False
         # setup tmpfs tmpdir when enabletmpfs is True
         self.enabletmpfs = False
 
         if createopts:
             # Mapping table for variables that have different names.
-            optmap = {"pkgmgr" : "pkgmgr_name",
-                      "outdir" : "destdir",
-                      "arch" : "target_arch",
-                      "local_pkgs_path" : "_local_pkgs_path",
-                      "copy_kernel" : "_need_copy_kernel",
+            optmap = {"outdir" : "destdir",
                      }
 
             # update setting from createopts
@@ -101,41 +78,11 @@ class BaseImageCreator(object):
 
             self.destdir = os.path.abspath(os.path.expanduser(self.destdir))
 
-            if 'release' in createopts and createopts['release']:
-                self.name = createopts['release'] + '_' + self.name
-
-            if self.pack_to:
-                if '@NAME@' in self.pack_to:
-                    self.pack_to = self.pack_to.replace('@NAME@', self.name)
-                (tar, ext) = os.path.splitext(self.pack_to)
-                if ext in (".gz", ".bz2") and tar.endswith(".tar"):
-                    ext = ".tar" + ext
-                if ext not in misc.pack_formats:
-                    self.pack_to += ".tar"
-
-        self._dep_checks = ["ls", "bash", "cp", "echo", "modprobe"]
+        self._dep_checks = ["ls", "bash", "cp", "echo"]
 
         # Output image file names
         self.outimage = []
 
-        # A flag to generate checksum
-        self._genchecksum = False
-
-        self._alt_initrd_name = None
-
-        self._recording_pkgs = []
-
-        # available size in root fs, init to 0
-        self._root_fs_avail = 0
-
-        # Name of the disk image file that is created.
-        self._img_name = None
-
-        self.image_format = None
-
-        # Save qemu emulator file name in order to clean up it finally
-        self.qemu_emulator = None
-
         # No ks provided when called by convertor, so skip the dependency check
         if self.ks:
             # If we have btrfs partition we need to check necessary tools
@@ -144,31 +91,9 @@ class BaseImageCreator(object):
                     self._dep_checks.append("mkfs.btrfs")
                     break
 
-        if self.target_arch and self.target_arch.startswith("arm"):
-            for dep in self._dep_checks:
-                if dep == "extlinux":
-                    self._dep_checks.remove(dep)
-
-            if not os.path.exists("/usr/bin/qemu-arm") or \
-               not misc.is_statically_linked("/usr/bin/qemu-arm"):
-                self._dep_checks.append("qemu-arm-static")
-
-            if os.path.exists("/proc/sys/vm/vdso_enabled"):
-                vdso_fh = open("/proc/sys/vm/vdso_enabled","r")
-                vdso_value = vdso_fh.read().strip()
-                vdso_fh.close()
-                if (int)(vdso_value) == 1:
-                    msger.warning("vdso is enabled on your host, which might "
-                        "cause problems with arm emulations.\n"
-                        "\tYou can disable vdso with following command before "
-                        "starting image build:\n"
-                        "\techo 0 | sudo tee /proc/sys/vm/vdso_enabled")
-
         # make sure the specified tmpdir and cachedir exist
         if not os.path.exists(self.tmpdir):
             os.makedirs(self.tmpdir)
-        if not os.path.exists(self.cachedir):
-            os.makedirs(self.cachedir)
 
 
     #
@@ -190,23 +115,6 @@ class BaseImageCreator(object):
 
     """
 
-    def __get_outdir(self):
-        if self.__builddir is None:
-            raise CreatorError("_outdir is not valid before calling mount()")
-        return self.__builddir + "/out"
-    _outdir = property(__get_outdir)
-    """The staging location for the final image.
-
-    This is where subclasses should stage any files that are part of the final
-    image. ImageCreator.package() will copy any files found here into the
-    requested destination directory.
-
-    Note, this directory does not exist before ImageCreator.mount() is called.
-
-    Note also, this is a read-only attribute.
-
-    """
-
 
     #
     # Hooks for subclasses
@@ -239,408 +147,6 @@ class BaseImageCreator(object):
         """
         pass
 
-    def _create_bootconfig(self):
-        """Configure the image so that it's bootable.
-
-        This is the hook where subclasses may prepare the image for booting by
-        e.g. creating an initramfs and bootloader configuration.
-
-        This hook is called while the install root is still mounted, after the
-        packages have been installed and the kickstart configuration has been
-        applied, but before the %post scripts have been executed.
-
-        There is no default implementation.
-
-        """
-        pass
-
-    def _stage_final_image(self):
-        """Stage the final system image in _outdir.
-
-        This is the hook where subclasses should place the image in _outdir
-        so that package() can copy it to the requested destination directory.
-
-        By default, this moves the install root into _outdir.
-
-        """
-        shutil.move(self._instroot, self._outdir + "/" + self.name)
-
-    def get_installed_packages(self):
-        return self._pkgs_content.keys()
-
-    def _save_recording_pkgs(self, destdir):
-        """Save the list or content of installed packages to file.
-        """
-        pkgs = self._pkgs_content.keys()
-        pkgs.sort() # inplace op
-
-        if not os.path.exists(destdir):
-            os.makedirs(destdir)
-
-        content = None
-        if 'vcs' in self._recording_pkgs:
-            vcslst = ["%s %s" % (k, v) for (k, v) in self._pkgs_vcsinfo.items()]
-            content = '\n'.join(sorted(vcslst))
-        elif 'name' in self._recording_pkgs:
-            content = '\n'.join(pkgs)
-        if content:
-            namefile = os.path.join(destdir, self.name + '.packages')
-            f = open(namefile, "w")
-            f.write(content)
-            f.close()
-            self.outimage.append(namefile);
-
-        # if 'content', save more details
-        if 'content' in self._recording_pkgs:
-            contfile = os.path.join(destdir, self.name + '.files')
-            f = open(contfile, "w")
-
-            for pkg in pkgs:
-                content = pkg + '\n'
-
-                pkgcont = self._pkgs_content[pkg]
-                content += '    '
-                content += '\n    '.join(pkgcont)
-                content += '\n'
-
-                content += '\n'
-                f.write(content)
-            f.close()
-            self.outimage.append(contfile)
-
-        if 'license' in self._recording_pkgs:
-            licensefile = os.path.join(destdir, self.name + '.license')
-            f = open(licensefile, "w")
-
-            f.write('Summary:\n')
-            for license in reversed(sorted(self._pkgs_license, key=\
-                            lambda license: len(self._pkgs_license[license]))):
-                f.write("    - %s: %s\n" \
-                        % (license, len(self._pkgs_license[license])))
-
-            f.write('\nDetails:\n')
-            for license in reversed(sorted(self._pkgs_license, key=\
-                            lambda license: len(self._pkgs_license[license]))):
-                f.write("    - %s:\n" % (license))
-                for pkg in sorted(self._pkgs_license[license]):
-                    f.write("        - %s\n" % (pkg))
-                f.write('\n')
-
-            f.close()
-            self.outimage.append(licensefile)
-
-    def _get_required_packages(self):
-        """Return a list of required packages.
-
-        This is the hook where subclasses may specify a set of packages which
-        it requires to be installed.
-
-        This returns an empty list by default.
-
-        Note, subclasses should usually chain up to the base class
-        implementation of this hook.
-
-        """
-        return []
-
-    def _get_excluded_packages(self):
-        """Return a list of excluded packages.
-
-        This is the hook where subclasses may specify a set of packages which
-        it requires _not_ to be installed.
-
-        This returns an empty list by default.
-
-        Note, subclasses should usually chain up to the base class
-        implementation of this hook.
-
-        """
-        return []
-
-    def _get_local_packages(self):
-        """Return a list of rpm path to be local installed.
-
-        This is the hook where subclasses may specify a set of rpms which
-        it requires to be installed locally.
-
-        This returns an empty list by default.
-
-        Note, subclasses should usually chain up to the base class
-        implementation of this hook.
-
-        """
-        if self._local_pkgs_path:
-            if os.path.isdir(self._local_pkgs_path):
-                return glob.glob(
-                        os.path.join(self._local_pkgs_path, '*.rpm'))
-            elif os.path.splitext(self._local_pkgs_path)[-1] == '.rpm':
-                return [self._local_pkgs_path]
-
-        return []
-
-    def _get_fstab(self):
-        """Return the desired contents of /etc/fstab.
-
-        This is the hook where subclasses may specify the contents of
-        /etc/fstab by returning a string containing the desired contents.
-
-        A sensible default implementation is provided.
-
-        """
-        s =  "/dev/root  /         %s    %s 0 0\n" \
-             % (self._fstype,
-                "defaults,noatime" if not self._fsopts else self._fsopts)
-        s += self._get_fstab_special()
-        return s
-
-    def _get_fstab_special(self):
-        s = "devpts     /dev/pts  devpts  gid=5,mode=620   0 0\n"
-        s += "tmpfs      /dev/shm  tmpfs   defaults         0 0\n"
-        s += "proc       /proc     proc    defaults         0 0\n"
-        s += "sysfs      /sys      sysfs   defaults         0 0\n"
-        return s
-
-    def _set_part_env(self, pnum, prop, value):
-        """ This is a helper function which generates an environment variable
-        for a property "prop" with value "value" of a partition number "pnum".
-
-        The naming convention is:
-           * Variables start with INSTALLERFW_PART
-           * Then goes the partition number, the order is the same as
-             specified in the KS file
-           * Then goes the property name
-        """
-
-        if value == None:
-            value = ""
-        else:
-            value = str(value)
-
-        name = self.installerfw_prefix + ("PART%d_" % pnum) + prop
-        return { name : value }
-
-    def _get_post_scripts_env(self, in_chroot):
-        """Return an environment dict for %post scripts.
-
-        This is the hook where subclasses may specify some environment
-        variables for %post scripts by return a dict containing the desired
-        environment.
-
-        in_chroot -- whether this %post script is to be executed chroot()ed
-                     into _instroot.
-        """
-
-        env = {}
-        pnum = 0
-
-        for p in kickstart.get_partitions(self.ks):
-            env.update(self._set_part_env(pnum, "SIZE", p.size))
-            env.update(self._set_part_env(pnum, "MOUNTPOINT", p.mountpoint))
-            env.update(self._set_part_env(pnum, "FSTYPE", p.fstype))
-            env.update(self._set_part_env(pnum, "LABEL", p.label))
-            env.update(self._set_part_env(pnum, "FSOPTS", p.fsopts))
-            env.update(self._set_part_env(pnum, "BOOTFLAG", p.active))
-            env.update(self._set_part_env(pnum, "ALIGN", p.align))
-            env.update(self._set_part_env(pnum, "TYPE_ID", p.part_type))
-            env.update(self._set_part_env(pnum, "DEVNODE",
-                                          "/dev/%s%d" % (p.disk, pnum + 1)))
-            pnum += 1
-
-        # Count of paritions
-        env[self.installerfw_prefix + "PART_COUNT"] = str(pnum)
-
-        # Partition table format
-        ptable_format = self.ks.handler.bootloader.ptable
-        env[self.installerfw_prefix + "PTABLE_FORMAT"] = ptable_format
-
-        # The kerned boot parameters
-        kernel_opts = self.ks.handler.bootloader.appendLine
-        env[self.installerfw_prefix + "KERNEL_OPTS"] = kernel_opts
-
-        # Name of the distribution
-        env[self.installerfw_prefix + "DISTRO_NAME"] = self.distro_name
-
-        # Name of the image creation tool
-        env[self.installerfw_prefix + "INSTALLER_NAME"] = "wic"
-
-        # The real current location of the mounted file-systems
-        if in_chroot:
-            mount_prefix = "/"
-        else:
-            mount_prefix = self._instroot
-        env[self.installerfw_prefix + "MOUNT_PREFIX"] = mount_prefix
-
-        # These are historical variables which lack the common name prefix
-        if not in_chroot:
-            env["INSTALL_ROOT"] = self._instroot
-            env["IMG_NAME"] = self._name
-
-        return env
-
-    def __get_imgname(self):
-        return self.name
-    _name = property(__get_imgname)
-    """The name of the image file.
-
-    """
-
-    def _get_kernel_versions(self):
-        """Return a dict detailing the available kernel types/versions.
-
-        This is the hook where subclasses may override what kernel types and
-        versions should be available for e.g. creating the booloader
-        configuration.
-
-        A dict should be returned mapping the available kernel types to a list
-        of the available versions for those kernels.
-
-        The default implementation uses rpm to iterate over everything
-        providing 'kernel', finds /boot/vmlinuz-* and returns the version
-        obtained from the vmlinuz filename. (This can differ from the kernel
-        RPM's n-v-r in the case of e.g. xen)
-
-        """
-        def get_kernel_versions(instroot):
-            ret = {}
-            versions = set()
-            files = glob.glob(instroot + "/boot/vmlinuz-*")
-            for file in files:
-                version = os.path.basename(file)[8:]
-                if version is None:
-                    continue
-                versions.add(version)
-            ret["kernel"] = list(versions)
-            return ret
-
-        def get_version(header):
-            version = None
-            for f in header['filenames']:
-                if f.startswith('/boot/vmlinuz-'):
-                    version = f[14:]
-            return version
-
-        if self.ks is None:
-            return get_kernel_versions(self._instroot)
-
-        ts = rpm.TransactionSet(self._instroot)
-
-        ret = {}
-        for header in ts.dbMatch('provides', 'kernel'):
-            version = get_version(header)
-            if version is None:
-                continue
-
-            name = header['name']
-            if not name in ret:
-                ret[name] = [version]
-            elif not version in ret[name]:
-                ret[name].append(version)
-
-        return ret
-
-
-    #
-    # Helpers for subclasses
-    #
-    def _do_bindmounts(self):
-        """Mount various system directories onto _instroot.
-
-        This method is called by mount(), but may also be used by subclasses
-        in order to re-mount the bindmounts after modifying the underlying
-        filesystem.
-
-        """
-        for b in self.__bindmounts:
-            b.mount()
-
-    def _undo_bindmounts(self):
-        """Unmount the bind-mounted system directories from _instroot.
-
-        This method is usually only called by unmount(), but may also be used
-        by subclasses in order to gain access to the filesystem obscured by
-        the bindmounts - e.g. in order to create device nodes on the image
-        filesystem.
-
-        """
-        self.__bindmounts.reverse()
-        for b in self.__bindmounts:
-            b.unmount()
-
-    def _chroot(self):
-        """Chroot into the install root.
-
-        This method may be used by subclasses when executing programs inside
-        the install root e.g.
-
-          subprocess.call(["/bin/ls"], preexec_fn = self.chroot)
-
-        """
-        os.chroot(self._instroot)
-        os.chdir("/")
-
-    def _mkdtemp(self, prefix = "tmp-"):
-        """Create a temporary directory.
-
-        This method may be used by subclasses to create a temporary directory
-        for use in building the final image - e.g. a subclass might create
-        a temporary directory in order to bundle a set of files into a package.
-
-        The subclass may delete this directory if it wishes, but it will be
-        automatically deleted by cleanup().
-
-        The absolute path to the temporary directory is returned.
-
-        Note, this method should only be called after mount() has been called.
-
-        prefix -- a prefix which should be used when creating the directory;
-                  defaults to "tmp-".
-
-        """
-        self.__ensure_builddir()
-        return tempfile.mkdtemp(dir = self.__builddir, prefix = prefix)
-
-    def _mkstemp(self, prefix = "tmp-"):
-        """Create a temporary file.
-
-        This method may be used by subclasses to create a temporary file
-        for use in building the final image - e.g. a subclass might need
-        a temporary location to unpack a compressed file.
-
-        The subclass may delete this file if it wishes, but it will be
-        automatically deleted by cleanup().
-
-        A tuple containing a file descriptor (returned from os.open() and the
-        absolute path to the temporary directory is returned.
-
-        Note, this method should only be called after mount() has been called.
-
-        prefix -- a prefix which should be used when creating the file;
-                  defaults to "tmp-".
-
-        """
-        self.__ensure_builddir()
-        return tempfile.mkstemp(dir = self.__builddir, prefix = prefix)
-
-    def _mktemp(self, prefix = "tmp-"):
-        """Create a temporary file.
-
-        This method simply calls _mkstemp() and closes the returned file
-        descriptor.
-
-        The absolute path to the temporary file is returned.
-
-        Note, this method should only be called after mount() has been called.
-
-        prefix -- a prefix which should be used when creating the file;
-                  defaults to "tmp-".
-
-        """
-
-        (f, path) = self._mkstemp(prefix)
-        os.close(f)
-        return path
-
-
     #
     # Actual implementation
     #
@@ -658,64 +164,6 @@ class BaseImageCreator(object):
             raise CreatorError("Failed create build directory in %s: %s" %
                                (self.tmpdir, msg))
 
-    def get_cachedir(self, cachedir = None):
-        if self.cachedir:
-            return self.cachedir
-
-        self.__ensure_builddir()
-        if cachedir:
-            self.cachedir = cachedir
-        else:
-            self.cachedir = self.__builddir + "/wic-cache"
-        fs.makedirs(self.cachedir)
-        return self.cachedir
-
-    def __sanity_check(self):
-        """Ensure that the config we've been given is sane."""
-        if not (kickstart.get_packages(self.ks) or
-                kickstart.get_groups(self.ks)):
-            raise CreatorError("No packages or groups specified")
-
-        kickstart.convert_method_to_repo(self.ks)
-
-        if not kickstart.get_repos(self.ks):
-            raise CreatorError("No repositories specified")
-
-    def __write_fstab(self):
-        fstab_contents = self._get_fstab()
-        if fstab_contents:
-            fstab = open(self._instroot + "/etc/fstab", "w")
-            fstab.write(fstab_contents)
-            fstab.close()
-
-    def __create_minimal_dev(self):
-        """Create a minimal /dev so that we don't corrupt the host /dev"""
-        origumask = os.umask(0000)
-        devices = (('null',   1, 3, 0666),
-                   ('urandom',1, 9, 0666),
-                   ('random', 1, 8, 0666),
-                   ('full',   1, 7, 0666),
-                   ('ptmx',   5, 2, 0666),
-                   ('tty',    5, 0, 0666),
-                   ('zero',   1, 5, 0666))
-
-        links = (("/proc/self/fd", "/dev/fd"),
-                 ("/proc/self/fd/0", "/dev/stdin"),
-                 ("/proc/self/fd/1", "/dev/stdout"),
-                 ("/proc/self/fd/2", "/dev/stderr"))
-
-        for (node, major, minor, perm) in devices:
-            if not os.path.exists(self._instroot + "/dev/" + node):
-                os.mknod(self._instroot + "/dev/" + node,
-                         perm | stat.S_IFCHR,
-                         os.makedev(major,minor))
-
-        for (src, dest) in links:
-            if not os.path.exists(self._instroot + dest):
-                os.symlink(src, self._instroot + dest)
-
-        os.umask(origumask)
-
     def __setup_tmpdir(self):
         if not self.enabletmpfs:
             return
@@ -789,338 +237,6 @@ class BaseImageCreator(object):
 
         self.__clean_tmpdir()
 
-    def __is_excluded_pkg(self, pkg):
-        if pkg in self._excluded_pkgs:
-            self._excluded_pkgs.remove(pkg)
-            return True
-
-        for xpkg in self._excluded_pkgs:
-            if xpkg.endswith('*'):
-                if pkg.startswith(xpkg[:-1]):
-                    return True
-            elif xpkg.startswith('*'):
-                if pkg.endswith(xpkg[1:]):
-                    return True
-
-        return None
-
-    def __select_packages(self, pkg_manager):
-        skipped_pkgs = []
-        for pkg in self._required_pkgs:
-            e = pkg_manager.selectPackage(pkg)
-            if e:
-                if kickstart.ignore_missing(self.ks):
-                    skipped_pkgs.append(pkg)
-                elif self.__is_excluded_pkg(pkg):
-                    skipped_pkgs.append(pkg)
-                else:
-                    raise CreatorError("Failed to find package '%s' : %s" %
-                                       (pkg, e))
-
-        for pkg in skipped_pkgs:
-            msger.warning("Skipping missing package '%s'" % (pkg,))
-
-    def __select_groups(self, pkg_manager):
-        skipped_groups = []
-        for group in self._required_groups:
-            e = pkg_manager.selectGroup(group.name, group.include)
-            if e:
-                if kickstart.ignore_missing(self.ks):
-                    skipped_groups.append(group)
-                else:
-                    raise CreatorError("Failed to find group '%s' : %s" %
-                                       (group.name, e))
-
-        for group in skipped_groups:
-            msger.warning("Skipping missing group '%s'" % (group.name,))
-
-    def __deselect_packages(self, pkg_manager):
-        for pkg in self._excluded_pkgs:
-            pkg_manager.deselectPackage(pkg)
-
-    def __localinst_packages(self, pkg_manager):
-        for rpm_path in self._get_local_packages():
-            pkg_manager.installLocal(rpm_path)
-
-    def __preinstall_packages(self, pkg_manager):
-        if not self.ks:
-            return
-
-        self._preinstall_pkgs = kickstart.get_pre_packages(self.ks)
-        for pkg in self._preinstall_pkgs:
-            pkg_manager.preInstall(pkg)
-
-    def __attachment_packages(self, pkg_manager):
-        if not self.ks:
-            return
-
-        self._attachment = []
-        for item in kickstart.get_attachment(self.ks):
-            if item.startswith('/'):
-                fpaths = os.path.join(self._instroot, item.lstrip('/'))
-                for fpath in glob.glob(fpaths):
-                    self._attachment.append(fpath)
-                continue
-
-            filelist = pkg_manager.getFilelist(item)
-            if filelist:
-                # found rpm in rootfs
-                for pfile in pkg_manager.getFilelist(item):
-                    fpath = os.path.join(self._instroot, pfile.lstrip('/'))
-                    self._attachment.append(fpath)
-                continue
-
-            # try to retrieve rpm file
-            (url, proxies) = pkg_manager.package_url(item)
-            if not url:
-                msger.warning("Can't get url from repo for %s" % item)
-                continue
-            fpath = os.path.join(self.cachedir, os.path.basename(url))
-            if not os.path.exists(fpath):
-                # download pkgs
-                try:
-                    fpath = grabber.myurlgrab(url, fpath, proxies, None)
-                except CreatorError:
-                    raise
-
-            tmpdir = self._mkdtemp()
-            misc.extract_rpm(fpath, tmpdir)
-            for (root, dirs, files) in os.walk(tmpdir):
-                for fname in files:
-                    fpath = os.path.join(root, fname)
-                    self._attachment.append(fpath)
-
-    def install(self, repo_urls=None):
-        """Install packages into the install root.
-
-        This function installs the packages listed in the supplied kickstart
-        into the install root. By default, the packages are installed from the
-        repository URLs specified in the kickstart.
-
-        repo_urls -- a dict which maps a repository name to a repository URL;
-                     if supplied, this causes any repository URLs specified in
-                     the kickstart to be overridden.
-
-        """
-
-        # initialize pkg list to install
-        if self.ks:
-            self.__sanity_check()
-
-            self._required_pkgs = \
-                kickstart.get_packages(self.ks, self._get_required_packages())
-            self._excluded_pkgs = \
-                kickstart.get_excluded(self.ks, self._get_excluded_packages())
-            self._required_groups = kickstart.get_groups(self.ks)
-        else:
-            self._required_pkgs = None
-            self._excluded_pkgs = None
-            self._required_groups = None
-
-        pkg_manager = self.get_pkg_manager()
-        pkg_manager.setup()
-
-        if hasattr(self, 'install_pkgs') and self.install_pkgs:
-            if 'debuginfo' in self.install_pkgs:
-                pkg_manager.install_debuginfo = True
-
-        for repo in kickstart.get_repos(self.ks, repo_urls):
-            (name, baseurl, mirrorlist, inc, exc,
-             proxy, proxy_username, proxy_password, debuginfo,
-             source, gpgkey, disable, ssl_verify, nocache,
-             cost, priority) = repo
-
-            yr = pkg_manager.addRepository(name, baseurl, mirrorlist, proxy,
-                        proxy_username, proxy_password, inc, exc, ssl_verify,
-                        nocache, cost, priority)
-
-        if kickstart.exclude_docs(self.ks):
-            rpm.addMacro("_excludedocs", "1")
-        rpm.addMacro("_dbpath", "/var/lib/rpm")
-        rpm.addMacro("__file_context_path", "%{nil}")
-        if kickstart.inst_langs(self.ks) != None:
-            rpm.addMacro("_install_langs", kickstart.inst_langs(self.ks))
-
-        try:
-            self.__preinstall_packages(pkg_manager)
-            self.__select_packages(pkg_manager)
-            self.__select_groups(pkg_manager)
-            self.__deselect_packages(pkg_manager)
-            self.__localinst_packages(pkg_manager)
-
-            BOOT_SAFEGUARD = 256L * 1024 * 1024 # 256M
-            checksize = self._root_fs_avail
-            if checksize:
-                checksize -= BOOT_SAFEGUARD
-            if self.target_arch:
-                pkg_manager._add_prob_flags(rpm.RPMPROB_FILTER_IGNOREARCH)
-            pkg_manager.runInstall(checksize)
-        except CreatorError, e:
-            raise
-        except  KeyboardInterrupt:
-            raise
-        else:
-            self._pkgs_content = pkg_manager.getAllContent()
-            self._pkgs_license = pkg_manager.getPkgsLicense()
-            self._pkgs_vcsinfo = pkg_manager.getVcsInfo()
-            self.__attachment_packages(pkg_manager)
-        finally:
-            pkg_manager.close()
-
-        # hook post install
-        self.postinstall()
-
-        # do some clean up to avoid lvm info leakage.  this sucks.
-        for subdir in ("cache", "backup", "archive"):
-            lvmdir = self._instroot + "/etc/lvm/" + subdir
-            try:
-                for f in os.listdir(lvmdir):
-                    os.unlink(lvmdir + "/" + f)
-            except:
-                pass
-
-    def postinstall(self):
-        self.copy_attachment()
-
-    def __run_post_scripts(self):
-        msger.info("Running scripts ...")
-        if os.path.exists(self._instroot + "/tmp"):
-            shutil.rmtree(self._instroot + "/tmp")
-        os.mkdir (self._instroot + "/tmp", 0755)
-        for s in kickstart.get_post_scripts(self.ks):
-            (fd, path) = tempfile.mkstemp(prefix = "ks-script-",
-                                          dir = self._instroot + "/tmp")
-
-            s.script = s.script.replace("\r", "")
-            os.write(fd, s.script)
-            os.close(fd)
-            os.chmod(path, 0700)
-
-            env = self._get_post_scripts_env(s.inChroot)
-
-            if not s.inChroot:
-                preexec = None
-                script = path
-            else:
-                preexec = self._chroot
-                script = "/tmp/" + os.path.basename(path)
-
-            try:
-                try:
-                    subprocess.call([s.interp, script],
-                                    preexec_fn = preexec,
-                                    env = env,
-                                    stdout = sys.stdout,
-                                    stderr = sys.stderr)
-                except OSError, (err, msg):
-                    raise CreatorError("Failed to execute %%post script "
-                                       "with '%s' : %s" % (s.interp, msg))
-            finally:
-                os.unlink(path)
-
-    def __save_repo_keys(self, repodata):
-        if not repodata:
-            return None
-
-        gpgkeydir = "/etc/pki/rpm-gpg"
-        fs.makedirs(self._instroot + gpgkeydir)
-        for repo in repodata:
-            if repo["repokey"]:
-                repokey = gpgkeydir + "/RPM-GPG-KEY-%s" %  repo["name"]
-                shutil.copy(repo["repokey"], self._instroot + repokey)
-
-    def configure(self, repodata = None):
-        """Configure the system image according to the kickstart.
-
-        This method applies the (e.g. keyboard or network) configuration
-        specified in the kickstart and executes the kickstart %post scripts.
-
-        If necessary, it also prepares the image to be bootable by e.g.
-        creating an initrd and bootloader configuration.
-
-        """
-        ksh = self.ks.handler
-
-        msger.info('Applying configurations ...')
-        try:
-            kickstart.LanguageConfig(self._instroot).apply(ksh.lang)
-            kickstart.KeyboardConfig(self._instroot).apply(ksh.keyboard)
-            kickstart.TimezoneConfig(self._instroot).apply(ksh.timezone)
-            #kickstart.AuthConfig(self._instroot).apply(ksh.authconfig)
-            kickstart.FirewallConfig(self._instroot).apply(ksh.firewall)
-            kickstart.RootPasswordConfig(self._instroot).apply(ksh.rootpw)
-            kickstart.UserConfig(self._instroot).apply(ksh.user)
-            kickstart.ServicesConfig(self._instroot).apply(ksh.services)
-            kickstart.XConfig(self._instroot).apply(ksh.xconfig)
-            kickstart.NetworkConfig(self._instroot).apply(ksh.network)
-            kickstart.RPMMacroConfig(self._instroot).apply(self.ks)
-            kickstart.DesktopConfig(self._instroot).apply(ksh.desktop)
-            self.__save_repo_keys(repodata)
-            kickstart.MoblinRepoConfig(self._instroot).apply(ksh.repo, repodata, self.repourl)
-        except:
-            msger.warning("Failed to apply configuration to image")
-            raise
-
-        self._create_bootconfig()
-        self.__run_post_scripts()
-
-    def launch_shell(self, launch):
-        """Launch a shell in the install root.
-
-        This method is launches a bash shell chroot()ed in the install root;
-        this can be useful for debugging.
-
-        """
-        if launch:
-            msger.info("Launching shell. Exit to continue.")
-            subprocess.call(["/bin/bash"], preexec_fn = self._chroot)
-
-    def do_genchecksum(self, image_name):
-        if not self._genchecksum:
-            return
-
-        md5sum = misc.get_md5sum(image_name)
-        with open(image_name + ".md5sum", "w") as f:
-            f.write("%s %s" % (md5sum, os.path.basename(image_name)))
-        self.outimage.append(image_name+".md5sum")
-
-    def package(self, destdir = "."):
-        """Prepares the created image for final delivery.
-
-        In its simplest form, this method merely copies the install root to the
-        supplied destination directory; other subclasses may choose to package
-        the image by e.g. creating a bootable ISO containing the image and
-        bootloader configuration.
-
-        destdir -- the directory into which the final image should be moved;
-                   this defaults to the current directory.
-
-        """
-        self._stage_final_image()
-
-        if not os.path.exists(destdir):
-            fs.makedirs(destdir)
-
-        if self._recording_pkgs:
-            self._save_recording_pkgs(destdir)
-
-        # For image formats with two or multiple image files, it will be
-        # better to put them under a directory
-        if self.image_format in ("raw", "vmdk", "vdi", "nand", "mrstnand"):
-            destdir = os.path.join(destdir, "%s-%s" \
-                                            % (self.name, self.image_format))
-            msger.debug("creating destination dir: %s" % destdir)
-            fs.makedirs(destdir)
-
-        # Ensure all data is flushed to _outdir
-        runner.quiet('sync')
-
-        misc.check_space_pre_cp(self._outdir, destdir)
-        for f in os.listdir(self._outdir):
-            shutil.move(os.path.join(self._outdir, f),
-                        os.path.join(destdir, f))
-            self.outimage.append(os.path.join(destdir, f))
-            self.do_genchecksum(os.path.join(destdir, f))
 
     def print_outimage_info(self):
         msg = "The new image can be found here:\n"
@@ -1129,135 +245,3 @@ class BaseImageCreator(object):
             msg += '  %s\n' % os.path.abspath(file)
 
         msger.info(msg)
-
-    def check_depend_tools(self):
-        for tool in self._dep_checks:
-            fs.find_binary_path(tool)
-
-    def package_output(self, image_format, destdir = ".", package="none"):
-        if not package or package == "none":
-            return
-
-        destdir = os.path.abspath(os.path.expanduser(destdir))
-        (pkg, comp) = os.path.splitext(package)
-        if comp:
-            comp=comp.lstrip(".")
-
-        if pkg == "tar":
-            if comp:
-                dst = "%s/%s-%s.tar.%s" %\
-                      (destdir, self.name, image_format, comp)
-            else:
-                dst = "%s/%s-%s.tar" %\
-                      (destdir, self.name, image_format)
-
-            msger.info("creating %s" % dst)
-            tar = tarfile.open(dst, "w:" + comp)
-
-            for file in self.outimage:
-                msger.info("adding %s to %s" % (file, dst))
-                tar.add(file,
-                        arcname=os.path.join("%s-%s" \
-                                           % (self.name, image_format),
-                                              os.path.basename(file)))
-                if os.path.isdir(file):
-                    shutil.rmtree(file, ignore_errors = True)
-                else:
-                    os.remove(file)
-
-            tar.close()
-
-            '''All the file in outimage has been packaged into tar.* file'''
-            self.outimage = [dst]
-
-    def release_output(self, config, destdir, release):
-        """ Create release directory and files
-        """
-
-        def _rpath(fn):
-            """ release path """
-            return os.path.join(destdir, fn)
-
-        outimages = self.outimage
-
-        # new ks
-        new_kspath = _rpath(self.name+'.ks')
-        with open(config) as fr:
-            with open(new_kspath, "w") as wf:
-                # When building a release we want to make sure the .ks
-                # file generates the same build even when --release not used.
-                wf.write(fr.read().replace("@BUILD_ID@", release))
-        outimages.append(new_kspath)
-
-        # save log file, logfile is only available in creator attrs
-        if hasattr(self, 'logfile') and not self.logfile:
-            log_path = _rpath(self.name + ".log")
-            # touch the log file, else outimages will filter it out
-            with open(log_path, 'w') as wf:
-                wf.write('')
-            msger.set_logfile(log_path)
-            outimages.append(_rpath(self.name + ".log"))
-
-        # rename iso and usbimg
-        for f in os.listdir(destdir):
-            if f.endswith(".iso"):
-                newf = f[:-4] + '.img'
-            elif f.endswith(".usbimg"):
-                newf = f[:-7] + '.img'
-            else:
-                continue
-            os.rename(_rpath(f), _rpath(newf))
-            outimages.append(_rpath(newf))
-
-        # generate MD5SUMS
-        with open(_rpath("MD5SUMS"), "w") as wf:
-            for f in os.listdir(destdir):
-                if f == "MD5SUMS":
-                    continue
-
-                if os.path.isdir(os.path.join(destdir, f)):
-                    continue
-
-                md5sum = misc.get_md5sum(_rpath(f))
-                # There needs to be two spaces between the sum and
-                # filepath to match the syntax with md5sum.
-                # This way also md5sum -c MD5SUMS can be used by users
-                wf.write("%s *%s\n" % (md5sum, f))
-
-        outimages.append("%s/MD5SUMS" % destdir)
-
-        # Filter out the nonexist file
-        for fp in outimages[:]:
-            if not os.path.exists("%s" % fp):
-                outimages.remove(fp)
-
-    def copy_kernel(self):
-        """ Copy kernel files to the outimage directory.
-        NOTE: This needs to be called before unmounting the instroot.
-        """
-
-        if not self._need_copy_kernel:
-            return
-
-        if not os.path.exists(self.destdir):
-            os.makedirs(self.destdir)
-
-        for kernel in glob.glob("%s/boot/vmlinuz-*" % self._instroot):
-            kernelfilename = "%s/%s-%s" % (self.destdir,
-                                           self.name,
-                                           os.path.basename(kernel))
-            msger.info('copy kernel file %s as %s' % (os.path.basename(kernel),
-                                                      kernelfilename))
-            shutil.copy(kernel, kernelfilename)
-            self.outimage.append(kernelfilename)
-
-    def copy_attachment(self):
-        """ Subclass implement it to handle attachment files
-        NOTE: This needs to be called before unmounting the instroot.
-        """
-        pass
-
-    def get_pkg_manager(self):
-        return self.pkgmgr(target_arch = self.target_arch,
-                           instroot = self._instroot,
-                           cachedir = self.cachedir)
scripts/lib/mic/imager/direct.py +2 -2
index 7e2b63a..93f0cd9 100644
@@ -54,14 +54,14 @@ class DirectImageCreator(BaseImageCreator):
 
     def __init__(self, oe_builddir, image_output_dir, rootfs_dir, bootimg_dir,
                  kernel_dir, native_sysroot, hdddir, staging_data_dir,
-                 creatoropts=None, pkgmgr=None, compress_image=None,
+                 creatoropts=None, compress_image=None,
                  generate_bmap=None, fstab_entry="uuid"):
         """
         Initialize a DirectImageCreator instance.
 
         This method takes the same arguments as ImageCreator.__init__()
         """
-        BaseImageCreator.__init__(self, creatoropts, pkgmgr)
+        BaseImageCreator.__init__(self, creatoropts)
 
         self.__instimage = None
         self.__imgdir = None
Signature · 1 line
1.8.3.1
#22 lore raw

PATCH 20/35 wic: Clean up DirectImageCreator

In reply to Tom Zanussi

Remove what wic doesn't use from DirectImageCreator.

---
 scripts/lib/mic/imager/direct.py                | 8 +-------
 scripts/lib/mic/plugins/imager/direct_plugin.py | 5 +----
 2 files changed, 2 insertions(+), 11 deletions(-)
scripts/lib/mic/imager/direct.py +1 -7
index 93f0cd9..92473b5 100644
@@ -54,8 +54,7 @@ class DirectImageCreator(BaseImageCreator):
 
     def __init__(self, oe_builddir, image_output_dir, rootfs_dir, bootimg_dir,
                  kernel_dir, native_sysroot, hdddir, staging_data_dir,
-                 creatoropts=None, compress_image=None,
-                 generate_bmap=None, fstab_entry="uuid"):
+                 creatoropts=None):
         """
         Initialize a DirectImageCreator instance.
 
@@ -64,19 +63,14 @@ class DirectImageCreator(BaseImageCreator):
         BaseImageCreator.__init__(self, creatoropts)
 
         self.__instimage = None
-        self.__imgdir = None
         self.__disks = {}
         self.__disk_format = "direct"
         self._disk_names = []
         self._ptable_format = self.ks.handler.bootloader.ptable
-        self.use_uuid = fstab_entry == "uuid"
-        self.compress_image = compress_image
-        self.bmap_needed = generate_bmap
 
         self.oe_builddir = oe_builddir
         if image_output_dir:
             self.tmpdir = image_output_dir
-            self.cachedir = "%s/cache" % image_output_dir
         self.rootfs_dir = rootfs_dir
         self.bootimg_dir = bootimg_dir
         self.kernel_dir = kernel_dir
scripts/lib/mic/plugins/imager/direct_plugin.py +1 -4
index d3a0ba7..877aaf6 100644
@@ -88,10 +88,7 @@ class DirectPlugin(ImagerPlugin):
                                             native_sysroot,
                                             hdddir,
                                             staging_data_dir,
-                                            creatoropts,
-                                            None,
-                                            None,
-                                            None)
+                                            creatoropts)
 
         try:
             creator.mount(None, creatoropts["cachedir"])
Signature · 1 line
1.8.3.1
#23 lore raw

PATCH 21/35 wic: Clean up PartitionedMount

In reply to Tom Zanussi

wic doesn't use a lot of ParitionedMount, so remove it.

---
 scripts/lib/mic/utils/partitionedfs.py | 355 +--------------------------------
 1 file changed, 2 insertions(+), 353 deletions(-)
scripts/lib/mic/utils/partitionedfs.py +2 -353
index 0c4c9ec..ef92125 100644
@@ -33,18 +33,13 @@ MBR_OVERHEAD = 1
 SECTOR_SIZE = 512
 
 class PartitionedMount(Mount):
-    def __init__(self, mountdir, skipformat = False):
+    def __init__(self, mountdir):
         Mount.__init__(self, mountdir)
         self.disks = {}
         self.partitions = []
-        self.subvolumes = []
-        self.mapped = False
         self.mountOrder = []
         self.unmountOrder = []
         self.parted = find_binary_path("parted")
-        self.btrfscmd=None
-        self.skipformat = skipformat
-        self.snapshot_created = self.skipformat
         # Size of a sector used in calculations
         self.sector_size = SECTOR_SIZE
         self._partitions_layed_out = False
@@ -62,7 +57,6 @@ class PartitionedMount(Mount):
 
         self.disks[disk_name] = \
                 { 'disk': None,     # Disk object
-                  'mapped': False,  # True if kpartx mapping exists
                   'numpart': 0,     # Number of allocate partitions
                   'partitions': [], # Indexes to self.partitions
                   'offset': 0,      # Offset of next partition (in sectors)
@@ -98,40 +92,8 @@ class PartitionedMount(Mount):
         # Converting MB to sectors for parted
         size = size * 1024 * 1024 / self.sector_size
 
-        # We need to handle subvolumes for btrfs
-        if fstype == "btrfs" and fsopts and fsopts.find("subvol=") != -1:
-            self.btrfscmd=find_binary_path("btrfs")
-            subvol = None
-            opts = fsopts.split(",")
-            for opt in opts:
-                if opt.find("subvol=") != -1:
-                    subvol = opt.replace("subvol=", "").strip()
-                    break
-            if not subvol:
-                raise MountError("No subvolume: %s" % fsopts)
-            self.subvolumes.append({'size': size, # In sectors
-                                    'mountpoint': mountpoint, # Mount relative to chroot
-                                    'fstype': fstype, # Filesystem type
-                                    'fsopts': fsopts, # Filesystem mount options
-                                    'disk_name': disk_name, # physical disk name holding partition
-                                    'device': None, # kpartx device node for partition
-                                    'mount': None, # Mount object
-                                    'subvol': subvol, # Subvolume name
-                                    'boot': boot, # Bootable flag
-                                    'mounted': False # Mount flag
-                                   })
-
         # We still need partition for "/" or non-subvolume
-        if mountpoint == "/" or not fsopts or fsopts.find("subvol=") == -1:
-            # Don't need subvolume for "/" because it will be set as default subvolume
-            if fsopts and fsopts.find("subvol=") != -1:
-                opts = fsopts.split(",")
-                for opt in opts:
-                    if opt.strip().startswith("subvol="):
-                        opts.remove(opt)
-                        break
-                fsopts = ",".join(opts)
-
+        if mountpoint == "/" or not fsopts:
             part = { 'ks_pnum' : ks_pnum, # Partition number in the KS file
                      'size': size, # In sectors
                      'mountpoint': mountpoint, # Mount relative to chroot
@@ -283,10 +245,6 @@ class PartitionedMount(Mount):
     def __format_disks(self):
         self.layout_partitions()
 
-        if self.skipformat:
-            msger.debug("Skipping disk format, because skipformat flag is set.")
-            return
-
         for dev in self.disks.keys():
             d = self.disks[dev]
             msger.debug("Initializing partition table for %s" % \
@@ -346,103 +304,6 @@ class PartitionedMount(Mount):
                     self.__run_parted(["-s", d['disk'].device, "set",
                                        "%d" % p['num'], "lba", "off"])
 
-
-    def __map_partitions(self):
-        """Load it if dm_snapshot isn't loaded. """
-        load_module("dm_snapshot")
-
-        for dev in self.disks.keys():
-            d = self.disks[dev]
-            if d['mapped']:
-                continue
-
-            msger.debug("Running kpartx on %s" % d['disk'].device )
-            rc, kpartxOutput = runner.runtool([self.kpartx, "-l", "-v", d['disk'].device])
-            kpartxOutput = kpartxOutput.splitlines()
-
-            if rc != 0:
-                raise MountError("Failed to query partition mapping for '%s'" %
-                                 d['disk'].device)
-
-            # Strip trailing blank and mask verbose output
-            i = 0
-            while i < len(kpartxOutput) and kpartxOutput[i][0:4] != "loop":
-                i = i + 1
-            kpartxOutput = kpartxOutput[i:]
-
-            # Make sure kpartx reported the right count of partitions
-            if len(kpartxOutput) != d['numpart']:
-                # If this disk has more than 3 partitions, then in case of MBR
-                # paritions there is an extended parition. Different versions
-                # of kpartx behave differently WRT the extended partition -
-                # some map it, some ignore it. This is why we do the below hack
-                # - if kpartx reported one more partition and the partition
-                # table type is "msdos" and the amount of partitions is more
-                # than 3, we just assume kpartx mapped the extended parition
-                # and we remove it.
-                if len(kpartxOutput) == d['numpart'] + 1 \
-                   and d['ptable_format'] == 'msdos' and len(kpartxOutput) > 3:
-                    kpartxOutput.pop(3)
-                else:
-                    raise MountError("Unexpected number of partitions from " \
-                                     "kpartx: %d != %d" % \
-                                        (len(kpartxOutput), d['numpart']))
-
-            for i in range(len(kpartxOutput)):
-                line = kpartxOutput[i]
-                newdev = line.split()[0]
-                mapperdev = "/dev/mapper/" + newdev
-                loopdev = d['disk'].device + newdev[-1]
-
-                msger.debug("Dev %s: %s -> %s" % (newdev, loopdev, mapperdev))
-                pnum = d['partitions'][i]
-                self.partitions[pnum]['device'] = loopdev
-
-                # grub's install wants partitions to be named
-                # to match their parent device + partition num
-                # kpartx doesn't work like this, so we add compat
-                # symlinks to point to /dev/mapper
-                if os.path.lexists(loopdev):
-                    os.unlink(loopdev)
-                os.symlink(mapperdev, loopdev)
-
-            msger.debug("Adding partx mapping for %s" % d['disk'].device)
-            rc = runner.show([self.kpartx, "-v", "-a", d['disk'].device])
-
-            if rc != 0:
-                # Make sure that the device maps are also removed on error case.
-                # The d['mapped'] isn't set to True if the kpartx fails so
-                # failed mapping will not be cleaned on cleanup either.
-                runner.quiet([self.kpartx, "-d", d['disk'].device])
-                raise MountError("Failed to map partitions for '%s'" %
-                                 d['disk'].device)
-
-            # FIXME: there is a bit delay for multipath device setup,
-            # wait 10ms for the setup
-            import time
-            time.sleep(10)
-            d['mapped'] = True
-
-    def __unmap_partitions(self):
-        for dev in self.disks.keys():
-            d = self.disks[dev]
-            if not d['mapped']:
-                continue
-
-            msger.debug("Removing compat symlinks")
-            for pnum in d['partitions']:
-                if self.partitions[pnum]['device'] != None:
-                    os.unlink(self.partitions[pnum]['device'])
-                    self.partitions[pnum]['device'] = None
-
-            msger.debug("Unmapping %s" % d['disk'].device)
-            rc = runner.quiet([self.kpartx, "-d", d['disk'].device])
-            if rc != 0:
-                raise MountError("Failed to unmap partitions for '%s'" %
-                                 d['disk'].device)
-
-            d['mapped'] = False
-
     def __calculate_mountorder(self):
         msger.debug("Calculating mount order")
         for p in self.partitions:
@@ -457,7 +318,6 @@ class PartitionedMount(Mount):
     def cleanup(self):
         Mount.cleanup(self)
         if self.disks:
-            self.__unmap_partitions()
             for dev in self.disks.keys():
                 d = self.disks[dev]
                 try:
@@ -466,7 +326,6 @@ class PartitionedMount(Mount):
                     pass
 
     def unmount(self):
-        self.__unmount_subvolumes()
         for mp in self.unmountOrder:
             if mp == 'swap':
                 continue
@@ -478,217 +337,11 @@ class PartitionedMount(Mount):
 
             if p['mount'] != None:
                 try:
-                    # Create subvolume snapshot here
-                    if p['fstype'] == "btrfs" and p['mountpoint'] == "/" and not self.snapshot_created:
-                        self.__create_subvolume_snapshots(p, p["mount"])
                     p['mount'].cleanup()
                 except:
                     pass
                 p['mount'] = None
 
-    # Only for btrfs
-    def __get_subvolume_id(self, rootpath, subvol):
-        if not self.btrfscmd:
-            self.btrfscmd=find_binary_path("btrfs")
-        argv = [ self.btrfscmd, "subvolume", "list", rootpath ]
-
-        rc, out = runner.runtool(argv)
-        msger.debug(out)
-
-        if rc != 0:
-            raise MountError("Failed to get subvolume id from %s', return code: %d." % (rootpath, rc))
-
-        subvolid = -1
-        for line in out.splitlines():
-            if line.endswith(" path %s" % subvol):
-                subvolid = line.split()[1]
-                if not subvolid.isdigit():
-                    raise MountError("Invalid subvolume id: %s" % subvolid)
-                subvolid = int(subvolid)
-                break
-        return subvolid
-
-    def __create_subvolume_metadata(self, p, pdisk):
-        if len(self.subvolumes) == 0:
-            return
-
-        argv = [ self.btrfscmd, "subvolume", "list", pdisk.mountdir ]
-        rc, out = runner.runtool(argv)
-        msger.debug(out)
-
-        if rc != 0:
-            raise MountError("Failed to get subvolume id from %s', return code: %d." % (pdisk.mountdir, rc))
-
-        subvolid_items = out.splitlines()
-        subvolume_metadata = ""
-        for subvol in self.subvolumes:
-            for line in subvolid_items:
-                if line.endswith(" path %s" % subvol["subvol"]):
-                    subvolid = line.split()[1]
-                    if not subvolid.isdigit():
-                        raise MountError("Invalid subvolume id: %s" % subvolid)
-
-                    subvolid = int(subvolid)
-                    opts = subvol["fsopts"].split(",")
-                    for opt in opts:
-                        if opt.strip().startswith("subvol="):
-                            opts.remove(opt)
-                            break
-                    fsopts = ",".join(opts)
-                    subvolume_metadata += "%d\t%s\t%s\t%s\n" % (subvolid, subvol["subvol"], subvol['mountpoint'], fsopts)
-
-        if subvolume_metadata:
-            fd = open("%s/.subvolume_metadata" % pdisk.mountdir, "w")
-            fd.write(subvolume_metadata)
-            fd.close()
-
-    def __get_subvolume_metadata(self, p, pdisk):
-        subvolume_metadata_file = "%s/.subvolume_metadata" % pdisk.mountdir
-        if not os.path.exists(subvolume_metadata_file):
-            return
-
-        fd = open(subvolume_metadata_file, "r")
-        content = fd.read()
-        fd.close()
-
-        for line in content.splitlines():
-            items = line.split("\t")
-            if items and len(items) == 4:
-                self.subvolumes.append({'size': 0, # In sectors
-                                        'mountpoint': items[2], # Mount relative to chroot
-                                        'fstype': "btrfs", # Filesystem type
-                                        'fsopts': items[3] + ",subvol=%s" %  items[1], # Filesystem mount options
-                                        'disk_name': p['disk_name'], # physical disk name holding partition
-                                        'device': None, # kpartx device node for partition
-                                        'mount': None, # Mount object
-                                        'subvol': items[1], # Subvolume name
-                                        'boot': False, # Bootable flag
-                                        'mounted': False # Mount flag
-                                   })
-
-    def __create_subvolumes(self, p, pdisk):
-        """ Create all the subvolumes. """
-
-        for subvol in self.subvolumes:
-            argv = [ self.btrfscmd, "subvolume", "create", pdisk.mountdir + "/" + subvol["subvol"]]
-
-            rc = runner.show(argv)
-            if rc != 0:
-                raise MountError("Failed to create subvolume '%s', return code: %d." % (subvol["subvol"], rc))
-
-        # Set default subvolume, subvolume for "/" is default
-        subvol = None
-        for subvolume in self.subvolumes:
-            if subvolume["mountpoint"] == "/" and p['disk_name'] == subvolume['disk_name']:
-                subvol = subvolume
-                break
-
-        if subvol:
-            # Get default subvolume id
-            subvolid = self. __get_subvolume_id(pdisk.mountdir, subvol["subvol"])
-            # Set default subvolume
-            if subvolid != -1:
-                rc = runner.show([ self.btrfscmd, "subvolume", "set-default", "%d" % subvolid, pdisk.mountdir])
-                if rc != 0:
-                    raise MountError("Failed to set default subvolume id: %d', return code: %d." % (subvolid, rc))
-
-        self.__create_subvolume_metadata(p, pdisk)
-
-    def __mount_subvolumes(self, p, pdisk):
-        if self.skipformat:
-            # Get subvolume info
-            self.__get_subvolume_metadata(p, pdisk)
-            # Set default mount options
-            if len(self.subvolumes) != 0:
-                for subvol in self.subvolumes:
-                    if subvol["mountpoint"] == p["mountpoint"] == "/":
-                        opts = subvol["fsopts"].split(",")
-                        for opt in opts:
-                            if opt.strip().startswith("subvol="):
-                                opts.remove(opt)
-                                break
-                        pdisk.fsopts = ",".join(opts)
-                        break
-
-        if len(self.subvolumes) == 0:
-            # Return directly if no subvolumes
-            return
-
-        # Remount to make default subvolume mounted
-        rc = runner.show([self.umountcmd, pdisk.mountdir])
-        if rc != 0:
-            raise MountError("Failed to umount %s" % pdisk.mountdir)
-
-        rc = runner.show([self.mountcmd, "-o", pdisk.fsopts, pdisk.disk.device, pdisk.mountdir])
-        if rc != 0:
-            raise MountError("Failed to umount %s" % pdisk.mountdir)
-
-        for subvol in self.subvolumes:
-            if subvol["mountpoint"] == "/":
-                continue
-            subvolid = self. __get_subvolume_id(pdisk.mountdir, subvol["subvol"])
-            if subvolid == -1:
-                msger.debug("WARNING: invalid subvolume %s" % subvol["subvol"])
-                continue
-            # Replace subvolume name with subvolume ID
-            opts = subvol["fsopts"].split(",")
-            for opt in opts:
-                if opt.strip().startswith("subvol="):
-                    opts.remove(opt)
-                    break
-
-            opts.extend(["subvolrootid=0", "subvol=%s" % subvol["subvol"]])
-            fsopts = ",".join(opts)
-            subvol['fsopts'] = fsopts
-            mountpoint = self.mountdir + subvol['mountpoint']
-            makedirs(mountpoint)
-            rc = runner.show([self.mountcmd, "-o", fsopts, pdisk.disk.device, mountpoint])
-            if rc != 0:
-                raise MountError("Failed to mount subvolume %s to %s" % (subvol["subvol"], mountpoint))
-            subvol["mounted"] = True
-
-    def __unmount_subvolumes(self):
-        """ It may be called multiple times, so we need to chekc if it is still mounted. """
-        for subvol in self.subvolumes:
-            if subvol["mountpoint"] == "/":
-                continue
-            if not subvol["mounted"]:
-                continue
-            mountpoint = self.mountdir + subvol['mountpoint']
-            rc = runner.show([self.umountcmd, mountpoint])
-            if rc != 0:
-                raise MountError("Failed to unmount subvolume %s from %s" % (subvol["subvol"], mountpoint))
-            subvol["mounted"] = False
-
-    def __create_subvolume_snapshots(self, p, pdisk):
-        import time
-
-        if self.snapshot_created:
-            return
-
-        # Remount with subvolid=0
-        rc = runner.show([self.umountcmd, pdisk.mountdir])
-        if rc != 0:
-            raise MountError("Failed to umount %s" % pdisk.mountdir)
-        if pdisk.fsopts:
-            mountopts = pdisk.fsopts + ",subvolid=0"
-        else:
-            mountopts = "subvolid=0"
-        rc = runner.show([self.mountcmd, "-o", mountopts, pdisk.disk.device, pdisk.mountdir])
-        if rc != 0:
-            raise MountError("Failed to umount %s" % pdisk.mountdir)
-
-        # Create all the subvolume snapshots
-        snapshotts = time.strftime("%Y%m%d-%H%M")
-        for subvol in self.subvolumes:
-            subvolpath = pdisk.mountdir + "/" + subvol["subvol"]
-            snapshotpath = subvolpath + "_%s-1" % snapshotts
-            rc = runner.show([ self.btrfscmd, "subvolume", "snapshot", subvolpath, snapshotpath ])
-            if rc != 0:
-                raise MountError("Failed to create subvolume snapshot '%s' for '%s', return code: %d." % (snapshotpath, subvolpath, rc))
-
-        self.snapshot_created = True
-
     def __install_partition(self, num, source_file, start, size):
         """
         Install source_file contents into a partition.
@@ -734,7 +387,3 @@ class PartitionedMount(Mount):
         self.__calculate_mountorder()
 
         return
-
-    def resparse(self, size = None):
-        # Can't re-sparse a disk image - too hard
-        pass
Signature · 1 line
1.8.3.1
#24 lore raw

PATCH 22/35 wic: Clean up Creator

In reply to Tom Zanussi

wic doesn't use a lot of Creator, so remove it.

---
 scripts/lib/mic/creator.py | 176 ++-------------------------------------------
 1 file changed, 6 insertions(+), 170 deletions(-)
scripts/lib/mic/creator.py +6 -170
index 267928f..7c9ca6f 100644
@@ -44,7 +44,7 @@ class Creator(cmdln.Cmdln):
         # mix-in do_subcmd interface
         for subcmd, klass in pluginmgr.get_plugins('imager').iteritems():
             if not hasattr(klass, 'do_create'):
-                msger.warning("Unsurpport subcmd: %s" % subcmd)
+                msger.warning("Unsupported subcmd: %s" % subcmd)
                 continue
 
             func = getattr(klass, 'do_create')
@@ -65,59 +65,12 @@ class Creator(cmdln.Cmdln):
         optparser.add_option('-c', '--config', type='string', dest='config',
                              default=None,
                              help='Specify config file for mic')
-        optparser.add_option('-k', '--cachedir', type='string', action='store',
-                             dest='cachedir', default=None,
-                             help='Cache directory to store the downloaded')
         optparser.add_option('-o', '--outdir', type='string', action='store',
                              dest='outdir', default=None,
                              help='Output directory')
-        optparser.add_option('-A', '--arch', type='string', dest='arch',
-                             default=None,
-                             help='Specify repo architecture')
-        optparser.add_option('', '--release', type='string', dest='release',
-                             default=None, metavar='RID',
-                             help='Generate a release of RID with all necessary'
-                                  ' files, when @BUILD_ID@ is contained in '
-                                  'kickstart file, it will be replaced by RID')
-        optparser.add_option("", "--record-pkgs", type="string",
-                             dest="record_pkgs", default=None,
-                             help='Record the info of installed packages, '
-                                  'multiple values can be specified which '
-                                  'joined by ",", valid values: "name", '
-                                  '"content", "license", "vcs"')
-        optparser.add_option('', '--pkgmgr', type='string', dest='pkgmgr',
-                             default=None,
-                             help='Specify backend package manager')
-        optparser.add_option('', '--local-pkgs-path', type='string',
-                             dest='local_pkgs_path', default=None,
-                             help='Path for local pkgs(rpms) to be installed')
-        optparser.add_option('', '--runtime', type='string',
-                             dest='runtime', default=None,
-                             help='Specify  runtime mode, avaiable: bootstrap, native')
-        # --taring-to is alias to --pack-to
-        optparser.add_option('', '--taring-to', type='string',
-                             dest='pack_to', default=None,
-                             help=SUPPRESS_HELP)
-        optparser.add_option('', '--pack-to', type='string',
-                             dest='pack_to', default=None,
-                             help='Pack the images together into the specified'
-                                  ' achive, extension supported: .zip, .tar, '
-                                  '.tar.gz, .tar.bz2, etc. by default, .tar '
-                                  'will be used')
-        optparser.add_option('', '--copy-kernel', action='store_true',
-                             dest='copy_kernel',
-                             help='Copy kernel files from image /boot directory'
-                                  ' to the image output directory.')
-        optparser.add_option('', '--install-pkgs', type='string', action='store',
-                             dest='install_pkgs', default=None,
-                             help='Specify what type of packages to be installed,'
-                                  ' valid: source, debuginfo, debugsource')
         optparser.add_option('', '--tmpfs', action='store_true', dest='enabletmpfs',
                              help='Setup tmpdir as tmpfs to accelerate, experimental'
                                   ' feature, use it if you have more than 4G memory')
-        optparser.add_option('', '--repourl', action='append',
-                             dest='repourl', default=[],
-                             help=SUPPRESS_HELP)
         return optparser
 
     def preoptparse(self, argv):
@@ -183,78 +136,16 @@ class Creator(cmdln.Cmdln):
 
         if self.options.outdir is not None:
             configmgr.create['outdir'] = abspath(self.options.outdir)
-        if self.options.cachedir is not None:
-            configmgr.create['cachedir'] = abspath(self.options.cachedir)
-        os.environ['ZYPP_LOCKFILE_ROOT'] = configmgr.create['cachedir']
-
-        for cdir in ('outdir', 'cachedir'):
-            if os.path.exists(configmgr.create[cdir]) \
-              and not os.path.isdir(configmgr.create[cdir]):
-                msger.error('Invalid directory specified: %s' \
-                            % configmgr.create[cdir])
-
-        if self.options.local_pkgs_path is not None:
-            if not os.path.exists(self.options.local_pkgs_path):
-                msger.error('Local pkgs directory: \'%s\' not exist' \
-                              % self.options.local_pkgs_path)
-            configmgr.create['local_pkgs_path'] = self.options.local_pkgs_path
-
-        if self.options.release:
-            configmgr.create['release'] = self.options.release.rstrip('/')
-
-        if self.options.record_pkgs:
-            configmgr.create['record_pkgs'] = []
-            for infotype in self.options.record_pkgs.split(','):
-                if infotype not in ('name', 'content', 'license', 'vcs'):
-                    raise errors.Usage('Invalid pkg recording: %s, valid ones:'
-                                       ' "name", "content", "license", "vcs"' \
-                                       % infotype)
-
-                configmgr.create['record_pkgs'].append(infotype)
-
-        if self.options.arch is not None:
-            supported_arch = sorted(rpmmisc.archPolicies.keys(), reverse=True)
-            if self.options.arch in supported_arch:
-                configmgr.create['arch'] = self.options.arch
-            else:
-                raise errors.Usage('Invalid architecture: "%s".\n'
-                                   '  Supported architectures are: \n'
-                                   '  %s' % (self.options.arch,
-                                               ', '.join(supported_arch)))
-
-        if self.options.pkgmgr is not None:
-            configmgr.create['pkgmgr'] = self.options.pkgmgr
 
-        if self.options.runtime:
-            configmgr.set_runtime(self.options.runtime)
-
-        if self.options.pack_to is not None:
-            configmgr.create['pack_to'] = self.options.pack_to
-
-        if self.options.copy_kernel:
-            configmgr.create['copy_kernel'] = self.options.copy_kernel
-
-        if self.options.install_pkgs:
-            configmgr.create['install_pkgs'] = []
-            for pkgtype in self.options.install_pkgs.split(','):
-                if pkgtype not in ('source', 'debuginfo', 'debugsource'):
-                    raise errors.Usage('Invalid parameter specified: "%s", '
-                                       'valid values: source, debuginfo, '
-                                       'debusource' % pkgtype)
-
-                configmgr.create['install_pkgs'].append(pkgtype)
+        cdir = 'outdir'
+        if os.path.exists(configmgr.create[cdir]) \
+           and not os.path.isdir(configmgr.create[cdir]):
+            msger.error('Invalid directory specified: %s' \
+                        % configmgr.create[cdir])
 
         if self.options.enabletmpfs:
             configmgr.create['enabletmpfs'] = self.options.enabletmpfs
 
-        if self.options.repourl:
-            for item in self.options.repourl:
-                try:
-                    key, val = item.split('=')
-                except:
-                    continue
-                configmgr.create['repourl'][key] = val
-
     def main(self, argv=None):
         if argv is None:
             argv = sys.argv
@@ -294,58 +185,3 @@ class Creator(cmdln.Cmdln):
             return ['help', argv[0]]
 
         return argv
-
-    def do_auto(self, subcmd, opts, *args):
-        """${cmd_name}: auto detect image type from magic header
-
-        Usage:
-            ${name} ${cmd_name} <ksfile>
-
-        ${cmd_option_list}
-        """
-        def parse_magic_line(re_str, pstr, ptype='mic'):
-            ptn = re.compile(re_str)
-            m = ptn.match(pstr)
-            if not m or not m.groups():
-                return None
-
-            inline_argv = m.group(1).strip()
-            if ptype == 'mic':
-                m2 = re.search('(?P<format>\w+)', inline_argv)
-            elif ptype == 'mic2':
-                m2 = re.search('(-f|--format(=)?)\s*(?P<format>\w+)',
-                               inline_argv)
-            else:
-                return None
-
-            if m2:
-                cmdname = m2.group('format')
-                inline_argv = inline_argv.replace(m2.group(0), '')
-                return (cmdname, inline_argv)
-
-            return None
-
-        if len(args) != 1:
-            raise errors.Usage("Extra arguments given")
-
-        if not os.path.exists(args[0]):
-            raise errors.CreatorError("Can't find the file: %s" % args[0])
-
-        with open(args[0], 'r') as rf:
-            first_line = rf.readline()
-
-        mic_re = '^#\s*-\*-mic-options-\*-\s+(.*)\s+-\*-mic-options-\*-'
-        mic2_re = '^#\s*-\*-mic2-options-\*-\s+(.*)\s+-\*-mic2-options-\*-'
-
-        result = parse_magic_line(mic_re, first_line, 'mic') \
-                 or parse_magic_line(mic2_re, first_line, 'mic2')
-        if not result:
-            raise errors.KsError("Invalid magic line in file: %s" % args[0])
-
-        if result[0] not in self._subcmds:
-            raise errors.KsError("Unsupport format '%s' in %s"
-                                 % (result[0], args[0]))
-
-        argv = ' '.join(result + args).split()
-        self.main(argv)
-
Signature · 1 line
1.8.3.1
#25 lore raw

PATCH 23/35 wic: Remove unused command versioning support

In reply to Tom Zanussi

The default is F16 and there's no reason to change that, so remove everything else.

---
 .../3rdparty/pykickstart/commands/bootloader.py    |  49 ------
 .../mic/3rdparty/pykickstart/commands/partition.py |  39 -----
 .../mic/3rdparty/pykickstart/handlers/control.py   | 169 ---------------------
 .../lib/mic/3rdparty/pykickstart/handlers/f10.py   |  24 ---
 .../lib/mic/3rdparty/pykickstart/handlers/f11.py   |  24 ---
 .../lib/mic/3rdparty/pykickstart/handlers/f12.py   |  24 ---
 .../lib/mic/3rdparty/pykickstart/handlers/f13.py   |  24 ---
 .../lib/mic/3rdparty/pykickstart/handlers/f14.py   |  24 ---
 .../lib/mic/3rdparty/pykickstart/handlers/f15.py   |  24 ---
 .../lib/mic/3rdparty/pykickstart/handlers/f7.py    |  24 ---
 .../lib/mic/3rdparty/pykickstart/handlers/f8.py    |  24 ---
 .../lib/mic/3rdparty/pykickstart/handlers/f9.py    |  24 ---
 .../lib/mic/3rdparty/pykickstart/handlers/fc3.py   |  24 ---
 .../lib/mic/3rdparty/pykickstart/handlers/fc4.py   |  24 ---
 .../lib/mic/3rdparty/pykickstart/handlers/fc5.py   |  24 ---
 .../lib/mic/3rdparty/pykickstart/handlers/fc6.py   |  24 ---
 .../lib/mic/3rdparty/pykickstart/handlers/rhel3.py |  24 ---
 .../lib/mic/3rdparty/pykickstart/handlers/rhel4.py |  24 ---
 .../lib/mic/3rdparty/pykickstart/handlers/rhel5.py |  24 ---
 .../lib/mic/3rdparty/pykickstart/handlers/rhel6.py |  24 ---
 20 files changed, 665 deletions(-)
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/f10.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/f11.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/f12.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/f13.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/f14.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/f15.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/f7.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/f8.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/f9.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/fc3.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/fc4.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/fc5.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/fc6.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/rhel3.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/rhel4.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/rhel5.py
 delete mode 100644 scripts/lib/mic/3rdparty/pykickstart/handlers/rhel6.py
scripts/lib/mic/3rdparty/pykickstart/commands/bootloader.py +0 -49
index b227fac..c2b552f 100644
@@ -214,52 +214,3 @@ class F15_Bootloader(F14_Bootloader):
         op.add_option("--iscrypted", dest="isCrypted", action="store_true", default=False)
         op.add_option("--md5pass", action="callback", callback=password_cb, nargs=1, type="string")
         return op
-
-class RHEL5_Bootloader(FC4_Bootloader):
-    removedKeywords = FC4_Bootloader.removedKeywords
-    removedAttrs = FC4_Bootloader.removedAttrs
-
-    def __init__(self, writePriority=10, *args, **kwargs):
-        FC4_Bootloader.__init__(self, writePriority, *args, **kwargs)
-
-        self.hvArgs = kwargs.get("hvArgs", "")
-
-    def _getArgsAsStr(self):
-        ret = FC4_Bootloader._getArgsAsStr(self)
-
-        if self.hvArgs:
-            ret += " --hvargs=\"%s\"" %(self.hvArgs,)
-
-        return ret
-
-    def _getParser(self):
-        op = FC4_Bootloader._getParser(self)
-        op.add_option("--hvargs", dest="hvArgs", type="string")
-        return op
-
-class RHEL6_Bootloader(F12_Bootloader):
-    removedKeywords = F12_Bootloader.removedKeywords
-    removedAttrs = F12_Bootloader.removedAttrs
-
-    def __init__(self, writePriority=10, *args, **kwargs):
-        F12_Bootloader.__init__(self, writePriority, *args, **kwargs)
-
-        self.isCrypted = kwargs.get("isCrypted", False)
-
-    def _getArgsAsStr(self):
-        ret = F12_Bootloader._getArgsAsStr(self)
-
-        if self.isCrypted:
-            ret += " --iscrypted"
-
-        return ret
-
-    def _getParser(self):
-        def password_cb(option, opt_str, value, parser):
-            parser.values.isCrypted = True
-            parser.values.password = value
-
-        op = F12_Bootloader._getParser(self)
-        op.add_option("--iscrypted", dest="isCrypted", action="store_true", default=False)
-        op.add_option("--md5pass", action="callback", callback=password_cb, nargs=1, type="string")
-        return op
scripts/lib/mic/3rdparty/pykickstart/commands/partition.py +0 -39
index e65e012..56b91aa 100644
@@ -115,26 +115,6 @@ class FC4_PartData(FC3_PartData):
 
         return retval
 
-class RHEL5_PartData(FC4_PartData):
-    removedKeywords = FC4_PartData.removedKeywords
-    removedAttrs = FC4_PartData.removedAttrs
-
-    def __init__(self, *args, **kwargs):
-        FC4_PartData.__init__(self, *args, **kwargs)
-        self.encrypted = kwargs.get("encrypted", False)
-        self.passphrase = kwargs.get("passphrase", "")
-
-    def _getArgsAsStr(self):
-        retval = FC4_PartData._getArgsAsStr(self)
-
-        if self.encrypted:
-            retval += " --encrypted"
-
-            if self.passphrase != "":
-                retval += " --passphrase=\"%s\"" % self.passphrase
-
-        return retval
-
 class F9_PartData(FC4_PartData):
     removedKeywords = FC4_PartData.removedKeywords + ["bytesPerInode"]
     removedAttrs = FC4_PartData.removedAttrs + ["bytesPerInode"]
@@ -281,25 +261,6 @@ class FC4_Partition(FC3_Partition):
         op.add_option("--label", dest="label")
         return op
 
-class RHEL5_Partition(FC4_Partition):
-    removedKeywords = FC4_Partition.removedKeywords
-    removedAttrs = FC4_Partition.removedAttrs
-
-    def __init__(self, writePriority=130, *args, **kwargs):
-        FC4_Partition.__init__(self, writePriority, *args, **kwargs)
-
-        def part_cb (option, opt_str, value, parser):
-            if value.startswith("/dev/"):
-                parser.values.ensure_value(option.dest, value[5:])
-            else:
-                parser.values.ensure_value(option.dest, value)
-
-    def _getParser(self):
-        op = FC4_Partition._getParser(self)
-        op.add_option("--encrypted", action="store_true", default=False)
-        op.add_option("--passphrase")
-        return op
-
 class F9_Partition(FC4_Partition):
     removedKeywords = FC4_Partition.removedKeywords
     removedAttrs = FC4_Partition.removedAttrs
scripts/lib/mic/3rdparty/pykickstart/handlers/control.py +0 -169

188 lines not on this page · raw message

scripts/lib/mic/3rdparty/pykickstart/handlers/f10.py deleted +0 -24
deleted file mode 100644
index 17c8211..0000000
@@ -1,24 +0,0 @@
-#
-# Chris Lumens <[email protected]>
-#
-# Copyright 2008 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use, modify,
-# copy, or redistribute it subject to the terms and conditions of the GNU
-# General Public License v.2.  This program is distributed in the hope that it
-# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
-# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
-# trademarks that are incorporated in the source code or documentation are not
-# subject to the GNU General Public License and may only be used or replicated
-# with the express permission of Red Hat, Inc. 
-#
-from pykickstart.base import *
-from pykickstart.version import *
-
-class F10Handler(BaseHandler):
-    version = F10
scripts/lib/mic/3rdparty/pykickstart/handlers/f11.py deleted +0 -24
deleted file mode 100644
index d21aee3..0000000
@@ -1,24 +0,0 @@
-#
-# Chris Lumens <[email protected]>
-#
-# Copyright 2008 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use, modify,
-# copy, or redistribute it subject to the terms and conditions of the GNU
-# General Public License v.2.  This program is distributed in the hope that it
-# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
-# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
-# trademarks that are incorporated in the source code or documentation are not
-# subject to the GNU General Public License and may only be used or replicated
-# with the express permission of Red Hat, Inc. 
-#
-from pykickstart.base import *
-from pykickstart.version import *
-
-class F11Handler(BaseHandler):
-    version = F11
scripts/lib/mic/3rdparty/pykickstart/handlers/f12.py deleted +0 -24
deleted file mode 100644
index cea3ece..0000000
@@ -1,24 +0,0 @@
-#
-# Chris Lumens <[email protected]>
-#
-# Copyright 2009 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use, modify,
-# copy, or redistribute it subject to the terms and conditions of the GNU
-# General Public License v.2.  This program is distributed in the hope that it
-# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
-# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
-# trademarks that are incorporated in the source code or documentation are not
-# subject to the GNU General Public License and may only be used or replicated
-# with the express permission of Red Hat, Inc. 
-#
-from pykickstart.base import *
-from pykickstart.version import *
-
-class F12Handler(BaseHandler):
-    version = F12
scripts/lib/mic/3rdparty/pykickstart/handlers/f13.py deleted +0 -24
deleted file mode 100644
index b94c738..0000000
@@ -1,24 +0,0 @@
-#
-# Chris Lumens <[email protected]>
-#
-# Copyright 2009 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use, modify,
-# copy, or redistribute it subject to the terms and conditions of the GNU
-# General Public License v.2.  This program is distributed in the hope that it
-# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
-# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
-# trademarks that are incorporated in the source code or documentation are not
-# subject to the GNU General Public License and may only be used or replicated
-# with the express permission of Red Hat, Inc. 
-#
-from pykickstart.base import *
-from pykickstart.version import *
-
-class F13Handler(BaseHandler):
-    version = F13
scripts/lib/mic/3rdparty/pykickstart/handlers/f14.py deleted +0 -24
deleted file mode 100644
index 478f75d..0000000
@@ -1,24 +0,0 @@
-#
-# Chris Lumens <[email protected]>
-#
-# Copyright 2010 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use, modify,
-# copy, or redistribute it subject to the terms and conditions of the GNU
-# General Public License v.2.  This program is distributed in the hope that it
-# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
-# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
-# trademarks that are incorporated in the source code or documentation are not
-# subject to the GNU General Public License and may only be used or replicated
-# with the express permission of Red Hat, Inc. 
-#
-from pykickstart.base import *
-from pykickstart.version import *
-
-class F14Handler(BaseHandler):
-    version = F14
scripts/lib/mic/3rdparty/pykickstart/handlers/f15.py deleted +0 -24
deleted file mode 100644
index 12aecb4..0000000
@@ -1,24 +0,0 @@
-#
-# Chris Lumens <[email protected]>
-#
-# Copyright 2010 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use, modify,
-# copy, or redistribute it subject to the terms and conditions of the GNU
-# General Public License v.2.  This program is distributed in the hope that it
-# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
-# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
-# trademarks that are incorporated in the source code or documentation are not
-# subject to the GNU General Public License and may only be used or replicated
-# with the express permission of Red Hat, Inc. 
-#
-from pykickstart.base import *
-from pykickstart.version import *
-
-class F15Handler(BaseHandler):
-    version = F15
scripts/lib/mic/3rdparty/pykickstart/handlers/f7.py deleted +0 -24
deleted file mode 100644
index 5e856ea..0000000
@@ -1,24 +0,0 @@
-#
-# Chris Lumens <[email protected]>
-#
-# Copyright 2007 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use, modify,
-# copy, or redistribute it subject to the terms and conditions of the GNU
-# General Public License v.2.  This program is distributed in the hope that it
-# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
-# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
-# trademarks that are incorporated in the source code or documentation are not
-# subject to the GNU General Public License and may only be used or replicated
-# with the express permission of Red Hat, Inc. 
-#
-from pykickstart.base import *
-from pykickstart.version import *
-
-class F7Handler(BaseHandler):
-    version = F7
scripts/lib/mic/3rdparty/pykickstart/handlers/f8.py deleted +0 -24
deleted file mode 100644
index 1a97881..0000000
@@ -1,24 +0,0 @@
-#
-# Chris Lumens <[email protected]>
-#
-# Copyright 2007 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use, modify,
-# copy, or redistribute it subject to the terms and conditions of the GNU
-# General Public License v.2.  This program is distributed in the hope that it
-# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
-# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
-# trademarks that are incorporated in the source code or documentation are not
-# subject to the GNU General Public License and may only be used or replicated
-# with the express permission of Red Hat, Inc. 
-#
-from pykickstart.base import *
-from pykickstart.version import *
-
-class F8Handler(BaseHandler):
-    version = F8
scripts/lib/mic/3rdparty/pykickstart/handlers/f9.py deleted +0 -24
deleted file mode 100644
index 116f1b5..0000000
@@ -1,24 +0,0 @@
-#
-# Chris Lumens <[email protected]>
-#
-# Copyright 2007 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use, modify,
-# copy, or redistribute it subject to the terms and conditions of the GNU
-# General Public License v.2.  This program is distributed in the hope that it
-# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
-# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
-# trademarks that are incorporated in the source code or documentation are not
-# subject to the GNU General Public License and may only be used or replicated
-# with the express permission of Red Hat, Inc. 
-#
-from pykickstart.base import *
-from pykickstart.version import *
-
-class F9Handler(BaseHandler):
-    version = F9
scripts/lib/mic/3rdparty/pykickstart/handlers/fc3.py deleted +0 -24
deleted file mode 100644
index a115dc2..0000000
@@ -1,24 +0,0 @@
-#
-# Chris Lumens <[email protected]>
-#
-# Copyright 2005, 2006, 2007 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use, modify,
-# copy, or redistribute it subject to the terms and conditions of the GNU
-# General Public License v.2.  This program is distributed in the hope that it
-# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
-# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
-# trademarks that are incorporated in the source code or documentation are not
-# subject to the GNU General Public License and may only be used or replicated
-# with the express permission of Red Hat, Inc. 
-#
-from pykickstart.base import *
-from pykickstart.version import *
-
-class FC3Handler(BaseHandler):
-    version = FC3
scripts/lib/mic/3rdparty/pykickstart/handlers/fc4.py deleted +0 -24
deleted file mode 100644
index fd47b73..0000000
@@ -1,24 +0,0 @@
-#
-# Chris Lumens <[email protected]>
-#
-# Copyright 2007 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use, modify,
-# copy, or redistribute it subject to the terms and conditions of the GNU
-# General Public License v.2.  This program is distributed in the hope that it
-# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
-# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
-# trademarks that are incorporated in the source code or documentation are not
-# subject to the GNU General Public License and may only be used or replicated
-# with the express permission of Red Hat, Inc. 
-#
-from pykickstart.base import *
-from pykickstart.version import *
-
-class FC4Handler(BaseHandler):
-    version = FC4
scripts/lib/mic/3rdparty/pykickstart/handlers/fc5.py deleted +0 -24
deleted file mode 100644
index bcdc29d..0000000
@@ -1,24 +0,0 @@
-#
-# Chris Lumens <[email protected]>
-#
-# Copyright 2007 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use, modify,
-# copy, or redistribute it subject to the terms and conditions of the GNU
-# General Public License v.2.  This program is distributed in the hope that it
-# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
-# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
-# trademarks that are incorporated in the source code or documentation are not
-# subject to the GNU General Public License and may only be used or replicated
-# with the express permission of Red Hat, Inc. 
-#
-from pykickstart.base import *
-from pykickstart.version import *
-
-class FC5Handler(BaseHandler):
-    version = FC5
scripts/lib/mic/3rdparty/pykickstart/handlers/fc6.py deleted +0 -24
deleted file mode 100644
index c83a929..0000000
@@ -1,24 +0,0 @@
-#
-# Chris Lumens <[email protected]>
-#
-# Copyright 2006, 2007 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use, modify,
-# copy, or redistribute it subject to the terms and conditions of the GNU
-# General Public License v.2.  This program is distributed in the hope that it
-# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
-# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
-# trademarks that are incorporated in the source code or documentation are not
-# subject to the GNU General Public License and may only be used or replicated
-# with the express permission of Red Hat, Inc. 
-#
-from pykickstart.base import *
-from pykickstart.version import *
-
-class FC6Handler(BaseHandler):
-    version = FC6
scripts/lib/mic/3rdparty/pykickstart/handlers/rhel3.py deleted +0 -24
deleted file mode 100644
index 131763c..0000000
@@ -1,24 +0,0 @@
-#
-# Chris Lumens <[email protected]>
-#
-# Copyright 2007 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use, modify,
-# copy, or redistribute it subject to the terms and conditions of the GNU
-# General Public License v.2.  This program is distributed in the hope that it
-# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
-# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
-# trademarks that are incorporated in the source code or documentation are not
-# subject to the GNU General Public License and may only be used or replicated
-# with the express permission of Red Hat, Inc. 
-#
-from pykickstart.base import *
-from pykickstart.version import *
-
-class RHEL3Handler(BaseHandler):
-    version = RHEL3
scripts/lib/mic/3rdparty/pykickstart/handlers/rhel4.py deleted +0 -24
deleted file mode 100644
index 3496c43..0000000
@@ -1,24 +0,0 @@
-#
-# Chris Lumens <[email protected]>
-#
-# Copyright 2007 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use, modify,
-# copy, or redistribute it subject to the terms and conditions of the GNU
-# General Public License v.2.  This program is distributed in the hope that it
-# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
-# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
-# trademarks that are incorporated in the source code or documentation are not
-# subject to the GNU General Public License and may only be used or replicated
-# with the express permission of Red Hat, Inc. 
-#
-from pykickstart.base import *
-from pykickstart.version import *
-
-class RHEL4Handler(BaseHandler):
-    version = RHEL4
scripts/lib/mic/3rdparty/pykickstart/handlers/rhel5.py deleted +0 -24
deleted file mode 100644
index abb7a8d..0000000
@@ -1,24 +0,0 @@
-#
-# Chris Lumens <[email protected]>
-#
-# Copyright 2007 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use, modify,
-# copy, or redistribute it subject to the terms and conditions of the GNU
-# General Public License v.2.  This program is distributed in the hope that it
-# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
-# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
-# trademarks that are incorporated in the source code or documentation are not
-# subject to the GNU General Public License and may only be used or replicated
-# with the express permission of Red Hat, Inc. 
-#
-from pykickstart.base import *
-from pykickstart.version import *
-
-class RHEL5Handler(BaseHandler):
-    version = RHEL5
scripts/lib/mic/3rdparty/pykickstart/handlers/rhel6.py deleted +0 -24
deleted file mode 100644
index 7202419..0000000
@@ -1,24 +0,0 @@
-#
-# Chris Lumens <[email protected]>
-#
-# Copyright 2010 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use, modify,
-# copy, or redistribute it subject to the terms and conditions of the GNU
-# General Public License v.2.  This program is distributed in the hope that it
-# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
-# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
-# trademarks that are incorporated in the source code or documentation are not
-# subject to the GNU General Public License and may only be used or replicated
-# with the express permission of Red Hat, Inc. 
-#
-from pykickstart.base import *
-from pykickstart.version import *
-
-class RHEL6Handler(BaseHandler):
-    version = RHEL6
Signature · 1 line
1.8.3.1
#26 lore raw

PATCH 24/35 wic: Update 'Background and Motivation' help section

In reply to Tom Zanussi

Remove help text regarding the source and future intentions of the wic codebase, since the code prompting those comments has now been mostly removed.

---
 scripts/lib/image/help.py | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
scripts/lib/image/help.py +1 -13
index 6e8e037..6503aaa 100644
@@ -456,24 +456,12 @@ DESCRIPTION
     oe-core: directdisk.bbclass and mkefidisk.sh.  The difference
     between wic and those examples is that with wic the functionality
     of those scripts is implemented by a general-purpose partitioning
-    'language' based on Redhat kickstart syntax (with the underlying
-    code borrowed from Tizen mic, which in turn was borrowed from
-    Meego mic, in turn borrowed from Fedora livecd, etc.).
+    'language' based on Redhat kickstart syntax).
 
     The initial motivation and design considerations that lead to the
     current tool are described exhaustively in Yocto Bug #3847
     (https://bugzilla.yoctoproject.org/show_bug.cgi?id=3847).
 
-    Though the current wic tool only uses the kickstart syntax related
-    to partitioning and bootloaders and only for creating images,
-    because the code is based on the mic/pykickstart code, future
-    deployment efforts such as those partially described by Yocto Bug
-    #4106 (https://bugzilla.yoctoproject.org/show_bug.cgi?id=4106),
-    but also others including package selection (from e.g. binary
-    feeds) and deployment configuration of users/network/services,
-    etc, could be implemented under this framework, considering that
-    all of those are implemented in some form by the base system.
-
   Implementation and Examples
 
     wic can be used in two different modes, depending on how much
Signature · 1 line
1.8.3.1
#27 lore raw

PATCH 25/35 wic: Remove unused conf support

In reply to Tom Zanussi

Also fix up users such as imager functions.

---
 scripts/lib/image/config/wic.conf               |  1 -
 scripts/lib/mic/conf.py                         | 39 --------------------
 scripts/lib/mic/imager/baseimager.py            | 13 ++-----
 scripts/lib/mic/imager/direct.py                |  6 ++--
 scripts/lib/mic/plugins/imager/direct_plugin.py |  4 +--
 scripts/lib/mic/utils/misc.py                   | 48 +------------------------
 6 files changed, 8 insertions(+), 103 deletions(-)
scripts/lib/image/config/wic.conf +0 -1
index e96d6ae..a51bcb5 100644
@@ -4,4 +4,3 @@ distro_name = OpenEmbedded
 
 [create]
 ; settings for create subcommand
-runtime=native
scripts/lib/mic/conf.py +0 -39
index 1fe6edd..a686e9c 100644
@@ -31,45 +31,18 @@ def get_siteconf():
     return scripts_path + "/lib/image/config/wic.conf"
 
 class ConfigMgr(object):
-    prefer_backends = ["zypp", "yum"]
-
     DEFAULTS = {'common': {
                     "distro_name": "Default Distribution",
                     "plugin_dir": "/usr/lib/wic/plugins", # TODO use prefix also?
                 },
                 'create': {
                     "tmpdir": '/var/tmp/wic',
-                    "cachedir": '/var/tmp/wic/cache',
                     "outdir": './wic-output',
 
-                    "arch": None, # None means auto-detect
-                    "pkgmgr": "auto",
-                    "name": "output",
-                    "ksfile": None,
-                    "ks": None,
-                    "repomd": None,
-                    "local_pkgs_path": None,
                     "release": None,
                     "logfile": None,
-                    "record_pkgs": [],
-                    "pack_to": None,
                     "name_prefix": None,
                     "name_suffix": None,
-                    "copy_kernel": False,
-                    "install_pkgs": None,
-                    "repourl": {},
-                    "localrepos": [],  # save localrepos
-                    "runtime": "bootstrap",
-                },
-                'chroot': {
-                    "saveto": None,
-                },
-                'convert': {
-                    "shell": False,
-                },
-                'bootstrap': {
-                    "rootdir": '/var/tmp/wic-bootstrap',
-                    "packages": [],
                 },
                }
 
@@ -116,10 +89,6 @@ class ConfigMgr(object):
         if not ksconf:
             return
 
-        ksconf = misc.normalize_ksfile(ksconf,
-                                       self.create['release'],
-                                       self.create['arch'])
-
         ks = kickstart.read_kickstart(ksconf)
 
         self.create['ks'] = ks
@@ -130,12 +99,4 @@ class ConfigMgr(object):
                                               self.create['name_prefix'],
                                               self.create['name_suffix'])
 
-    def set_runtime(self, runtime):
-        if runtime not in ("bootstrap", "native"):
-            msger.error("Invalid runtime mode: %s" % runtime)
-
-        if misc.get_distro()[0] in ("tizen", "Tizen"):
-            runtime = "native"
-        self.create['runtime'] = runtime
-
 configmgr = ConfigMgr()
scripts/lib/mic/imager/baseimager.py +2 -11
index 55f2dea..0d591ea 100644
@@ -176,7 +176,7 @@ class BaseImageCreator(object):
 
         runner.show('umount -l %s' % self.workdir)
 
-    def mount(self, base_on = None, cachedir = None):
+    def mount(self):
         """Setup the target filesystem in preparation for an install.
 
         This function sets up the filesystem which the ImageCreator will
@@ -184,20 +184,11 @@ class BaseImageCreator(object):
         install root directory, bind mounts some system directories (e.g. /dev)
         and writes out /etc/fstab. Other subclasses may also e.g. create a
         sparse file, format it and loopback mount it to the install root.
-
-        base_on -- a previous install on which to base this install; defaults
-                   to None, causing a new image to be created
-
-        cachedir -- a directory in which to store the Yum cache; defaults to
-                    None, causing a new cache to be created; by setting this
-                    to another directory, the same cache can be reused across
-                    multiple installs.
-
         """
         self.__setup_tmpdir()
         self.__ensure_builddir()
 
-        self._mount_instroot(base_on)
+        self._mount_instroot()
 
     def unmount(self):
         """Unmounts the target filesystem.
scripts/lib/mic/imager/direct.py +3 -3
index 92473b5..2e6914b 100644
@@ -217,7 +217,7 @@ class DirectImageCreator(BaseImageCreator):
     #
     # Actual implemention
     #
-    def _mount_instroot(self, base_on = None):
+    def _mount_instroot(self):
         """
         For 'wic', we already have our build artifacts and don't want
         to loop mount anything to install into, we just create
@@ -296,7 +296,7 @@ class DirectImageCreator(BaseImageCreator):
 
         self.__instimage.mount()
 
-    def install(self, repo_urls=None):
+    def install(self):
         """
         Install fs images into partitions
         """
@@ -306,7 +306,7 @@ class DirectImageCreator(BaseImageCreator):
                         % (disk_name, full_path, disk['min_size']))
             self.__instimage.install(full_path)
 
-    def configure(self, repodata = None):
+    def configure(self):
         """
         Configure the system image according to kickstart.
 
scripts/lib/mic/plugins/imager/direct_plugin.py +2 -2
index 877aaf6..793a736 100644
@@ -91,9 +91,9 @@ class DirectPlugin(ImagerPlugin):
                                             creatoropts)
 
         try:
-            creator.mount(None, creatoropts["cachedir"])
+            creator.mount()
             creator.install()
-            creator.configure(creatoropts["repomd"])
+            creator.configure()
             creator.print_outimage_info()
 
         except errors.CreatorError:
scripts/lib/mic/utils/misc.py +1 -47

58 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#28 lore raw

PATCH 26/35 wic: Remove Mount object

In reply to Tom Zanussi

It doesn't do anything we need, so remove it and fix up callers/base classes.

---
 scripts/lib/mic/utils/fs_related.py    | 16 ----------------
 scripts/lib/mic/utils/partitionedfs.py |  4 +---
 2 files changed, 1 insertion(+), 19 deletions(-)
scripts/lib/mic/utils/fs_related.py +0 -16
index e6e362d..07a5ff9 100644
@@ -112,19 +112,3 @@ class DiskImage(Disk):
         exec_cmd(dd_cmd)
 
         self.device = self.image_file
-
-
-class Mount:
-    """A generic base class to deal with mounting things."""
-    def __init__(self, mountdir):
-        self.mountdir = mountdir
-
-    def cleanup(self):
-        self.unmount()
-
-    def mount(self, options = None):
-        pass
-
-    def unmount(self):
-        pass
-
scripts/lib/mic/utils/partitionedfs.py +1 -3
index ef92125..50536b4 100644
@@ -32,9 +32,8 @@ MBR_OVERHEAD = 1
 # Size of a sector in bytes
 SECTOR_SIZE = 512
 
-class PartitionedMount(Mount):
+class PartitionedMount:
     def __init__(self, mountdir):
-        Mount.__init__(self, mountdir)
         self.disks = {}
         self.partitions = []
         self.mountOrder = []
@@ -316,7 +315,6 @@ class PartitionedMount(Mount):
         self.unmountOrder.reverse()
 
     def cleanup(self):
-        Mount.cleanup(self)
         if self.disks:
             for dev in self.disks.keys():
                 d = self.disks[dev]
Signature · 1 line
1.8.3.1
#29 lore raw

PATCH 27/35 wic: Update/rename/delete mount-related code

In reply to Tom Zanussi

The wic code inherited a basic image-creation flow based on mounting loop devices, but wic doesn't actually mount anything, so rename parts of the code dealing with mounting to something more appropriate, and remove related unused code.

---
 scripts/lib/mic/imager/baseimager.py            | 47 +++++--------------------
 scripts/lib/mic/imager/direct.py                | 42 ++++++----------------
 scripts/lib/mic/plugins/imager/direct_plugin.py |  2 +-
 scripts/lib/mic/utils/partitionedfs.py          | 37 ++-----------------
 4 files changed, 22 insertions(+), 106 deletions(-)
scripts/lib/mic/imager/baseimager.py +9 -38
index 0d591ea..7f32dd5 100644
@@ -97,41 +97,15 @@ class BaseImageCreator(object):
 
 
     #
-    # Properties
-    #
-    def __get_instroot(self):
-        if self.__builddir is None:
-            raise CreatorError("_instroot is not valid before calling mount()")
-        return self.__builddir + "/install_root"
-    _instroot = property(__get_instroot)
-    """The location of the install root directory.
-
-    This is the directory into which the system is installed. Subclasses may
-    mount a filesystem image here or copy files to/from here.
-
-    Note, this directory does not exist before ImageCreator.mount() is called.
-
-    Note also, this is a read-only attribute.
-
-    """
-
-
-    #
     # Hooks for subclasses
     #
-    def _mount_instroot(self, base_on = None):
-        """Mount or prepare the install root directory.
+    def _create(self):
+        """Create partitions for the disk image(s)
 
-        This is the hook where subclasses may prepare the install root by e.g.
-        mounting creating and loopback mounting a filesystem image to
-        _instroot.
+        This is the hook where subclasses may create the partitions
+        that will be assembled into disk image(s).
 
         There is no default implementation.
-
-        base_on -- this is the value passed to mount() and can be interpreted
-                   as the subclass wishes; it might e.g. be the location of
-                   a previously created ISO containing a system image.
-
         """
         pass
 
@@ -176,19 +150,16 @@ class BaseImageCreator(object):
 
         runner.show('umount -l %s' % self.workdir)
 
-    def mount(self):
-        """Setup the target filesystem in preparation for an install.
+    def create(self):
+        """Create partitions for the disk image(s)
 
-        This function sets up the filesystem which the ImageCreator will
-        install into and configure. The ImageCreator class merely creates an
-        install root directory, bind mounts some system directories (e.g. /dev)
-        and writes out /etc/fstab. Other subclasses may also e.g. create a
-        sparse file, format it and loopback mount it to the install root.
+        Create the partitions that will be assembled into disk
+        image(s).
         """
         self.__setup_tmpdir()
         self.__ensure_builddir()
 
-        self._mount_instroot()
+        self._create()
 
     def unmount(self):
         """Unmounts the target filesystem.
scripts/lib/mic/imager/direct.py +10 -32

75 lines not on this page · raw message

scripts/lib/mic/plugins/imager/direct_plugin.py +1 -1
index 793a736..da18b65 100644
@@ -91,7 +91,7 @@ class DirectPlugin(ImagerPlugin):
                                             creatoropts)
 
         try:
-            creator.mount()
+            creator.create()
             creator.install()
             creator.configure()
             creator.print_outimage_info()
scripts/lib/mic/utils/partitionedfs.py +2 -35
index 50536b4..43a38a9 100644
@@ -33,11 +33,9 @@ MBR_OVERHEAD = 1
 SECTOR_SIZE = 512
 
 class PartitionedMount:
-    def __init__(self, mountdir):
+    def __init__(self):
         self.disks = {}
         self.partitions = []
-        self.mountOrder = []
-        self.unmountOrder = []
         self.parted = find_binary_path("parted")
         # Size of a sector used in calculations
         self.sector_size = SECTOR_SIZE
@@ -102,7 +100,6 @@ class PartitionedMount:
                      'label': label, # Partition label
                      'disk_name': disk_name, # physical disk name holding partition
                      'device': None, # kpartx device node for partition
-                     'mount': None, # Mount object
                      'num': None, # Partition number
                      'boot': boot, # Bootable flag
                      'align': align, # Partition alignment
@@ -303,17 +300,6 @@ class PartitionedMount:
                     self.__run_parted(["-s", d['disk'].device, "set",
                                        "%d" % p['num'], "lba", "off"])
 
-    def __calculate_mountorder(self):
-        msger.debug("Calculating mount order")
-        for p in self.partitions:
-            if p['mountpoint']:
-                self.mountOrder.append(p['mountpoint'])
-                self.unmountOrder.append(p['mountpoint'])
-
-        self.mountOrder.sort()
-        self.unmountOrder.sort()
-        self.unmountOrder.reverse()
-
     def cleanup(self):
         if self.disks:
             for dev in self.disks.keys():
@@ -323,23 +309,6 @@ class PartitionedMount:
                 except:
                     pass
 
-    def unmount(self):
-        for mp in self.unmountOrder:
-            if mp == 'swap':
-                continue
-            p = None
-            for p1 in self.partitions:
-                if p1['mountpoint'] == mp:
-                    p = p1
-                    break
-
-            if p['mount'] != None:
-                try:
-                    p['mount'].cleanup()
-                except:
-                    pass
-                p['mount'] = None
-
     def __install_partition(self, num, source_file, start, size):
         """
         Install source_file contents into a partition.
@@ -375,13 +344,11 @@ class PartitionedMount:
             self.__install_partition(p['num'], p['source_file'],
                                      p['start'], p['size'])
 
-    def mount(self):
+    def create(self):
         for dev in self.disks.keys():
             d = self.disks[dev]
             d['disk'].create()
 
         self.__format_disks()
 
-        self.__calculate_mountorder()
-
         return
Signature · 1 line
1.8.3.1
#30 lore raw

PATCH 28/35 wic: Update cleanup/unmount-related code

In reply to Tom Zanussi

The wic code inherited a basic image-creation flow based on mounting loop devices, but wic doesn't actually mount or unmount anything, so get rid of unmount() and consolidate whatever it did do with cleanup().

---
 scripts/lib/mic/imager/baseimager.py | 28 ++++++----------------------
 scripts/lib/mic/imager/direct.py     |  2 +-
 2 files changed, 7 insertions(+), 23 deletions(-)
scripts/lib/mic/imager/baseimager.py +6 -22
index 7f32dd5..23919d4 100644
@@ -109,12 +109,11 @@ class BaseImageCreator(object):
         """
         pass
 
-    def _unmount_instroot(self):
-        """Undo anything performed in _mount_instroot().
+    def _cleanup(self):
+        """Undo anything performed in _create().
 
-        This is the hook where subclasses must undo anything which was done
-        in _mount_instroot(). For example, if a filesystem image was mounted
-        onto _instroot, it should be unmounted here.
+        This is the hook where subclasses must undo anything which was
+        done in _create().
 
         There is no default implementation.
 
@@ -161,23 +160,8 @@ class BaseImageCreator(object):
 
         self._create()
 
-    def unmount(self):
-        """Unmounts the target filesystem.
-
-        The ImageCreator class detaches the system from the install root, but
-        other subclasses may also detach the loopback mounted filesystem image
-        from the install root.
-
-        """
-        self._unmount_instroot()
-
-
     def cleanup(self):
-        """Unmounts the target filesystem and deletes temporary files.
-
-        This method calls unmount() and then deletes any temporary files and
-        directories that were created on the host system while building the
-        image.
+        """Undo anything performed in create().
 
         Note, make sure to call this method once finished with the creator
         instance in order to ensure no stale files are left on the host e.g.:
@@ -192,7 +176,7 @@ class BaseImageCreator(object):
         if not self.__builddir:
             return
 
-        self.unmount()
+        self._cleanup()
 
         shutil.rmtree(self.__builddir, ignore_errors = True)
         self.__builddir = None
scripts/lib/mic/imager/direct.py +1 -1
index b96740d..91f64d5 100644
@@ -354,7 +354,7 @@ class DirectImageCreator(BaseImageCreator):
 
         return (rootdev, root_part_uuid)
 
-    def _unmount_instroot(self):
+    def _cleanup(self):
         if not self.__instimage is None:
             try:
                 self.__instimage.cleanup()
Signature · 1 line
1.8.3.1
#31 lore raw

PATCH 29/35 wic: Update/rename install-related code

In reply to Tom Zanussi

The wic code inherited a basic image-creation flow based on installing packages, but wic doesn't actually install anything, so rename parts of the code dealing with installing to something more appropriate.

---
 scripts/lib/mic/imager/direct.py                | 50 ++++++++++++-------------
 scripts/lib/mic/plugins/imager/direct_plugin.py |  2 +-
 scripts/lib/mic/utils/partitionedfs.py          | 16 ++++----
 3 files changed, 34 insertions(+), 34 deletions(-)
scripts/lib/mic/imager/direct.py +25 -25
index 91f64d5..8d7b6ee 100644
@@ -62,7 +62,7 @@ class DirectImageCreator(BaseImageCreator):
         """
         BaseImageCreator.__init__(self, creatoropts)
 
-        self.__instimage = None
+        self.__image = None
         self.__disks = {}
         self.__disk_format = "direct"
         self._disk_names = []
@@ -226,7 +226,7 @@ class DirectImageCreator(BaseImageCreator):
         """
         parts = self._get_parts()
 
-        self.__instimage = PartitionedMount()
+        self.__image = PartitionedMount()
 
         for p in parts:
             # as a convenience, set source to the boot partition source
@@ -250,39 +250,39 @@ class DirectImageCreator(BaseImageCreator):
 
             self._restore_fstab(fstab)
 
-            self.__instimage.add_partition(int(p.size),
-                                           p.disk,
-                                           p.mountpoint,
-                                           p.source_file,
-                                           p.fstype,
-                                           p.label,
-                                           fsopts = p.fsopts,
-                                           boot = p.active,
-                                           align = p.align,
-                                           part_type = p.part_type)
+            self.__image.add_partition(int(p.size),
+                                       p.disk,
+                                       p.mountpoint,
+                                       p.source_file,
+                                       p.fstype,
+                                       p.label,
+                                       fsopts = p.fsopts,
+                                       boot = p.active,
+                                       align = p.align,
+                                       part_type = p.part_type)
 
-        self.__instimage.layout_partitions(self._ptable_format)
+        self.__image.layout_partitions(self._ptable_format)
 
         self.__imgdir = self.workdir
-        for disk_name, disk in self.__instimage.disks.items():
+        for disk_name, disk in self.__image.disks.items():
             full_path = self._full_path(self.__imgdir, disk_name, "direct")
             msger.debug("Adding disk %s as %s with size %s bytes" \
                         % (disk_name, full_path, disk['min_size']))
             disk_obj = fs_related.DiskImage(full_path, disk['min_size'])
             self.__disks[disk_name] = disk_obj
-            self.__instimage.add_disk(disk_name, disk_obj)
+            self.__image.add_disk(disk_name, disk_obj)
 
-        self.__instimage.create()
+        self.__image.create()
 
-    def install(self):
+    def assemble(self):
         """
-        Install fs images into partitions
+        Assemble partitions into disk image(s)
         """
-        for disk_name, disk in self.__instimage.disks.items():
+        for disk_name, disk in self.__image.disks.items():
             full_path = self._full_path(self.__imgdir, disk_name, "direct")
-            msger.debug("Installing disk %s as %s with size %s bytes" \
+            msger.debug("Assembling disk %s as %s with size %s bytes" \
                         % (disk_name, full_path, disk['min_size']))
-            self.__instimage.install(full_path)
+            self.__image.assemble(full_path)
 
     def configure(self):
         """
@@ -294,7 +294,7 @@ class DirectImageCreator(BaseImageCreator):
         source_plugin = self.get_default_source_plugin()
         if source_plugin:
             self._source_methods = pluginmgr.get_source_plugin_methods(source_plugin, disk_methods)
-            for disk_name, disk in self.__instimage.disks.items():
+            for disk_name, disk in self.__image.disks.items():
                 self._source_methods["do_install_disk"](disk, disk_name, self,
                                                         self.workdir,
                                                         self.oe_builddir,
@@ -310,7 +310,7 @@ class DirectImageCreator(BaseImageCreator):
 
         parts = self._get_parts()
 
-        for disk_name, disk in self.__instimage.disks.items():
+        for disk_name, disk in self.__image.disks.items():
             full_path = self._full_path(self.__imgdir, disk_name, "direct")
             msg += '  %s\n\n' % full_path
 
@@ -355,9 +355,9 @@ class DirectImageCreator(BaseImageCreator):
         return (rootdev, root_part_uuid)
 
     def _cleanup(self):
-        if not self.__instimage is None:
+        if not self.__image is None:
             try:
-                self.__instimage.cleanup()
+                self.__image.cleanup()
             except MountError, err:
                 msger.warning("%s" % err)
 
scripts/lib/mic/plugins/imager/direct_plugin.py +1 -1
index da18b65..2cbd5d1 100644
@@ -92,7 +92,7 @@ class DirectPlugin(ImagerPlugin):
 
         try:
             creator.create()
-            creator.install()
+            creator.assemble()
             creator.configure()
             creator.print_outimage_info()
 
scripts/lib/mic/utils/partitionedfs.py +8 -8
index 43a38a9..2f950a6 100644
@@ -309,11 +309,11 @@ class PartitionedMount:
                 except:
                     pass
 
-    def __install_partition(self, num, source_file, start, size):
+    def __write_partition(self, num, source_file, start, size):
         """
         Install source_file contents into a partition.
         """
-        if not source_file: # nothing to install
+        if not source_file: # nothing to write
             return
 
         # Start is included in the size so need to substract one from the end.
@@ -325,7 +325,7 @@ class PartitionedMount:
         exec_cmd(dd_cmd)
 
 
-    def install(self, image_file):
+    def assemble(self, image_file):
         msger.debug("Installing partitions")
 
         self.image_file = image_file
@@ -337,12 +337,12 @@ class PartitionedMount:
                 # of the first _logical_ partition. This is why the extended
                 # partition should start one sector before the first logical
                 # partition.
-                self.__install_partition(p['num'], p['source_file'],
-                                         p['start'] - 1,
-                                         d['offset'] - p['start'])
+                self.__write_partition(p['num'], p['source_file'],
+                                       p['start'] - 1,
+                                       d['offset'] - p['start'])
 
-            self.__install_partition(p['num'], p['source_file'],
-                                     p['start'], p['size'])
+            self.__write_partition(p['num'], p['source_file'],
+                                   p['start'], p['size'])
 
     def create(self):
         for dev in self.disks.keys():
Signature · 1 line
1.8.3.1
#32 lore raw

PATCH 30/35 wic: Update/rename configure-related code

In reply to Tom Zanussi

The wic code inherited a basic image-creation flow based on image-configuration, but wic doesn't actually configure anything, so rename parts of the code dealing with configuration to something more appropriate.

---
 scripts/lib/mic/imager/direct.py                | 7 ++++---
 scripts/lib/mic/plugins/imager/direct_plugin.py | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
scripts/lib/mic/imager/direct.py +4 -3
index 8d7b6ee..17bfd01 100644
@@ -284,12 +284,13 @@ class DirectImageCreator(BaseImageCreator):
                         % (disk_name, full_path, disk['min_size']))
             self.__image.assemble(full_path)
 
-    def configure(self):
+    def finalize(self):
         """
-        Configure the system image according to kickstart.
+        Finalize the disk image.
 
-        For now, it just prepares the image to be bootable by e.g.
+        For example, prepare the image to be bootable by e.g.
         creating and installing a bootloader configuration.
+
         """
         source_plugin = self.get_default_source_plugin()
         if source_plugin:
scripts/lib/mic/plugins/imager/direct_plugin.py +1 -1
index 2cbd5d1..ff30f09 100644
@@ -93,7 +93,7 @@ class DirectPlugin(ImagerPlugin):
         try:
             creator.create()
             creator.assemble()
-            creator.configure()
+            creator.finalize()
             creator.print_outimage_info()
 
         except errors.CreatorError:
Signature · 1 line
1.8.3.1
#33 lore raw

PATCH 31/35 wic: Rename PartitionedMount

In reply to Tom Zanussi

It's actually a container for disks and partitions, and wic doesn't mount anything, so rename it to match what it really is.

---
 scripts/lib/mic/imager/direct.py                 | 15 +++++++--------
 scripts/lib/mic/plugins/imager/direct_plugin.py  |  1 -
 scripts/lib/mic/plugins/source/bootimg-efi.py    |  1 -
 scripts/lib/mic/plugins/source/bootimg-pcbios.py |  1 -
 scripts/lib/mic/plugins/source/rootfs.py         |  1 -
 scripts/lib/mic/utils/partitionedfs.py           |  8 +++++++-
 6 files changed, 14 insertions(+), 13 deletions(-)
scripts/lib/mic/imager/direct.py +7 -8
index 17bfd01..a4f5691 100644
@@ -31,7 +31,7 @@ import shutil
 
 from mic import kickstart, msger
 from mic.utils import fs_related, runner, misc
-from mic.utils.partitionedfs import PartitionedMount
+from mic.utils.partitionedfs import Image
 from mic.utils.errors import CreatorError, MountError
 from mic.imager.baseimager import BaseImageCreator
 from mic.utils.oe.misc import *
@@ -226,7 +226,7 @@ class DirectImageCreator(BaseImageCreator):
         """
         parts = self._get_parts()
 
-        self.__image = PartitionedMount()
+        self.__image = Image()
 
         for p in parts:
             # as a convenience, set source to the boot partition source
@@ -237,12 +237,11 @@ class DirectImageCreator(BaseImageCreator):
         for p in parts:
             # need to create the filesystems in order to get their
             # sizes before we can add them and do the layout.
-            # PartitionedMount.create() actually calls __format_disks()
-            # to create the disk images and carve out the partitions,
-            # then self.install() calls PartitionedMount.install()
-            # which calls __install_partitition() for each partition
-            # to dd the fs into the partitions.
-
+            # Image.create() actually calls __format_disks() to create
+            # the disk images and carve out the partitions, then
+            # self.assemble() calls Image.assemble() which calls
+            # __write_partitition() for each partition to dd the fs
+            # into the partitions.
             fstab = self.__write_fstab(self.rootfs_dir.get("ROOTFS_DIR"))
 
             p.prepare(self, self.workdir, self.oe_builddir, self.rootfs_dir,
scripts/lib/mic/plugins/imager/direct_plugin.py +0 -1
index ff30f09..c05a400 100644
@@ -34,7 +34,6 @@ from mic import msger
 from mic.utils import misc, fs_related, errors, runner, cmdln
 from mic.conf import configmgr
 from mic.plugin import pluginmgr
-from mic.utils.partitionedfs import PartitionedMount
 
 import mic.imager.direct as direct
 from mic.pluginbase import ImagerPlugin
scripts/lib/mic/plugins/source/bootimg-efi.py +0 -1
index d4a7771..e880358 100644
@@ -33,7 +33,6 @@ from mic import kickstart, msger
 from mic.utils import misc, fs_related, errors, runner, cmdln
 from mic.conf import configmgr
 from mic.plugin import pluginmgr
-from mic.utils.partitionedfs import PartitionedMount
 import mic.imager.direct as direct
 from mic.pluginbase import SourcePlugin
 from mic.utils.oe.misc import *
scripts/lib/mic/plugins/source/bootimg-pcbios.py +0 -1
index 3434320..53ed7c3 100644
@@ -33,7 +33,6 @@ from mic import kickstart, msger
 from mic.utils import misc, fs_related, errors, runner, cmdln
 from mic.conf import configmgr
 from mic.plugin import pluginmgr
-from mic.utils.partitionedfs import PartitionedMount
 import mic.imager.direct as direct
 from mic.pluginbase import SourcePlugin
 from mic.utils.oe.misc import *
scripts/lib/mic/plugins/source/rootfs.py +0 -1
index 8cb576d..8ebf62c 100644
@@ -34,7 +34,6 @@ from mic import kickstart, msger
 from mic.utils import misc, fs_related, errors, runner, cmdln
 from mic.conf import configmgr
 from mic.plugin import pluginmgr
-from mic.utils.partitionedfs import PartitionedMount
 import mic.imager.direct as direct
 from mic.pluginbase import SourcePlugin
 from mic.utils.oe.misc import *
scripts/lib/mic/utils/partitionedfs.py +7 -1
index 2f950a6..f4ce4a9 100644
@@ -32,7 +32,13 @@ MBR_OVERHEAD = 1
 # Size of a sector in bytes
 SECTOR_SIZE = 512
 
-class PartitionedMount:
+class Image:
+    """
+    Generic base object for an image.
+
+    An Image is a container for a set of DiskImages and associated
+    partitions.
+    """
     def __init__(self):
         self.disks = {}
         self.partitions = []
Signature · 1 line
1.8.3.1
#34 lore raw

PATCH 32/35 wic: Rename MountError

In reply to Tom Zanussi

wic doesn't mount anything, so can't have a mount error; rename it to something more appropriate.

---
 scripts/lib/mic/imager/direct.py                 | 4 ++--
 scripts/lib/mic/plugins/source/bootimg-efi.py    | 2 +-
 scripts/lib/mic/plugins/source/bootimg-pcbios.py | 4 ++--
 scripts/lib/mic/utils/errors.py                  | 5 +----
 scripts/lib/mic/utils/partitionedfs.py           | 8 ++++----
 5 files changed, 10 insertions(+), 13 deletions(-)
scripts/lib/mic/imager/direct.py +2 -2
index a4f5691..2f2bd4e 100644
@@ -32,7 +32,7 @@ import shutil
 from mic import kickstart, msger
 from mic.utils import fs_related, runner, misc
 from mic.utils.partitionedfs import Image
-from mic.utils.errors import CreatorError, MountError
+from mic.utils.errors import CreatorError, ImageError
 from mic.imager.baseimager import BaseImageCreator
 from mic.utils.oe.misc import *
 from mic.plugin import pluginmgr
@@ -358,6 +358,6 @@ class DirectImageCreator(BaseImageCreator):
         if not self.__image is None:
             try:
                 self.__image.cleanup()
-            except MountError, err:
+            except ImageError, err:
                 msger.warning("%s" % err)
 
scripts/lib/mic/plugins/source/bootimg-efi.py +1 -1
index e880358..5b1a533 100644
@@ -77,7 +77,7 @@ class BootimgEFIPlugin(SourcePlugin):
         if cr._ptable_format == 'msdos':
             rootstr = rootdev
         else:
-            raise MountError("Unsupported partition table format found")
+            raise ImageError("Unsupported partition table format found")
 
         grubefi_conf += "linux %s root=%s rootwait %s\n" \
             % (kernel, rootstr, options)
scripts/lib/mic/plugins/source/bootimg-pcbios.py +2 -2
index 53ed7c3..959cf41 100644
@@ -62,7 +62,7 @@ class BootimgPcbiosPlugin(SourcePlugin):
         rc = runner.show(['dd', 'if=%s' % mbrfile,
                           'of=%s' % full_path, 'conv=notrunc'])
         if rc != 0:
-            raise MountError("Unable to set MBR to %s" % full_path)
+            raise ImageError("Unable to set MBR to %s" % full_path)
 
     @classmethod
     def do_configure_partition(self, part, cr, cr_workdir, oe_builddir,
@@ -107,7 +107,7 @@ class BootimgPcbiosPlugin(SourcePlugin):
         if cr._ptable_format == 'msdos':
             rootstr = rootdev
         else:
-            raise MountError("Unsupported partition table format found")
+            raise ImageError("Unsupported partition table format found")
 
         syslinux_conf += "APPEND label=boot root=%s %s\n" % (rootstr, options)
 
scripts/lib/mic/utils/errors.py +1 -4
index 38fda30..86e230a 100644
@@ -40,11 +40,8 @@ class Usage(CreatorError):
             self.msg = str(self.msg)
         return self.keyword + self.msg + ', please use "--help" for more info'
 
-class Abort(CreatorError):
-    keyword = ''
-
 class KsError(CreatorError):
     keyword = '<kickstart>'
 
-class MountError(CreatorError):
+class ImageError(CreatorError):
     keyword = '<mount>'
scripts/lib/mic/utils/partitionedfs.py +4 -4
index f4ce4a9..68e4cab 100644
@@ -22,7 +22,7 @@ import os
 
 from mic import msger
 from mic.utils import runner
-from mic.utils.errors import MountError
+from mic.utils.errors import ImageError
 from mic.utils.fs_related import *
 from mic.utils.oe.misc import *
 
@@ -121,7 +121,7 @@ class Image:
         msger.debug("Assigning %s partitions to disks" % ptable_format)
 
         if ptable_format not in ('msdos'):
-            raise MountError("Unknown partition table format '%s', supported " \
+            raise ImageError("Unknown partition table format '%s', supported " \
                              "formats are: 'msdos'" % ptable_format)
 
         if self._partitions_layed_out:
@@ -134,14 +134,14 @@ class Image:
             p = self.partitions[n]
 
             if not self.disks.has_key(p['disk_name']):
-                raise MountError("No disk %s for partition %s" \
+                raise ImageError("No disk %s for partition %s" \
                                  % (p['disk_name'], p['mountpoint']))
 
             if p['part_type']:
                 # The --part-type can also be implemented for MBR partitions,
                 # in which case it would map to the 1-byte "partition type"
                 # filed at offset 3 of the partition entry.
-                raise MountError("setting custom partition type is not " \
+                raise ImageError("setting custom partition type is not " \
                                  "implemented for msdos partitions")
 
             # Get the disk where the partition is located
Signature · 1 line
1.8.3.1
#35 lore raw

PATCH 33/35 wic: Update Disk description

In reply to Tom Zanussi

Remove obsolete comment.

---
 scripts/lib/mic/utils/fs_related.py | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
scripts/lib/mic/utils/fs_related.py +2 -5
index 07a5ff9..cf2a759 100644
@@ -60,11 +60,8 @@ def makedirs(dirname):
             raise
 
 class Disk:
-    """Generic base object for a disk
-
-    The 'create' method must make the disk visible as a block device - eg
-    by calling losetup. For RawDisk, this is obviously a no-op. The 'cleanup'
-    method must undo the 'create' operation.
+    """
+    Generic base object for a disk.
     """
     def __init__(self, size, device = None):
         self._device = device
Signature · 1 line
1.8.3.1
#36 lore raw

PATCH 34/35 wic: Rename /mic to /wic

In reply to Tom Zanussi

As well as any other stray instances of mic in the codebase that can be removed.

We don't really need to carry around legacy naming, and the history is in git.

---
 scripts/lib/image/engine.py                          | 12 ++++++------
 scripts/lib/image/help.py                            |  8 ++++----
 .../{mic => wic}/3rdparty/pykickstart/__init__.py    |  0
 .../lib/{mic => wic}/3rdparty/pykickstart/base.py    |  0
 .../3rdparty/pykickstart/commands/__init__.py        |  0
 .../3rdparty/pykickstart/commands/bootloader.py      |  0
 .../3rdparty/pykickstart/commands/partition.py       |  0
 .../{mic => wic}/3rdparty/pykickstart/constants.py   |  0
 .../lib/{mic => wic}/3rdparty/pykickstart/errors.py  |  0
 .../3rdparty/pykickstart/handlers/__init__.py        |  0
 .../3rdparty/pykickstart/handlers/control.py         |  0
 .../3rdparty/pykickstart/handlers/f16.py             |  0
 scripts/lib/{mic => wic}/3rdparty/pykickstart/ko.py  |  0
 .../lib/{mic => wic}/3rdparty/pykickstart/options.py |  0
 .../lib/{mic => wic}/3rdparty/pykickstart/parser.py  |  0
 .../{mic => wic}/3rdparty/pykickstart/sections.py    |  0
 .../lib/{mic => wic}/3rdparty/pykickstart/version.py |  0
 scripts/lib/{mic => wic}/__init__.py                 |  0
 scripts/lib/{mic => wic}/__version__.py              |  0
 scripts/lib/{mic => wic}/conf.py                     | 12 ++++++------
 scripts/lib/{mic => wic}/creator.py                  | 12 ++++++------
 scripts/lib/{mic => wic}/imager/__init__.py          |  0
 scripts/lib/{mic => wic}/imager/baseimager.py        | 10 +++++-----
 scripts/lib/{mic => wic}/imager/direct.py            | 17 ++++++++---------
 scripts/lib/{mic => wic}/kickstart/__init__.py       |  4 ++--
 .../kickstart/custom_commands/__init__.py            |  0
 .../kickstart/custom_commands/micboot.py             |  0
 .../kickstart/custom_commands/micpartition.py        |  0
 .../kickstart/custom_commands/partition.py           |  6 +++---
 .../kickstart/custom_commands/wicboot.py             |  2 +-
 scripts/lib/{mic => wic}/msger.py                    |  0
 scripts/lib/{mic => wic}/plugin.py                   | 16 ++++++++--------
 scripts/lib/{mic => wic}/pluginbase.py               | 20 ++++++++++----------
 .../lib/{mic => wic}/plugins/imager/direct_plugin.py | 15 +++++++--------
 .../lib/{mic => wic}/plugins/source/bootimg-efi.py   | 16 ++++++++--------
 .../{mic => wic}/plugins/source/bootimg-pcbios.py    | 16 ++++++++--------
 scripts/lib/{mic => wic}/plugins/source/rootfs.py    | 16 ++++++++--------
 scripts/lib/{mic => wic}/test                        |  0
 scripts/lib/{mic => wic}/utils/__init__.py           |  0
 scripts/lib/{mic => wic}/utils/cmdln.py              |  0
 scripts/lib/{mic => wic}/utils/errors.py             |  0
 scripts/lib/{mic => wic}/utils/fs_related.py         |  8 ++++----
 scripts/lib/{mic => wic}/utils/misc.py               |  0
 scripts/lib/{mic => wic}/utils/oe/__init__.py        |  2 +-
 scripts/lib/{mic => wic}/utils/oe/misc.py            |  6 +++---
 scripts/lib/{mic => wic}/utils/partitionedfs.py      | 10 +++++-----
 scripts/lib/{mic => wic}/utils/runner.py             |  2 +-
 47 files changed, 104 insertions(+), 106 deletions(-)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/__init__.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/base.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/commands/__init__.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/commands/bootloader.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/commands/partition.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/constants.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/errors.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/handlers/__init__.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/handlers/control.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/handlers/f16.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/ko.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/options.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/parser.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/sections.py (100%)
 rename scripts/lib/{mic => wic}/3rdparty/pykickstart/version.py (100%)
 rename scripts/lib/{mic => wic}/__init__.py (100%)
 rename scripts/lib/{mic => wic}/__version__.py (100%)
 rename scripts/lib/{mic => wic}/conf.py (93%)
 rename scripts/lib/{mic => wic}/creator.py (96%)
 rename scripts/lib/{mic => wic}/imager/__init__.py (100%)
 rename scripts/lib/{mic => wic}/imager/baseimager.py (96%)
 rename scripts/lib/{mic => wic}/imager/direct.py (96%)
 rename scripts/lib/{mic => wic}/kickstart/__init__.py (98%)
 rename scripts/lib/{mic => wic}/kickstart/custom_commands/__init__.py (100%)
 rename scripts/lib/{mic => wic}/kickstart/custom_commands/micboot.py (100%)
 rename scripts/lib/{mic => wic}/kickstart/custom_commands/micpartition.py (100%)
 rename scripts/lib/{mic => wic}/kickstart/custom_commands/partition.py (99%)
 rename scripts/lib/{mic => wic}/kickstart/custom_commands/wicboot.py (97%)
 rename scripts/lib/{mic => wic}/msger.py (100%)
 rename scripts/lib/{mic => wic}/plugin.py (94%)
 rename scripts/lib/{mic => wic}/pluginbase.py (88%)
 rename scripts/lib/{mic => wic}/plugins/imager/direct_plugin.py (89%)
 rename scripts/lib/{mic => wic}/plugins/source/bootimg-efi.py (94%)
 rename scripts/lib/{mic => wic}/plugins/source/bootimg-pcbios.py (95%)
 rename scripts/lib/{mic => wic}/plugins/source/rootfs.py (90%)
 rename scripts/lib/{mic => wic}/test (100%)
 rename scripts/lib/{mic => wic}/utils/__init__.py (100%)
 rename scripts/lib/{mic => wic}/utils/cmdln.py (100%)
 rename scripts/lib/{mic => wic}/utils/errors.py (100%)
 rename scripts/lib/{mic => wic}/utils/fs_related.py (96%)
 rename scripts/lib/{mic => wic}/utils/misc.py (100%)
 rename scripts/lib/{mic => wic}/utils/oe/__init__.py (95%)
 rename scripts/lib/{mic => wic}/utils/oe/misc.py (97%)
 rename scripts/lib/{mic => wic}/utils/partitionedfs.py (98%)
 rename scripts/lib/{mic => wic}/utils/runner.py (99%)
scripts/lib/image/engine.py +6 -6
index b850bb9..f1df8b4 100644
@@ -37,12 +37,12 @@ import subprocess
 import shutil
 
 import os, sys, errno
-from mic import msger, creator
-from mic.utils import cmdln, misc, errors
-from mic.conf import configmgr
-from mic.plugin import pluginmgr
-from mic.__version__ import VERSION
-from mic.utils.oe.misc import *
+from wic import msger, creator
+from wic.utils import cmdln, misc, errors
+from wic.conf import configmgr
+from wic.plugin import pluginmgr
+from wic.__version__ import VERSION
+from wic.utils.oe.misc import *
 
 
 def verify_build_env():
scripts/lib/image/help.py +4 -4
index 6503aaa..080795e 100644
@@ -144,7 +144,7 @@ DESCRIPTION
     the corresponding artifacts are typically found in a normal
     OpenEmbedded build.
 
-    Alternatively, users can use the -e option to have 'mic' determine
+    Alternatively, users can use the -e option to have 'wic' determine
     those locations for a given image.  If the -e option is used, the
     user needs to have set the appropriate MACHINE variable in
     local.conf, and have sourced the build environment.
@@ -349,12 +349,12 @@ DESCRIPTION
     implementation that populates a corresponding partition.
 
     A source plugin is created as a subclass of SourcePlugin (see
-    scripts/lib/mic/pluginbase.py) and the plugin file containing it
-    is added to scripts/lib/mic/plugins/source/ to make the plugin
+    scripts/lib/wic/pluginbase.py) and the plugin file containing it
+    is added to scripts/lib/wic/plugins/source/ to make the plugin
     implementation available to the wic implementation.
 
     Source plugins can also be implemented and added by external
-    layers - any plugins found in a scripts/lib/mic/plugins/source/
+    layers - any plugins found in a scripts/lib/wic/plugins/source/
     directory in an external layer will also be made available.
 
     When the wic implementation needs to invoke a partition-specific
scripts/lib/wic/3rdparty/pykickstart/__init__.py renamed from scripts/lib/mic/3rdparty/pykickstart/__init__.py +0 -0
similarity index 100%
rename from scripts/lib/mic/3rdparty/pykickstart/__init__.py
rename to scripts/lib/wic/3rdparty/pykickstart/__init__.py
scripts/lib/wic/3rdparty/pykickstart/base.py renamed from scripts/lib/mic/3rdparty/pykickstart/base.py +0 -0
similarity index 100%
rename from scripts/lib/mic/3rdparty/pykickstart/base.py
rename to scripts/lib/wic/3rdparty/pykickstart/base.py
scripts/lib/wic/3rdparty/pykickstart/commands/__init__.py renamed from scripts/lib/mic/3rdparty/pykickstart/commands/__init__.py +0 -0
similarity index 100%
rename from scripts/lib/mic/3rdparty/pykickstart/commands/__init__.py
rename to scripts/lib/wic/3rdparty/pykickstart/commands/__init__.py
scripts/lib/wic/3rdparty/pykickstart/commands/bootloader.py renamed from scripts/lib/mic/3rdparty/pykickstart/commands/bootloader.py +0 -0
similarity index 100%
rename from scripts/lib/mic/3rdparty/pykickstart/commands/bootloader.py
rename to scripts/lib/wic/3rdparty/pykickstart/commands/bootloader.py
scripts/lib/wic/3rdparty/pykickstart/commands/partition.py renamed from scripts/lib/mic/3rdparty/pykickstart/commands/partition.py +0 -0
similarity index 100%
rename from scripts/lib/mic/3rdparty/pykickstart/commands/partition.py
rename to scripts/lib/wic/3rdparty/pykickstart/commands/partition.py
scripts/lib/wic/3rdparty/pykickstart/constants.py renamed from scripts/lib/mic/3rdparty/pykickstart/constants.py +0 -0
similarity index 100%
rename from scripts/lib/mic/3rdparty/pykickstart/constants.py
rename to scripts/lib/wic/3rdparty/pykickstart/constants.py
scripts/lib/wic/3rdparty/pykickstart/errors.py renamed from scripts/lib/mic/3rdparty/pykickstart/errors.py +0 -0
similarity index 100%
rename from scripts/lib/mic/3rdparty/pykickstart/errors.py
rename to scripts/lib/wic/3rdparty/pykickstart/errors.py
scripts/lib/wic/3rdparty/pykickstart/handlers/__init__.py renamed from scripts/lib/mic/3rdparty/pykickstart/handlers/__init__.py +0 -0
similarity index 100%
rename from scripts/lib/mic/3rdparty/pykickstart/handlers/__init__.py
rename to scripts/lib/wic/3rdparty/pykickstart/handlers/__init__.py
scripts/lib/wic/3rdparty/pykickstart/handlers/control.py renamed from scripts/lib/mic/3rdparty/pykickstart/handlers/control.py +0 -0
similarity index 100%
rename from scripts/lib/mic/3rdparty/pykickstart/handlers/control.py
rename to scripts/lib/wic/3rdparty/pykickstart/handlers/control.py
scripts/lib/wic/3rdparty/pykickstart/handlers/f16.py renamed from scripts/lib/mic/3rdparty/pykickstart/handlers/f16.py +0 -0
similarity index 100%
rename from scripts/lib/mic/3rdparty/pykickstart/handlers/f16.py
rename to scripts/lib/wic/3rdparty/pykickstart/handlers/f16.py
scripts/lib/wic/3rdparty/pykickstart/ko.py renamed from scripts/lib/mic/3rdparty/pykickstart/ko.py +0 -0
similarity index 100%
rename from scripts/lib/mic/3rdparty/pykickstart/ko.py
rename to scripts/lib/wic/3rdparty/pykickstart/ko.py
scripts/lib/wic/3rdparty/pykickstart/options.py renamed from scripts/lib/mic/3rdparty/pykickstart/options.py +0 -0
similarity index 100%
rename from scripts/lib/mic/3rdparty/pykickstart/options.py
rename to scripts/lib/wic/3rdparty/pykickstart/options.py
scripts/lib/wic/3rdparty/pykickstart/parser.py renamed from scripts/lib/mic/3rdparty/pykickstart/parser.py +0 -0
similarity index 100%
rename from scripts/lib/mic/3rdparty/pykickstart/parser.py
rename to scripts/lib/wic/3rdparty/pykickstart/parser.py
scripts/lib/wic/3rdparty/pykickstart/sections.py renamed from scripts/lib/mic/3rdparty/pykickstart/sections.py +0 -0
similarity index 100%
rename from scripts/lib/mic/3rdparty/pykickstart/sections.py
rename to scripts/lib/wic/3rdparty/pykickstart/sections.py
scripts/lib/wic/3rdparty/pykickstart/version.py renamed from scripts/lib/mic/3rdparty/pykickstart/version.py +0 -0
similarity index 100%
rename from scripts/lib/mic/3rdparty/pykickstart/version.py
rename to scripts/lib/wic/3rdparty/pykickstart/version.py
scripts/lib/wic/__init__.py renamed from scripts/lib/mic/__init__.py +0 -0
similarity index 100%
rename from scripts/lib/mic/__init__.py
rename to scripts/lib/wic/__init__.py
scripts/lib/wic/__version__.py renamed from scripts/lib/mic/__version__.py +0 -0
similarity index 100%
rename from scripts/lib/mic/__version__.py
rename to scripts/lib/wic/__version__.py
scripts/lib/wic/conf.py renamed from scripts/lib/mic/conf.py +6 -6
similarity index 93%
rename from scripts/lib/mic/conf.py
rename to scripts/lib/wic/conf.py
index a686e9c..d5419f8 100644
@@ -18,15 +18,15 @@
 import os, sys, re
 import ConfigParser
 
-from mic import msger
-from mic import kickstart
-from mic.utils import misc, runner, errors
+from wic import msger
+from wic import kickstart
+from wic.utils import misc, runner, errors
 
 
 def get_siteconf():
-    mic_path = os.path.dirname(__file__)
-    eos = mic_path.find('scripts') + len('scripts')
-    scripts_path = mic_path[:eos]
+    wic_path = os.path.dirname(__file__)
+    eos = wic_path.find('scripts') + len('scripts')
+    scripts_path = wic_path[:eos]
 
     return scripts_path + "/lib/image/config/wic.conf"
 
scripts/lib/wic/creator.py renamed from scripts/lib/mic/creator.py +6 -6
similarity index 96%
rename from scripts/lib/mic/creator.py
rename to scripts/lib/wic/creator.py
index 7c9ca6f..a4b19ac 100644
@@ -18,10 +18,10 @@
 import os, sys, re
 from optparse import SUPPRESS_HELP
 
-from mic import msger
-from mic.utils import cmdln, errors
-from mic.conf import configmgr
-from mic.plugin import pluginmgr
+from wic import msger
+from wic.utils import cmdln, errors
+from wic.conf import configmgr
+from wic.plugin import pluginmgr
 
 
 class Creator(cmdln.Cmdln):
@@ -34,7 +34,7 @@ class Creator(cmdln.Cmdln):
     ${option_list}
     """
 
-    name = 'mic create(cr)'
+    name = 'wic create(cr)'
 
     def __init__(self, *args, **kwargs):
         cmdln.Cmdln.__init__(self, *args, **kwargs)
@@ -64,7 +64,7 @@ class Creator(cmdln.Cmdln):
                              help='Path of logfile')
         optparser.add_option('-c', '--config', type='string', dest='config',
                              default=None,
-                             help='Specify config file for mic')
+                             help='Specify config file for wic')
         optparser.add_option('-o', '--outdir', type='string', action='store',
                              dest='outdir', default=None,
                              help='Output directory')
scripts/lib/wic/imager/__init__.py renamed from scripts/lib/mic/imager/__init__.py +0 -0
similarity index 100%
rename from scripts/lib/mic/imager/__init__.py
rename to scripts/lib/wic/imager/__init__.py
scripts/lib/wic/imager/baseimager.py renamed from scripts/lib/mic/imager/baseimager.py +5 -5
similarity index 96%
rename from scripts/lib/mic/imager/baseimager.py
rename to scripts/lib/wic/imager/baseimager.py
index 23919d4..5bcd2f7 100644
@@ -21,10 +21,10 @@ import os, sys
 import tempfile
 import shutil
 
-from mic import kickstart
-from mic import msger
-from mic.utils.errors import CreatorError
-from mic.utils import misc, runner, fs_related as fs
+from wic import kickstart
+from wic import msger
+from wic.utils.errors import CreatorError
+from wic.utils import misc, runner, fs_related as fs
 
 class BaseImageCreator(object):
     """Base class for image creation.
@@ -34,7 +34,7 @@ class BaseImageCreator(object):
 
     e.g.
 
-      import mic.imgcreate as imgcreate
+      import wic.imgcreate as imgcreate
       ks = imgcreate.read_kickstart("foo.ks")
       imgcreate.ImageCreator(ks, "foo").create()
     """
scripts/lib/wic/imager/direct.py renamed from scripts/lib/mic/imager/direct.py +8 -9
similarity index 96%
rename from scripts/lib/mic/imager/direct.py
rename to scripts/lib/wic/imager/direct.py
index 2f2bd4e..5b12856 100644
@@ -18,8 +18,7 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
 # DESCRIPTION
-# This implements the 'direct' image creator class for 'wic', based
-# loosely on the raw image creator from 'mic'
+# This implements the 'direct' image creator class for 'wic'
 #
 # AUTHORS
 # Tom Zanussi <tom.zanussi (at] linux.intel.com>
@@ -29,13 +28,13 @@ import os
 import stat
 import shutil
 
-from mic import kickstart, msger
-from mic.utils import fs_related, runner, misc
-from mic.utils.partitionedfs import Image
-from mic.utils.errors import CreatorError, ImageError
-from mic.imager.baseimager import BaseImageCreator
-from mic.utils.oe.misc import *
-from mic.plugin import pluginmgr
+from wic import kickstart, msger
+from wic.utils import fs_related, runner, misc
+from wic.utils.partitionedfs import Image
+from wic.utils.errors import CreatorError, ImageError
+from wic.imager.baseimager import BaseImageCreator
+from wic.utils.oe.misc import *
+from wic.plugin import pluginmgr
 
 disk_methods = {
     "do_install_disk":None,
scripts/lib/wic/kickstart/__init__.py renamed from scripts/lib/mic/kickstart/__init__.py +2 -2
similarity index 98%
rename from scripts/lib/mic/kickstart/__init__.py
rename to scripts/lib/wic/kickstart/__init__.py
index 590bf47..4f5b778 100644
@@ -30,8 +30,8 @@ import pykickstart.version as ksversion
 from pykickstart.handlers.control import commandMap
 from pykickstart.handlers.control import dataMap
 
-from mic import msger
-from mic.utils import errors, misc, runner, fs_related as fs
+from wic import msger
+from wic.utils import errors, misc, runner, fs_related as fs
 from custom_commands import wicboot, partition
 
 def read_kickstart(path):
scripts/lib/wic/kickstart/custom_commands/__init__.py renamed from scripts/lib/mic/kickstart/custom_commands/__init__.py +0 -0
similarity index 100%
rename from scripts/lib/mic/kickstart/custom_commands/__init__.py
rename to scripts/lib/wic/kickstart/custom_commands/__init__.py
scripts/lib/wic/kickstart/custom_commands/micboot.py renamed from scripts/lib/mic/kickstart/custom_commands/micboot.py +0 -0
similarity index 100%
rename from scripts/lib/mic/kickstart/custom_commands/micboot.py
rename to scripts/lib/wic/kickstart/custom_commands/micboot.py
scripts/lib/wic/kickstart/custom_commands/micpartition.py renamed from scripts/lib/mic/kickstart/custom_commands/micpartition.py +0 -0
similarity index 100%
rename from scripts/lib/mic/kickstart/custom_commands/micpartition.py
rename to scripts/lib/wic/kickstart/custom_commands/micpartition.py
scripts/lib/wic/kickstart/custom_commands/partition.py renamed from scripts/lib/mic/kickstart/custom_commands/partition.py +3 -3
similarity index 99%
rename from scripts/lib/mic/kickstart/custom_commands/partition.py
rename to scripts/lib/wic/kickstart/custom_commands/partition.py
index 101b90e..24f523a 100644
@@ -29,9 +29,9 @@ import os
 import tempfile
 
 from pykickstart.commands.partition import *
-from mic.utils.oe.misc import *
-from mic.kickstart.custom_commands import *
-from mic.plugin import pluginmgr
+from wic.utils.oe.misc import *
+from wic.kickstart.custom_commands import *
+from wic.plugin import pluginmgr
 
 partition_methods = {
     "do_stage_partition":None,
scripts/lib/wic/kickstart/custom_commands/wicboot.py renamed from scripts/lib/mic/kickstart/custom_commands/wicboot.py +1 -1
similarity index 97%
rename from scripts/lib/mic/kickstart/custom_commands/wicboot.py
rename to scripts/lib/wic/kickstart/custom_commands/wicboot.py
index ab8871d..f191416 100644
@@ -29,7 +29,7 @@ from pykickstart.errors import *
 from pykickstart.options import *
 from pykickstart.commands.bootloader import *
 
-from mic.kickstart.custom_commands.micboot import *
+from wic.kickstart.custom_commands.micboot import *
 
 class Wic_Bootloader(Mic_Bootloader):
     def __init__(self, writePriority=10, appendLine="", driveorder=None,
scripts/lib/wic/msger.py renamed from scripts/lib/mic/msger.py +0 -0
similarity index 100%
rename from scripts/lib/mic/msger.py
rename to scripts/lib/wic/msger.py
scripts/lib/wic/plugin.py renamed from scripts/lib/mic/plugin.py +8 -8
similarity index 94%
rename from scripts/lib/mic/plugin.py
rename to scripts/lib/wic/plugin.py
index 43afdbc..61c5859 100644
@@ -17,16 +17,16 @@
 
 import os, sys
 
-from mic import msger
-from mic import pluginbase
-from mic.utils import errors
-from mic.utils.oe.misc import *
+from wic import msger
+from wic import pluginbase
+from wic.utils import errors
+from wic.utils.oe.misc import *
 
 __ALL__ = ['PluginMgr', 'pluginmgr']
 
 PLUGIN_TYPES = ["imager", "source"]
 
-PLUGIN_DIR = "/lib/mic/plugins" # relative to scripts
+PLUGIN_DIR = "/lib/wic/plugins" # relative to scripts
 SCRIPTS_PLUGIN_DIR = "scripts" + PLUGIN_DIR
 
 class PluginMgr(object):
@@ -41,9 +41,9 @@ class PluginMgr(object):
         return cls._instance
 
     def __init__(self):
-        mic_path = os.path.dirname(__file__)
-        eos = mic_path.find('scripts') + len('scripts')
-        scripts_path = mic_path[:eos]
+        wic_path = os.path.dirname(__file__)
+        eos = wic_path.find('scripts') + len('scripts')
+        scripts_path = wic_path[:eos]
         self.scripts_path = scripts_path
         self.plugin_dir = scripts_path + PLUGIN_DIR
         self.layers_path = None
scripts/lib/wic/pluginbase.py renamed from scripts/lib/mic/pluginbase.py +10 -10
similarity index 88%
rename from scripts/lib/mic/pluginbase.py
rename to scripts/lib/wic/pluginbase.py
index 46a4f4a..06f318f 100644
@@ -17,8 +17,8 @@
 
 import os
 import shutil
-from mic import msger
-from mic.utils import errors
+from wic import msger
+from wic.utils import errors
 
 class _Plugin(object):
     class __metaclass__(type):
@@ -26,15 +26,15 @@ class _Plugin(object):
             if not hasattr(cls, 'plugins'):
                 cls.plugins = {}
 
-            elif 'mic_plugin_type' in attrs:
-                if attrs['mic_plugin_type'] not in cls.plugins:
-                    cls.plugins[attrs['mic_plugin_type']] = {}
+            elif 'wic_plugin_type' in attrs:
+                if attrs['wic_plugin_type'] not in cls.plugins:
+                    cls.plugins[attrs['wic_plugin_type']] = {}
 
-            elif hasattr(cls, 'mic_plugin_type') and 'name' in attrs:
-                cls.plugins[cls.mic_plugin_type][attrs['name']] = cls
+            elif hasattr(cls, 'wic_plugin_type') and 'name' in attrs:
+                cls.plugins[cls.wic_plugin_type][attrs['name']] = cls
 
         def show_plugins(cls):
-            for cls in cls.plugins[cls.mic_plugin_type]:
+            for cls in cls.plugins[cls.wic_plugin_type]:
                 print cls
 
         def get_plugins(cls):
@@ -42,11 +42,11 @@ class _Plugin(object):
 
 
 class ImagerPlugin(_Plugin):
-    mic_plugin_type = "imager"
+    wic_plugin_type = "imager"
 
 
 class SourcePlugin(_Plugin):
-    mic_plugin_type = "source"
+    wic_plugin_type = "source"
     """
     The methods that can be implemented by --source plugins.
 
scripts/lib/wic/plugins/imager/direct_plugin.py renamed from scripts/lib/mic/plugins/imager/direct_plugin.py +7 -8
similarity index 89%
rename from scripts/lib/mic/plugins/imager/direct_plugin.py
rename to scripts/lib/wic/plugins/imager/direct_plugin.py
index c05a400..dabd6fc 100644
@@ -18,8 +18,7 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
 # DESCRIPTION
-# This implements the 'direct' imager plugin class for 'wic', based
-# loosely on the raw imager plugin from 'mic'
+# This implements the 'direct' imager plugin class for 'wic'
 #
 # AUTHORS
 # Tom Zanussi <tom.zanussi (at] linux.intel.com>
@@ -30,13 +29,13 @@ import shutil
 import re
 import tempfile
 
-from mic import msger
-from mic.utils import misc, fs_related, errors, runner, cmdln
-from mic.conf import configmgr
-from mic.plugin import pluginmgr
+from wic import msger
+from wic.utils import misc, fs_related, errors, runner, cmdln
+from wic.conf import configmgr
+from wic.plugin import pluginmgr
 
-import mic.imager.direct as direct
-from mic.pluginbase import ImagerPlugin
+import wic.imager.direct as direct
+from wic.pluginbase import ImagerPlugin
 
 class DirectPlugin(ImagerPlugin):
     name = 'direct'
scripts/lib/wic/plugins/source/bootimg-efi.py renamed from scripts/lib/mic/plugins/source/bootimg-efi.py +8 -8
similarity index 94%
rename from scripts/lib/mic/plugins/source/bootimg-efi.py
rename to scripts/lib/wic/plugins/source/bootimg-efi.py
index 5b1a533..53f1782 100644
@@ -29,14 +29,14 @@ import shutil
 import re
 import tempfile
 
-from mic import kickstart, msger
-from mic.utils import misc, fs_related, errors, runner, cmdln
-from mic.conf import configmgr
-from mic.plugin import pluginmgr
-import mic.imager.direct as direct
-from mic.pluginbase import SourcePlugin
-from mic.utils.oe.misc import *
-from mic.imager.direct import DirectImageCreator
+from wic import kickstart, msger
+from wic.utils import misc, fs_related, errors, runner, cmdln
+from wic.conf import configmgr
+from wic.plugin import pluginmgr
+import wic.imager.direct as direct
+from wic.pluginbase import SourcePlugin
+from wic.utils.oe.misc import *
+from wic.imager.direct import DirectImageCreator
 
 class BootimgEFIPlugin(SourcePlugin):
     name = 'bootimg-efi'
scripts/lib/wic/plugins/source/bootimg-pcbios.py renamed from scripts/lib/mic/plugins/source/bootimg-pcbios.py +8 -8
similarity index 95%
rename from scripts/lib/mic/plugins/source/bootimg-pcbios.py
rename to scripts/lib/wic/plugins/source/bootimg-pcbios.py
index 959cf41..bd2225e 100644
@@ -29,14 +29,14 @@ import shutil
 import re
 import tempfile
 
-from mic import kickstart, msger
-from mic.utils import misc, fs_related, errors, runner, cmdln
-from mic.conf import configmgr
-from mic.plugin import pluginmgr
-import mic.imager.direct as direct
-from mic.pluginbase import SourcePlugin
-from mic.utils.oe.misc import *
-from mic.imager.direct import DirectImageCreator
+from wic import kickstart, msger
+from wic.utils import misc, fs_related, errors, runner, cmdln
+from wic.conf import configmgr
+from wic.plugin import pluginmgr
+import wic.imager.direct as direct
+from wic.pluginbase import SourcePlugin
+from wic.utils.oe.misc import *
+from wic.imager.direct import DirectImageCreator
 
 class BootimgPcbiosPlugin(SourcePlugin):
     name = 'bootimg-pcbios'
scripts/lib/wic/plugins/source/rootfs.py renamed from scripts/lib/mic/plugins/source/rootfs.py +8 -8
similarity index 90%
rename from scripts/lib/mic/plugins/source/rootfs.py
rename to scripts/lib/wic/plugins/source/rootfs.py
index 8ebf62c..919e97e 100644
@@ -30,14 +30,14 @@ import shutil
 import re
 import tempfile
 
-from mic import kickstart, msger
-from mic.utils import misc, fs_related, errors, runner, cmdln
-from mic.conf import configmgr
-from mic.plugin import pluginmgr
-import mic.imager.direct as direct
-from mic.pluginbase import SourcePlugin
-from mic.utils.oe.misc import *
-from mic.imager.direct import DirectImageCreator
+from wic import kickstart, msger
+from wic.utils import misc, fs_related, errors, runner, cmdln
+from wic.conf import configmgr
+from wic.plugin import pluginmgr
+import wic.imager.direct as direct
+from wic.pluginbase import SourcePlugin
+from wic.utils.oe.misc import *
+from wic.imager.direct import DirectImageCreator
 
 class RootfsPlugin(SourcePlugin):
     name = 'rootfs'
scripts/lib/wic/test renamed from scripts/lib/mic/test +0 -0
similarity index 100%
rename from scripts/lib/mic/test
rename to scripts/lib/wic/test
scripts/lib/wic/utils/__init__.py renamed from scripts/lib/mic/utils/__init__.py +0 -0
similarity index 100%
rename from scripts/lib/mic/utils/__init__.py
rename to scripts/lib/wic/utils/__init__.py
scripts/lib/wic/utils/cmdln.py renamed from scripts/lib/mic/utils/cmdln.py +0 -0
similarity index 100%
rename from scripts/lib/mic/utils/cmdln.py
rename to scripts/lib/wic/utils/cmdln.py
scripts/lib/wic/utils/errors.py renamed from scripts/lib/mic/utils/errors.py +0 -0
similarity index 100%
rename from scripts/lib/mic/utils/errors.py
rename to scripts/lib/wic/utils/errors.py
scripts/lib/wic/utils/fs_related.py renamed from scripts/lib/mic/utils/fs_related.py +4 -4
similarity index 96%
rename from scripts/lib/mic/utils/fs_related.py
rename to scripts/lib/wic/utils/fs_related.py
index cf2a759..79cc1d5 100644
@@ -26,10 +26,10 @@ import string
 import time
 import uuid
 
-from mic import msger
-from mic.utils import runner
-from mic.utils.errors import *
-from mic.utils.oe.misc import *
+from wic import msger
+from wic.utils import runner
+from wic.utils.errors import *
+from wic.utils.oe.misc import *
 
 def find_binary_path(binary):
     if os.environ.has_key("PATH"):
scripts/lib/wic/utils/misc.py renamed from scripts/lib/mic/utils/misc.py +0 -0
similarity index 100%
rename from scripts/lib/mic/utils/misc.py
rename to scripts/lib/wic/utils/misc.py
scripts/lib/wic/utils/oe/__init__.py renamed from scripts/lib/mic/utils/oe/__init__.py +1 -1
similarity index 95%
rename from scripts/lib/mic/utils/oe/__init__.py
rename to scripts/lib/wic/utils/oe/__init__.py
index d10e802..0a81575 100644
@@ -1,5 +1,5 @@
 #
-# OpenEmbedded mic utils library
+# OpenEmbedded wic utils library
 #
 # Copyright (c) 2013, Intel Corporation.
 # All rights reserved.
scripts/lib/wic/utils/oe/misc.py renamed from scripts/lib/mic/utils/oe/misc.py +3 -3
similarity index 97%
rename from scripts/lib/mic/utils/oe/misc.py
rename to scripts/lib/wic/utils/oe/misc.py
index bed2750..87e3041 100644
@@ -18,15 +18,15 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
 # DESCRIPTION
-# This module provides a place to collect various mic-related utils
+# This module provides a place to collect various wic-related utils
 # for the OpenEmbedded Image Tools.
 #
 # AUTHORS
 # Tom Zanussi <tom.zanussi (at] linux.intel.com>
 #
 
-from mic import msger
-from mic.utils import runner
+from wic import msger
+from wic.utils import runner
 
 def __exec_cmd(cmd_and_args, as_shell = False, catch = 3):
     """
scripts/lib/wic/utils/partitionedfs.py renamed from scripts/lib/mic/utils/partitionedfs.py +5 -5
similarity index 98%
rename from scripts/lib/mic/utils/partitionedfs.py
rename to scripts/lib/wic/utils/partitionedfs.py
index 68e4cab..76aa421 100644
@@ -20,11 +20,11 @@
 
 import os
 
-from mic import msger
-from mic.utils import runner
-from mic.utils.errors import ImageError
-from mic.utils.fs_related import *
-from mic.utils.oe.misc import *
+from wic import msger
+from wic.utils import runner
+from wic.utils.errors import ImageError
+from wic.utils.fs_related import *
+from wic.utils.oe.misc import *
 
 # Overhead of the MBR partitioning scheme (just one sector)
 MBR_OVERHEAD = 1
scripts/lib/wic/utils/runner.py renamed from scripts/lib/mic/utils/runner.py +1 -1
similarity index 99%
rename from scripts/lib/mic/utils/runner.py
rename to scripts/lib/wic/utils/runner.py
index fded3c9..e740dad 100644
@@ -18,7 +18,7 @@
 import os
 import subprocess
 
-from mic import msger
+from wic import msger
 
 def runtool(cmdln_or_args, catch=1):
     """ wrapper for most of the subprocess calls
Signature · 1 line
1.8.3.1
#37 lore raw

PATCH 35/35 wic: Bump the version to 2.0

In reply to Tom Zanussi

This represents a complete rework, and if we assume the previous version should have been 1.0 (instead of a silly .1x version), then this should be 2.0.

---
 scripts/lib/wic/__version__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/lib/wic/__version__.py +1 -1
index 60d7626..5452a46 100644
@@ -1 +1 @@
-VERSION = "0.14"
+VERSION = "2.00"
Signature · 1 line
1.8.3.1