diff --git a/doc/zadm.pod b/doc/zadm.pod index 45baf8e..b933b3e 100644 --- a/doc/zadm.pod +++ b/doc/zadm.pod @@ -87,6 +87,7 @@ where 'command' is one of the following: set install [-i ] [-f] uninstall [-f] + updateres -i show [zone_name [property[,property]...]] list [-H] [-F ] [-b ] [-s ] [zone_name] memstat diff --git a/lib/Zadm/Zone/Emu.pm b/lib/Zadm/Zone/Emu.pm index 19d1a1b..579c44d 100644 --- a/lib/Zadm/Zone/Emu.pm +++ b/lib/Zadm/Zone/Emu.pm @@ -6,22 +6,32 @@ use Mojo::URL; has ibrand => sub($self) { $self->brand }; has template => sub($self) { - my $template = $self->SUPER::template; - return { %{$self->SUPER::template}, $self->hasimg ? %{$self->image->metadata->{attr} || {}} : (), } }; +has public => sub($self) { [ @{$self->SUPER::public}, qw(updateres) ] }; +has options => sub($self) { + return { + %{$self->SUPER::options}, + updateres => { + image => { + getopt => 'image|i=s', + }, + }, + } +}; # public methods -sub install($self, @args) { - $self->SUPER::install(@args); +sub updateres($self, @args) { + return 1 if $ENV{__ZADM_ALTROOT}; - return 1 if $ENV{__ZADM_ALTROOT} || !$self->hasimg - || !$self->utils->isArrRef($self->image->metadata->{res}); + $self->usage if !$self->hasimg; + + return 1 if !$self->utils->isArrRef($self->image->metadata->{res}); - # TODO: we could parallelise this; however, we just have one resource so far at maximum + # we could parallelise this; however, we just have a few resources and they are small # the advantage of doing it sequentially is that we can print progress for my $res (@{$self->image->metadata->{res}}) { my $file = Mojo::File->new($self->config->{zonepath}, 'root', Mojo::File->new($res)->basename); @@ -31,6 +41,15 @@ sub install($self, @args) { } } +sub install($self, @args) { + $self->SUPER::install(@args); + + return 1 if $ENV{__ZADM_ALTROOT} || !$self->hasimg + || !$self->utils->isArrRef($self->image->metadata->{res}); + + $self->updateres; +} + 1; __END__ @@ -47,6 +66,7 @@ where 'command' is one of the following: set install [-i ] [-f] uninstall [-f] + updateres -i show [zone_name [property[,property]...]] list [-H] [-F ] [-b ] [-s ] [zone_name] memstat @@ -73,7 +93,7 @@ where 'command' is one of the following: =head1 COPYRIGHT -Copyright 2023 OmniOS Community Edition (OmniOSce) Association. +Copyright 2024 OmniOS Community Edition (OmniOSce) Association. =head1 LICENSE