wishlist: decouple templates from architectures #463

Closed
yarikoptic opened this Issue Jan 3, 2013 · 6 comments

2 participants

@yarikoptic

ATM, templates are pretty much duplicated for e.g. two different architectures (could theoretically be a dozen ;) ) without any changes. Carrying duplicates is known to be more cumbersome and leads to diversions between them (e.g. compare two for Debian-7.0-b4-*-netboot).

To accomplish it, veewee should accept an additional cmdline option to specify which architecture to use. If none is provided -- assume old behavior. Further, internally I see at least two possible ways how to play with the specifications

  • making Definitions dictionary structure architecture aware, i.e. for
  :iso_file => "debian-wheezy-DI-b4-amd64-netinst.iso",
  :iso_src => "http://cdimage.debian.org/cdimage/wheezy_di_beta4/amd64/iso-cd/debian-wheezy-DI-b4-amd64-netinst.iso",
  :iso_md5 => "9fcd2bb541f9b6b32f2a17116d606bed",

have

  :iso_file => {"amd64": "debian-wheezy-DI-b4-amd64-netinst.iso",
                        "i386": "debian-wheezy-DI-b4-i386-netinst.iso"},
and so on
  • or may be define dictionary outside of direct call to Declare and then update corresponding iso_ fields via ruby code conditioned on exposed architecture, e.g.
spec_common = {
  :cpu_count => '1',
...
  :postinstall_timeout => "10000"
}

spec_archs = {
  "i386" => {
    :iso_file => "debian-wheezy-DI-b4-i386-netinst.iso",
    :iso_src => "http://cdimage.debian.org/cdimage/wheezy_di_beta4/i386/iso-cd/debian-wheezy-DI-b4-i386-netinst.iso",
    :iso_md5 => "34d0ae973715c7a31646281c70839809",
  },
  "amd64" => {
    :iso_file => "debian-wheezy-DI-b4-amd64-netinst.iso",
    :iso_src => "http://cdimage.debian.org/cdimage/wheezy_di_beta4/amd64/iso-cd/debian-wheezy-DI-b4-amd64-netinst.iso",
    :iso_md5 => "9fcd2bb541f9b6b32f2a17116d606bed",
  }}


d = File.expand_path(File.dirname(__FILE__))
m = /.*-(?<arch>.*?)$/.match(d)
Veewee::Definition.declare(spec_common.merge(spec_archs[m[:arch]]))

In above I tried to trick veewee by creating a single definitions/OS while providing symlinks to it as definitions/OS-amd64 and definitions/OS-i386 ... unfortunately didn't work since interally veewee I guess follows symlinks, so d becomes the pure OS one.... [meanwhile I had to create those two directories and symlink files -- seems to start ok ;) ]

but that is just for an idea and I bet you would come up with a better resolution. Cheers!

@yarikoptic

FWIW -- tried with symlinks to each file:

yoh@orphan:~/deb/perspect/veewee-boxes/nd$ ls -l definitions/neurodebian-6.999.b4.20120103*
definitions/neurodebian-6.999.b4.20120103:
total 48
-rw-r--r-- 1 yoh yoh   732 Jan  2 13:38 base.sh
-rw-r--r-- 1 yoh yoh   559 Jan  2 13:38 cleanup.sh
-rw-r--r-- 1 yoh yoh   114 Jan  2 13:38 cleanup-virtualbox.sh
-rw-r--r-- 1 yoh yoh  2100 Jan  3 13:49 definition.rb
-rw-r--r-- 1 yoh yoh  3532 Jan  2 15:50 neurodebian.sh
-rw-r--r-- 1 yoh yoh 13486 Jan  2 15:52 preseed.cfg
-rw-r--r-- 1 yoh yoh   617 Jan  2 15:19 vagrant.sh
-rw-r--r-- 1 yoh yoh   485 Jan  2 13:38 virtualbox.sh
-rw-r--r-- 1 yoh yoh   105 Jan  2 13:38 zerodisk.sh

definitions/neurodebian-6.999.b4.20120103-amd64:
total 0
lrwxrwxrwx 1 yoh yoh 40 Jan  3 13:52 base.sh -> ../neurodebian-6.999.b4.20120103/base.sh
lrwxrwxrwx 1 yoh yoh 43 Jan  3 13:52 cleanup.sh -> ../neurodebian-6.999.b4.20120103/cleanup.sh
lrwxrwxrwx 1 yoh yoh 54 Jan  3 13:52 cleanup-virtualbox.sh -> ../neurodebian-6.999.b4.20120103/cleanup-virtualbox.sh
lrwxrwxrwx 1 yoh yoh 46 Jan  3 13:52 definition.rb -> ../neurodebian-6.999.b4.20120103/definition.rb
lrwxrwxrwx 1 yoh yoh 47 Jan  3 13:52 neurodebian.sh -> ../neurodebian-6.999.b4.20120103/neurodebian.sh
lrwxrwxrwx 1 yoh yoh 44 Jan  3 13:52 preseed.cfg -> ../neurodebian-6.999.b4.20120103/preseed.cfg
lrwxrwxrwx 1 yoh yoh 43 Jan  3 13:52 vagrant.sh -> ../neurodebian-6.999.b4.20120103/vagrant.sh
lrwxrwxrwx 1 yoh yoh 46 Jan  3 13:52 virtualbox.sh -> ../neurodebian-6.999.b4.20120103/virtualbox.sh
lrwxrwxrwx 1 yoh yoh 44 Jan  3 13:52 zerodisk.sh -> ../neurodebian-6.999.b4.20120103/zerodisk.sh

definitions/neurodebian-6.999.b4.20120103-i386:
total 0
lrwxrwxrwx 1 yoh yoh 40 Jan  3 13:52 base.sh -> ../neurodebian-6.999.b4.20120103/base.sh
lrwxrwxrwx 1 yoh yoh 43 Jan  3 13:52 cleanup.sh -> ../neurodebian-6.999.b4.20120103/cleanup.sh
lrwxrwxrwx 1 yoh yoh 54 Jan  3 13:52 cleanup-virtualbox.sh -> ../neurodebian-6.999.b4.20120103/cleanup-virtualbox.sh
lrwxrwxrwx 1 yoh yoh 46 Jan  3 13:52 definition.rb -> ../neurodebian-6.999.b4.20120103/definition.rb
lrwxrwxrwx 1 yoh yoh 47 Jan  3 13:52 neurodebian.sh -> ../neurodebian-6.999.b4.20120103/neurodebian.sh
lrwxrwxrwx 1 yoh yoh 44 Jan  3 13:52 preseed.cfg -> ../neurodebian-6.999.b4.20120103/preseed.cfg
lrwxrwxrwx 1 yoh yoh 43 Jan  3 13:52 vagrant.sh -> ../neurodebian-6.999.b4.20120103/vagrant.sh
lrwxrwxrwx 1 yoh yoh 46 Jan  3 13:52 virtualbox.sh -> ../neurodebian-6.999.b4.20120103/virtualbox.sh
lrwxrwxrwx 1 yoh yoh 44 Jan  3 13:52 zerodisk.sh -> ../neurodebian-6.999.b4.20120103/zerodisk.sh

worked nicely -- giving me both amd64 and i386 boxes out of a single definition ;-)

@jedi4ever
Owner
@yarikoptic

hooorraay -- I have reinvented the square wheel ;)

why not to adopt similar (apparently tested/deployed) strategy in veewee itself?

@yarikoptic

d'oh --- may be "windows users" would be the answer? ;)

@jedi4ever
Owner
@jedi4ever
Owner

Hardlinks seem to work - this will get fixed when the templates will be reorganized

@jedi4ever jedi4ever closed this Feb 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment