The following changes were made:

* Added snapinstall (missed on last check in)
  * Added reinstall functionality to snap
This commit is contained in:
2017-05-22 14:15:38 -05:00
parent 6a9cce6b3f
commit 4cd5b95d7e
4 changed files with 184 additions and 3 deletions

View File

@@ -16,7 +16,7 @@ DESC = The Snaplinux package management system
ARCHIVE := ''
SRCDIR := $(PWD)/SRC/snap
PATCHDIR := $(PWD)/SRC/patches
VERSION := 0.5-0
VERSION := 0.6-0
MAKEINST = make install

View File

@@ -5,6 +5,7 @@ dirs:
files:
install -v -m 755 snap $(DESTDIR)/usr/bin/snap
install -v -m 755 snapinstall $(DESTDIR)/usr/bin/snapinstall
install -v -m 644 Makefile.skel \
$(DESTDIR)/usr/share/snap/Makefile.skel
install -v -m 644 Makefile.snaplinux \

View File

@@ -303,13 +303,13 @@ elsif ( $command eq 'install' ) {
chkyes();
print "\n";
foreach my $package ( @$packages ) {
if ( ! $virtfs ) {
$virtfs = virtfs( 'mount' );
}
print "\n";
$package->install( $sources );
}
@@ -346,6 +346,97 @@ elsif ( $command eq 'refresh' ) {
print "\n";
}
}
elsif ( $command eq 'reinstall' ) {
my $opts = {
yes => eval {
for ( my $i = 0; $i <= $#ARGV; $i++ ) {
if ( $ARGV[$i] eq '-y' ) {
splice( @ARGV, $i, 1 );
return( 1 );
}
}
}
};
my $packages = [];
my $virtfs = 0;
$sources->readpkgs();
print "\n";
foreach my $pkgname ( @ARGV ) {
my $package = $sources->{'installed'}{$pkgname};
if ( ! $package ) {
print STDERR "Package '$pkgname' not installed\n";
next;
}
$package = $sources->search( {
name => $package->{'name'},
version => $package->{'version'},
quiet => 1
} );
if ( $package->{'path'} =~ /https*:\/\// ) {
( my $filename = $package->{'path'} ) =~ s/.*\///;
if ( ! -f Snap->PKGDIR . "/$filename" ) {
Snap->httpget( $package->{'path'},
Snap->PKGDIR . "/$filename", 0644 );
}
$package->{'path'} = Snap->PKGDIR . "/$filename";
}
push( @$packages, $package );
}
foreach my $package ( @$packages ) {
my $termsize = Snap->termsize();
my $cnt = 0;
foreach my $package ( sort { $a->{'name'} cmp $b->{'name'} }
( @$packages ) ) {
if ( ! $cnt ) {
print "The following packages will be"
. " reinstalled:\n ";
}
if ( $termsize->{'col'} - ( length(
$package->{'name'} ) + 3 ) <= 0 ) {
print "\n ";
$termsize = Snap->termsize();
}
print "$package->{'name'} ";
$termsize->{'col'} -= length( $package->{'name'} ) + 1;
$cnt++;
}
}
print "\n\nContinue? (y/n): ";
chkyes();
foreach my $package ( @$packages ) {
if ( ! $virtfs ) {
$virtfs = virtfs( 'mount' );
}
print "\n";
$package->install();
}
virtfs( 'umount' );
print "\n";
}
elsif ( $command eq 'remove' ) {
my $opts = {
nodeps => eval {

89
SRC/snap/snapinstall Executable file
View File

@@ -0,0 +1,89 @@
#!/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";