From 17cbf95a363b41d5bef723283adf8ba7c1ad075c Mon Sep 17 00:00:00 2001 From: Valko Laszlo Date: Sat, 12 May 2018 05:54:31 +0200 Subject: [PATCH] Added package removal steps. --- pkgtool.pm | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/pkgtool.pm b/pkgtool.pm index 9aacd59..7bc2862 100644 --- a/pkgtool.pm +++ b/pkgtool.pm @@ -195,6 +195,55 @@ my $pkgdef_syntax = { } } }, + 'remove' => { + Type => 'list', + Elements => { + Type => 'struct', + Check => \&check_cfg_remove_step, + Keywords => { + 'type' => { + Type => 'string', + Mandatory => 1 + }, + 'condition' => { + Type => 'string' + }, + 'ignore-failure' => { + Type => 'integer' + }, + 'background' => { + Type => 'integer' + }, + 'recurse' => { + Type => 'integer' + }, + 'chdir' => { + Type => 'string' + }, + 'variable' => { + Type => 'string' + }, + 'filename' => { + Type => 'string' + }, + 'expression' => { + Type => 'string' + }, + 'source-file' => { + Type => 'string' + }, + 'target-file' => { + Type => 'string' + }, + 'parameters' => { + Type => 'list', + Elements => { + Type => 'string' + } + } + } + } + }, 'remove-parameters' => { Type => 'list', Elements => { @@ -1053,6 +1102,72 @@ sub check_cfg_install_step ($$) return 1; } +sub check_cfg_remove_step ($$) +{ + my ($remove, $label) = @_; + + my $type = $$remove{type}; + + if ($type eq 'setvar') { + if (! defined $$remove{'variable'} || $$remove{'variable'} eq '') { + print_log('pkg', ERROR, 'Remove step missing "variable" at %s', $label); + return 0; + } + if (! defined $$remove{'expression'} && ! defined $$remove{'filename'}) { + print_log('pkg', ERROR, 'Remove step missing "expression" or "filename" at %s', $label); + return 0; + } + } + elsif ($type eq 'msi') { + if (! defined $$remove{'source-file'} || $$remove{'source-file'} eq '') { + print_log('pkg', ERROR, 'Remove step missing "source-file" at %s', $label); + return 0; + } + } + elsif ($type eq 'run') { + if (! defined $$remove{'source-file'} || $$remove{'source-file'} eq '') { + print_log('pkg', ERROR, 'Remove step missing "source-file" at %s', $label); + return 0; + } + } + elsif ($type eq 'file') { + if (! defined $$remove{'source-file'} || $$remove{'source-file'} eq '') { + print_log('pkg', ERROR, 'Remove step missing "source-file" at %s', $label); + return 0; + } + if (! defined $$remove{'target-file'} || $$remove{'target-file'} eq '') { + print_log('pkg', ERROR, 'Remove step missing "target-file" at %s', $label); + return 0; + } + } + elsif ($type eq 'delete-file') { + if (! defined $$remove{'target-file'} || $$remove{'target-file'} eq '') { + print_log('pkg', ERROR, 'Remove step missing "target-file" at %s', $label); + return 0; + } + } + elsif ($type eq 'delete-dir') { + if (! defined $$remove{'target-file'} || $$remove{'target-file'} eq '') { + print_log('pkg', ERROR, 'Remove step missing "target-file" at %s', $label); + return 0; + } + } + elsif ($type eq 'reg') { + if (! defined $$remove{'source-file'} || $$remove{'source-file'} eq '') { + print_log('pkg', ERROR, 'Remove step missing "source-file" at %s', $label); + return 0; + } + } + elsif ($type eq 'remove-pkg') { + } + else { + print_log('pkg', ERROR, 'Unknown remove step type at %s', $label.': '.$type); + return 0; + } + + return 1; +} + sub check_cfg_pkg_version_struct ($$) { my ($option, $label) = @_;