Added package removal steps.

This commit is contained in:
László Valkó 2018-05-12 05:54:31 +02:00
parent 367a21eaab
commit 17cbf95a36

View file

@ -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) = @_;