diff --git a/Makefile b/Makefile index a2502bb..d195095 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ DESC = The Snaplinux package management system ARCHIVE := '' SRCDIR := $(PWD)/SRC/snap PATCHDIR := $(PWD)/SRC/patches -VERSION := 0.6-0 +VERSION := 0.7-0 include /usr/share/snap/Makefile.snaplinux diff --git a/SRC/snap/Commands.pm b/SRC/snap/Commands.pm index c13692f..2193efc 100644 --- a/SRC/snap/Commands.pm +++ b/SRC/snap/Commands.pm @@ -208,6 +208,11 @@ my $commands = { . " separate\n\t\t\t\tdirectory/file system\n", "\t\t\t\tProceed without prompting" ] + }, + version => { + options => [], + brief => 'Display version information', + help => [] } }; diff --git a/SRC/snap/Package.pm b/SRC/snap/Package.pm index 0aac645..cfacbd1 100644 --- a/SRC/snap/Package.pm +++ b/SRC/snap/Package.pm @@ -317,7 +317,12 @@ sub files { next; } - if ( $opts->{'quiet'} ) { + if ( $opts->{'quiet'} && + $opts->{'verbose'} ) { + push( @{$self->{'files'}}, [ + $sha, $perms, $file ] ); + } + elsif ( $opts->{'quiet'} ) { push( @{$self->{'files'}}, $file ); } @@ -367,7 +372,13 @@ sub files { $self->{'files'} = []; } - push( @{$self->{'files'}}, $file ); + if ( $opts->{'verbose'} ) { + push( @{$self->{'files'}}, [ + $sha, $perms, $file ] ); + } + else { + push( @{$self->{'files'}}, $file ); + } } elsif ( $opts->{'verbose'} ) { print "$sha\t$perms\t$file\n"; diff --git a/SRC/snap/Snap.pm b/SRC/snap/Snap.pm index 38d97f3..95936de 100644 --- a/SRC/snap/Snap.pm +++ b/SRC/snap/Snap.pm @@ -27,6 +27,8 @@ our @EXPORT = qw( readconf refresh setup + sha + sha256 target termsize vercmp @@ -87,7 +89,7 @@ use constant VERFILE => eval { } }; use constant { - VERSION => '0.3', + VERSION => '0.7', SNAPDIR => TARGET . '/var/lib/snap', PKGDIR => TARGET . '/var/lib/snap/packages', INSTDIR => TARGET . '/var/lib/snap/installed', @@ -648,6 +650,15 @@ sub setup { } } +sub sha { + my $file = shift; + my $digest = eval { + Digest::SHA->new( 1 )->addfile( $file ); + } || Snap->error( -1, "sha(): $file: $!\n" ); + + return( $digest->hexdigest ); + } + ### sha256() ############################################### # # This sub returns a hex sha256 hash of a supplied file diff --git a/SRC/snap/Sources.pm b/SRC/snap/Sources.pm index 5436875..266a848 100644 --- a/SRC/snap/Sources.pm +++ b/SRC/snap/Sources.pm @@ -219,7 +219,7 @@ sub search { if ( ! @$packages ) { if ( $opts->{'name'} && $opts->{'version'} ) { Snap->error( 0, "Snap::Sources::search():" - . " $opts->{'name'}$opts->{'version'}:" + . " $opts->{'name'}=$opts->{'version'}:" . " No such package" ); } elsif ( $opts->{'name'} ) { diff --git a/SRC/snap/snap b/SRC/snap/snap index 64a7ab2..8a20677 100755 --- a/SRC/snap/snap +++ b/SRC/snap/snap @@ -366,7 +366,19 @@ elsif ( $command eq 'reinstall' ) { print "\n"; foreach my $pkgname ( @ARGV ) { - my $package = $sources->{'installed'}{$pkgname}; + my $package; + + if ( -f $pkgname ) { + $package = Snap::Package->new( $pkgname ); + } + else { + $package = $sources->{'installed'}{$pkgname}; + $package = $sources->search( { + name => $package->{'name'}, + version => $package->{'version'}, + quiet => 1 + } ); + } if ( ! $package ) { print STDERR "Package '$pkgname' not installed\n"; @@ -374,12 +386,6 @@ elsif ( $command eq 'reinstall' ) { next; } - $package = $sources->search( { - name => $package->{'name'}, - version => $package->{'version'}, - quiet => 1 - } ); - if ( $package->{'path'} =~ /https*:\/\// ) { ( my $filename = $package->{'path'} ) =~ s/.*\///; @@ -613,6 +619,9 @@ elsif ( $command eq 'verify' ) { print Dumper( $package ); } } +elsif ( $command eq 'version' ) { + print "\n" . Snap->VERSION . "\n\n"; + } elsif ( $command ) { print "\n"; diff --git a/SRC/snapinstall b/SRC/snapinstall deleted file mode 100755 index d1bda7f..0000000 --- a/SRC/snapinstall +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Snap; -use Data::Dumper; - -setup(); - -my $conf = readconf(); -my $sources = Snap::Sources->new( $conf->{'sources'} ); - -my $opts = { - repo => 'core', - quiet => 1 - }; -my $corepkgs; -my $packages; -my $virtfs = 0; -my $prepkgs = {}; -my $prelist = [ 'snap-base', 'bash', 'coreutils', 'glibc', - 'libacl', 'libattr', 'libcap', 'ncurses', 'readline', - 'tzdata', 'perl', 'initscripts' ]; - -print "\n"; - -if ( ! Snap->TARGET ) { - Snap->error( -1, 'A target must be specified with -t' ); - } - -$sources->readpkgs(); -$corepkgs = $sources->search( $opts ); - -for ( my $i = 0; $i <= $#$corepkgs; $i++ ) { - if ( ! $opts->{'nodeps'} ) { - print "Resolving dependencies for" - . " $corepkgs->[$i]{'name'}\n"; - - $corepkgs->[$i]->depends( $sources, $packages ); - } - else { - print "Ignoring dependencies for" - . " $corepkgs->[$i]{'name'}\n"; - } - - push( @$packages, $corepkgs->[$i] ); - } - -for ( my $i = 0; $i <= $#$packages; $i++ ) { - if ( $packages->[$i]{'path'} =~ /https*:\/\// ) { - ( my $filename = $packages->[$i]{'path'} ) =~ s/.*\///; - - if ( ! -f Snap->PKGDIR . "/$filename" ) { - Snap->httpget( $packages->[$i]{'path'}, - Snap->PKGDIR . "/$filename", 0644 ); - } - - $packages->[$i]{'path'} = Snap->PKGDIR . "/$filename"; - } - - - if ( grep( $_ eq $packages->[$i]{'name'}, @$prelist ) ) { - $prepkgs->{$packages->[$i]{'name'}} = $packages->[$i]; - - splice( @$packages, $i, 1 ); - $i--; - } - } - -foreach my $package ( @$prelist ) { - print "\n"; - - $prepkgs->{$package}->install(); - } - -foreach my $package ( @$packages ) { - if ( ! $virtfs ) { - $virtfs = virtfs( 'mount' ); - } - - print "\n"; - - $package->install(); - } - -virtfs( 'umount' ); - -print "\n";