2 Commits

Author SHA1 Message Date
Jay Larson
319401eb51 Corrected issue in assignment to $(SNAP) in Makefile.snaplinux 2017-05-22 14:46:14 -05:00
Jay Larson
4cd5b95d7e The following changes were made:
* Added snapinstall (missed on last check in)
  * Added reinstall functionality to snap
2017-05-22 14:15:38 -05:00
5 changed files with 191 additions and 9 deletions

View File

@@ -16,9 +16,7 @@ DESC = The Snaplinux package management system
ARCHIVE := '' ARCHIVE := ''
SRCDIR := $(PWD)/SRC/snap SRCDIR := $(PWD)/SRC/snap
PATCHDIR := $(PWD)/SRC/patches PATCHDIR := $(PWD)/SRC/patches
VERSION := 0.5-0 VERSION := 0.6-0
MAKEINST = make install
include /usr/share/snap/Makefile.snaplinux include /usr/share/snap/Makefile.snaplinux
@@ -29,7 +27,7 @@ $(ROOT): $(SRCDIR)/Makefile
mkdir -v $(ROOT); \ mkdir -v $(ROOT); \
fi fi
@cd $(SRCDIR) && $(MAKEINST) DESTDIR=$(ROOT) @cd $(SRCDIR) && make install DESTDIR=$(ROOT)
clean: clean:
@rm -rvf $(ROOT) \ @rm -rvf $(ROOT) \

View File

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

View File

@@ -17,8 +17,8 @@ ROOT = $(PWD)/ROOT
# of the package file. Added for the kernel package # of the package file. Added for the kernel package
# though could be useful for others # though could be useful for others
ifeq ( $(SNAP), ) ifndef SNAP
SNAP = $(PACKAGE)-$(VERSION).snap SNAP := $(PACKAGE)-$(VERSION).snap
endif endif
SNAPINFO = $(SNAPDIR)/snapinfo SNAPINFO = $(SNAPDIR)/snapinfo
@@ -31,7 +31,7 @@ FILES = $(SNAPDIR)/files.tar.gz
# if we find that not to be supplied we're going to # if we find that not to be supplied we're going to
# assume that the SRCPKG is the same as the PACKAGE # assume that the SRCPKG is the same as the PACKAGE
ifeq ( $(SRCPKG), ) ifndef SRCPKG)
SRCPKG := $(PACKAGE) SRCPKG := $(PACKAGE)
endif endif
@@ -116,12 +116,15 @@ $(FILES): $(ROOT)
type=`file -i $$file|sed 's/.*: //'`; \ type=`file -i $$file|sed 's/.*: //'`; \
case $$type in \ case $$type in \
*'/x-executable; charset=binary') \ *'/x-executable; charset=binary') \
echo "--strip-unneeded $$file"; \
strip --strip-unneeded $$file \ strip --strip-unneeded $$file \
;; \ ;; \
*'/x-object; charset=binary') \ *'/x-object; charset=binary') \
echo "--strip-debug $$file"; \
strip --strip-debug $$file \ strip --strip-debug $$file \
;; \ ;; \
*'/x-sharedlib; charset=binary') \ *'/x-sharedlib; charset=binary') \
echo "--strip-debug $$file"; \
strip --strip-debug $$file \ strip --strip-debug $$file \
;; \ ;; \
esac; \ esac; \

View File

@@ -303,13 +303,13 @@ elsif ( $command eq 'install' ) {
chkyes(); chkyes();
print "\n";
foreach my $package ( @$packages ) { foreach my $package ( @$packages ) {
if ( ! $virtfs ) { if ( ! $virtfs ) {
$virtfs = virtfs( 'mount' ); $virtfs = virtfs( 'mount' );
} }
print "\n";
$package->install( $sources ); $package->install( $sources );
} }
@@ -346,6 +346,97 @@ elsif ( $command eq 'refresh' ) {
print "\n"; 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' ) { elsif ( $command eq 'remove' ) {
my $opts = { my $opts = {
nodeps => eval { 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";