* corrected issue in reinstall that prevented reinstall of package files * added version command * updated files() in Package.pm to accept both quiet and verbose options * added sha() to Snap.pm which will be used for verify function in future * corrected missing '=' in output for search() in Sources.pm * removed duplicate file (SRC/snapinstall)
264 lines
6.0 KiB
Perl
264 lines
6.0 KiB
Perl
package Snap::Commands;
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use parent 'Snap';
|
|
|
|
my $commands = {
|
|
files => {
|
|
options => [
|
|
'<PKGNAME|FILE>',
|
|
'[-t TARGET]',
|
|
'[-v]'
|
|
],
|
|
brief => 'List files in package',
|
|
help => [
|
|
"\t\tPKGNAME or FILE is required. If PKGNAME\n"
|
|
. "\t\t\t\tis used it must be an installed package\n",
|
|
"\t\t\tAn optional target may be specified"
|
|
. " to\n\t\t\t\tquery a separate"
|
|
. " directory/file system\n",
|
|
"\t\t\t\tShow full manifest details"
|
|
]
|
|
},
|
|
genpkg => {
|
|
options => [
|
|
'<PKGNAME>'
|
|
],
|
|
brief => 'Create package build directory',
|
|
help => [
|
|
"\t\t\tPKGNAME is required. This will"
|
|
. " create a\n\t\t\t\tdirectory of the same"
|
|
. " name and populate\n\t\t\t\tit with a"
|
|
. " skeleton of files and"
|
|
. " directories\n\t\t\t\trequired to build"
|
|
. " a snap package"
|
|
]
|
|
},
|
|
help => {
|
|
options => [],
|
|
brief => 'Print brief usage information',
|
|
help => []
|
|
},
|
|
info => {
|
|
options => [
|
|
'<PKGNAME[=VER]|FILE>',
|
|
'[-t TARGET]'
|
|
],
|
|
brief => 'List package info',
|
|
help => [
|
|
"\t\tPKGNAME or FILE is required."
|
|
. " A version string\n\t\t\t\tcan optionally"
|
|
. " be provided with the PKGNAME\n"
|
|
. "\t\t\t\tas packagename=x.x.x\n",
|
|
"\t\t\tAn optional target may be specified"
|
|
. " to\n\t\t\t\tquery a separate directory"
|
|
. "/file system"
|
|
]
|
|
},
|
|
install => {
|
|
options => [
|
|
'<PKGNAME[=VER]|FILE>',
|
|
'[-t TARGET]',
|
|
'[--no-deps]',
|
|
'[-y]'
|
|
],
|
|
brief => 'Install package',
|
|
help => [
|
|
"\t\tPKGNAME or FILE is required"
|
|
. " A version string\n\t\t\t\tcan optionally"
|
|
. " be provided with the PKGNAME\n"
|
|
. "\t\t\t\tas packagename=x.x.x\n",
|
|
"\t\t\tAn optional target may be specified"
|
|
. " to\n\t\t\t\tinstall the package to a"
|
|
. " separate\n\t\t\t\tdirectory/file system\n",
|
|
"\t\t\tInstall the package without dependencies\n",
|
|
"\t\t\t\tProceed without prompting"
|
|
]
|
|
},
|
|
list => {
|
|
options => [
|
|
'[-a]',
|
|
'[-r REPO]',
|
|
'[-t TARGET]'
|
|
],
|
|
brief => 'List packages',
|
|
help => [
|
|
"\t\t\t\tList all repo and installed packages\n",
|
|
"\t\t\tOptionally specify a repository to list\n",
|
|
"\t\t\tAn optional target may be specified"
|
|
. " to\n\t\t\t\tquery a separate directory"
|
|
. "/file system"
|
|
]
|
|
},
|
|
purge => {
|
|
options => [
|
|
'<PKGNAME>',
|
|
'[-t TARGET]',
|
|
'[-y]'
|
|
],
|
|
brief => 'Remove package and/or configs',
|
|
help => [
|
|
"\t\t\tPKGNAME is required\n",
|
|
"\t\t\tAn optional target may be specified"
|
|
. " to\n\t\t\t\tinstall the package to a"
|
|
. " separate\n\t\t\t\tdirectory/file system\n",
|
|
"\t\t\t\tProceed without prompting"
|
|
]
|
|
},
|
|
rebuild => {
|
|
options => [
|
|
'[-t TARGET]',
|
|
'[-y]'
|
|
],
|
|
brief => 'Rebuild package DB',
|
|
help => [
|
|
"\t\t\tAn optional target may be specified"
|
|
. " to\n\t\t\t\trepair the DB of a"
|
|
. " separate\n\t\t\t\tdirectory/file system\n",
|
|
"\t\t\t\tProceed without prompting"
|
|
]
|
|
},
|
|
reinstall => {
|
|
options => [
|
|
'<PKGNAME>',
|
|
'[-t TARGET]',
|
|
'[-y]'
|
|
],
|
|
brief => 'Re-install package',
|
|
help => [
|
|
"\t\t\tPKGNAME is required\n",
|
|
"\t\t\tAn optional target may be specified"
|
|
. " to\n\t\t\t\tre-install the package on a"
|
|
. " separate\n\t\t\t\tdirectory/file system\n",
|
|
"\t\t\t\tProceed without prompting"
|
|
]
|
|
},
|
|
remove => {
|
|
options => [
|
|
'<PKGNAME>',
|
|
'[-t TARGET]',
|
|
'[-y]'
|
|
],
|
|
brief => 'Remove a package',
|
|
help => [
|
|
"\t\t\tPKGNAME is required\n",
|
|
"\t\t\tAn optional target may be specified"
|
|
. " to\n\t\t\t\tremove the package from a"
|
|
. " separate\n\t\t\t\tdirectory/file system\n",
|
|
"\t\t\t\tProceed without prompting"
|
|
]
|
|
},
|
|
search => {
|
|
options => [
|
|
'[STRING[=VER]]',
|
|
'[-a]',
|
|
'[-v]'
|
|
],
|
|
brief => 'Search repositories for packages',
|
|
help => [
|
|
"\t\tSTRING is optional. If STRING is not\n"
|
|
. "\t\t\t\tprovided all repo packages are listed.\n"
|
|
. "\t\t\t\tAn optional version string may be used\n",
|
|
"\t\t\t\tReturn all versions from all repos\n",
|
|
"\t\t\t\tPrint verbose output"
|
|
]
|
|
},
|
|
source => {
|
|
options => [
|
|
'<PKGNAME[=VER]>'
|
|
],
|
|
brief => 'Retrieve package source',
|
|
help => [
|
|
"\t\tPKGNAME is required."
|
|
. " A version string\n\t\t\t\tcan optionally"
|
|
. " be provided with the PKGNAME\n"
|
|
. "\t\t\t\tas packagename=x.x.x"
|
|
]
|
|
},
|
|
upgrade => {
|
|
options => [
|
|
'[PKGNAME]',
|
|
'[-t TARGET]',
|
|
'[-y]'
|
|
],
|
|
brief => 'Upgrade packages',
|
|
help => [
|
|
"\t\t\tWith no arguments all packages are upgraded\n"
|
|
. "\t\t\t\totherwise only the specified package\n",
|
|
"\t\t\tAn optional target may be specified"
|
|
. " to\n\t\t\t\tupgrade the package on a"
|
|
. " separate\n\t\t\t\tdirectory/file system\n",
|
|
"\t\t\t\tProceed without prompting"
|
|
]
|
|
},
|
|
verify => {
|
|
options => [
|
|
'[PKGNAME]',
|
|
'[-t TARGET]',
|
|
'[-y]'
|
|
],
|
|
brief => 'Verify integrity of packages',
|
|
help => [
|
|
"\t\t\tWith no arguments all packages are verified\n"
|
|
. "\t\t\t\totherwise only the specified package\n",
|
|
"\t\t\tAn optional target may be specified"
|
|
. " to\n\t\t\t\tverify the package on a"
|
|
. " separate\n\t\t\t\tdirectory/file system\n",
|
|
"\t\t\t\tProceed without prompting"
|
|
]
|
|
},
|
|
version => {
|
|
options => [],
|
|
brief => 'Display version information',
|
|
help => []
|
|
}
|
|
};
|
|
|
|
sub commandhelp {
|
|
my $self = shift;
|
|
my $command = shift;
|
|
|
|
if ( ! $self->{$command} ) {
|
|
Snap->error( 64, "help(): Invalid command '$command'" );
|
|
}
|
|
|
|
my $options = $commands->{$command}{'options'};
|
|
my $help = $commands->{$command}{'help'};
|
|
|
|
print "\nsnap $command @{$commands->{$command}{'options'}}\n\n";
|
|
print "$commands->{$command}{'brief'}\n\n";
|
|
|
|
for ( my $i = 0; $i <= $#{$options}; $i++ ) {
|
|
print " $options->[$i]$help->[$i]\n";
|
|
}
|
|
|
|
print "\n";
|
|
}
|
|
|
|
sub new {
|
|
my $class = shift;
|
|
|
|
return( bless( $commands, $class ) );
|
|
}
|
|
|
|
sub help {
|
|
if ( @ARGV ) {
|
|
Snap->error( -1, "usage(): Invalid option '$ARGV[0]'" );
|
|
}
|
|
|
|
print "\nUsage: $0 <COMMAND> <ARGS>\n\n"
|
|
. "snap is the Snaplinux package management utility\n\n"
|
|
. "COMMANDS\n\n";
|
|
|
|
foreach my $command ( sort( keys( %$commands ) ) ) {
|
|
print " $command \t\t\t$commands->{$command}{'brief'}\n"
|
|
}
|
|
|
|
print "\nTo view more information for commands run:\n"
|
|
. "snap <COMMAND> -h\n\n";
|
|
}
|
|
|
|
1;
|