Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdbf4ed7d5 | ||
|
|
bfa1d110c4 |
4
Makefile
4
Makefile
@@ -12,11 +12,13 @@ DEPENDS = binutils,coreutils,gzip,perl>=5.20.0,tar
|
|||||||
ARCH = x86_64
|
ARCH = x86_64
|
||||||
URL =
|
URL =
|
||||||
DESC = The Snaplinux package management system
|
DESC = The Snaplinux package management system
|
||||||
|
SNAPVER = 0
|
||||||
|
|
||||||
ARCHIVE := ''
|
ARCHIVE := ''
|
||||||
SRCDIR := $(PWD)/SRC/snap
|
SRCDIR := $(PWD)/SRC/snap
|
||||||
PATCHDIR := $(PWD)/SRC/patches
|
PATCHDIR := $(PWD)/SRC/patches
|
||||||
VERSION := 0.7-0
|
VERSION := $(shell grep 'VERSION =>' SRC/snap/Snap.pm| \
|
||||||
|
sed "s/.*=> '\|',//g")-$(SNAPVER)
|
||||||
|
|
||||||
include /usr/share/snap/Makefile.snaplinux
|
include /usr/share/snap/Makefile.snaplinux
|
||||||
|
|
||||||
|
|||||||
@@ -282,6 +282,87 @@ sub depends {
|
|||||||
$self->revdeps( $sources, $dependencies );
|
$self->revdeps( $sources, $dependencies );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub dump {
|
||||||
|
my $self = shift;
|
||||||
|
my $pid;
|
||||||
|
my $sel;
|
||||||
|
my $cnt;
|
||||||
|
my $stderr;
|
||||||
|
my $stat;
|
||||||
|
local $| = 1;
|
||||||
|
|
||||||
|
if ( $self->{'path'} =~ /^https*:\/\// ) {
|
||||||
|
( my $filename = $self->{'path'} ) =~ s/.*\///;
|
||||||
|
|
||||||
|
Snap->httpget( $self->{'path'}, Snap->PKGDIR
|
||||||
|
. "/$filename", 0644 );
|
||||||
|
|
||||||
|
$self->{'path'} = Snap->PKGDIR . "/$filename";
|
||||||
|
}
|
||||||
|
|
||||||
|
print "Dumping $self->{'name'}=$self->{'version'}\n";
|
||||||
|
|
||||||
|
print "\e[?25l\r";
|
||||||
|
|
||||||
|
eval {
|
||||||
|
my $target = Snap->TARGET ||
|
||||||
|
"$self->{'name'}-$self->{'version'}";
|
||||||
|
|
||||||
|
if ( ! -d $target ) {
|
||||||
|
mkdir( $target );
|
||||||
|
}
|
||||||
|
|
||||||
|
$pid = open3( \*CHLDIN, \*CHLDOUT, \*CHLDERR,
|
||||||
|
"/usr/bin/ar p $self->{'path'} files.tar.gz|"
|
||||||
|
. "tar --no-overwrite-dir --keep-directory-symlink"
|
||||||
|
. " -hzvxf - -C $target" );
|
||||||
|
} || Snap->error( int( $! ), "open3(): /usr/bin/ar: $!" );
|
||||||
|
|
||||||
|
close( CHLDIN );
|
||||||
|
|
||||||
|
$sel = IO::Select->new();
|
||||||
|
$sel->add( *CHLDOUT, *CHLDERR );
|
||||||
|
|
||||||
|
while ( my @fhs = $sel->can_read ) {
|
||||||
|
foreach my $fh ( @fhs ) {
|
||||||
|
if ( eof( $fh ) ) {
|
||||||
|
$sel->remove( $fh );
|
||||||
|
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( fileno( $fh ) == fileno( *CHLDOUT ) ) {
|
||||||
|
my $line = <$fh>;
|
||||||
|
( my $file = $line ) =~ s/.*\/|\n$//;
|
||||||
|
chomp( $line );
|
||||||
|
chomp( $file );
|
||||||
|
|
||||||
|
if ( $file ) {
|
||||||
|
$cnt++;
|
||||||
|
|
||||||
|
print "\e[K$file\r";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif ( fileno( $fh ) == fileno( *CHLDERR ) ) {
|
||||||
|
$stderr .= <$fh>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close( CHLDOUT );
|
||||||
|
close( CHLDERR );
|
||||||
|
|
||||||
|
waitpid( $pid, 0 );
|
||||||
|
$stat = $? >> 8;
|
||||||
|
|
||||||
|
if ( $stat ) {
|
||||||
|
Snap->error( $stat, "Failed dumping $self->{'name'}:"
|
||||||
|
. " $stderr\e[?25h" );
|
||||||
|
}
|
||||||
|
|
||||||
|
print "\e[K$cnt files extracted\e[?25h\n";
|
||||||
|
}
|
||||||
|
|
||||||
sub files {
|
sub files {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $opts = shift;
|
my $opts = shift;
|
||||||
@@ -293,8 +374,13 @@ sub files {
|
|||||||
my $stdout;
|
my $stdout;
|
||||||
my $stderr;
|
my $stderr;
|
||||||
my $stat;
|
my $stat;
|
||||||
my $pid = open3( \*CHLDIN, \*CHLDOUT, \*CHLDERR,
|
my $pid;
|
||||||
"/usr/bin/ar p $self->{'path'} manifest" );
|
|
||||||
|
eval {
|
||||||
|
$pid = open3( \*CHLDIN, \*CHLDOUT, \*CHLDERR,
|
||||||
|
"/usr/bin/ar p $self->{'path'} manifest" );
|
||||||
|
} || Snap->error( int( $! ), "open3(): /usr/bin/ar:"
|
||||||
|
. " $!" );
|
||||||
|
|
||||||
close( CHLDIN );
|
close( CHLDIN );
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use Snap::Commands;
|
|||||||
use Snap::Package;
|
use Snap::Package;
|
||||||
use Snap::Sources;
|
use Snap::Sources;
|
||||||
|
|
||||||
use Fcntl;
|
use Fcntl qw( :flock );
|
||||||
use IPC::Open3;
|
use IPC::Open3;
|
||||||
use IO::Socket::INET;
|
use IO::Socket::INET;
|
||||||
use Digest::SHA qw( sha256_hex );
|
use Digest::SHA qw( sha256_hex );
|
||||||
@@ -89,7 +89,7 @@ use constant VERFILE => eval {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
use constant {
|
use constant {
|
||||||
VERSION => '0.7',
|
VERSION => '0.9',
|
||||||
SNAPDIR => TARGET . '/var/lib/snap',
|
SNAPDIR => TARGET . '/var/lib/snap',
|
||||||
PKGDIR => TARGET . '/var/lib/snap/packages',
|
PKGDIR => TARGET . '/var/lib/snap/packages',
|
||||||
INSTDIR => TARGET . '/var/lib/snap/installed',
|
INSTDIR => TARGET . '/var/lib/snap/installed',
|
||||||
@@ -105,6 +105,7 @@ use constant SNAPVER => eval {
|
|||||||
|
|
||||||
return( $version );
|
return( $version );
|
||||||
};
|
};
|
||||||
|
use constant LOCKFILE => '/var/lock/snap';
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
#
|
#
|
||||||
@@ -114,6 +115,17 @@ use constant SNAPVER => eval {
|
|||||||
|
|
||||||
$0 =~ s/.*\///;
|
$0 =~ s/.*\///;
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
#
|
||||||
|
# Exit unless we can get exclusive lock
|
||||||
|
#
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
open( LOCK, '>', LOCKFILE ) || Snap->error( int( $! ), "open(): "
|
||||||
|
. LOCKFILE . ": Unable to open lock file" );
|
||||||
|
flock( LOCK, LOCK_EX|LOCK_NB ) || Snap->error( int( $! ), "flock(): "
|
||||||
|
. LOCKFILE . ": Unable to lock file" );
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
#
|
#
|
||||||
# Make sure we bring back the cursor if we're killed
|
# Make sure we bring back the cursor if we're killed
|
||||||
@@ -832,7 +844,7 @@ sub virtfs {
|
|||||||
my $stat = 0;
|
my $stat = 0;
|
||||||
my $pid;
|
my $pid;
|
||||||
|
|
||||||
if ( ! -f $virtfs->{$fs}{'dir'} ) {
|
if ( ! -d $virtfs->{$fs}{'dir'} ) {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,15 +6,6 @@ use warnings;
|
|||||||
use Snap;
|
use Snap;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
############################################################
|
|
||||||
#
|
|
||||||
# setup() will give the user the option to create the files
|
|
||||||
# and directories needed for snap to function
|
|
||||||
#
|
|
||||||
############################################################
|
|
||||||
|
|
||||||
setup();
|
|
||||||
|
|
||||||
my $command = shift( @ARGV );
|
my $command = shift( @ARGV );
|
||||||
my $conf = readconf();
|
my $conf = readconf();
|
||||||
my $commands = Snap::Commands->new();
|
my $commands = Snap::Commands->new();
|
||||||
@@ -23,9 +14,15 @@ my $sources = Snap::Sources->new( $conf->{'sources'} );
|
|||||||
if ( $ARGV[0] && $ARGV[0] eq '-h' ) {
|
if ( $ARGV[0] && $ARGV[0] eq '-h' ) {
|
||||||
$commands->commandhelp( $command );
|
$commands->commandhelp( $command );
|
||||||
}
|
}
|
||||||
elsif ( $command eq 'genpkg' ) {
|
elsif ( $command eq 'dump' ) {
|
||||||
|
print "\n";
|
||||||
|
|
||||||
foreach my $arg ( @ARGV ) {
|
foreach my $arg ( @ARGV ) {
|
||||||
genpkg( $arg );
|
my $package = Snap::Package->new( $arg );
|
||||||
|
|
||||||
|
$package->dump();
|
||||||
|
|
||||||
|
print "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif ( $command eq 'files' ) {
|
elsif ( $command eq 'files' ) {
|
||||||
@@ -61,11 +58,15 @@ elsif ( $command eq 'files' ) {
|
|||||||
|
|
||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
|
elsif ( $command eq 'genpkg' ) {
|
||||||
|
foreach my $arg ( @ARGV ) {
|
||||||
|
genpkg( $arg );
|
||||||
|
}
|
||||||
|
}
|
||||||
elsif ( $command eq 'help' ) {
|
elsif ( $command eq 'help' ) {
|
||||||
$commands->help();
|
$commands->help();
|
||||||
}
|
}
|
||||||
elsif ( $command eq 'info' ) {
|
elsif ( $command eq 'info' ) {
|
||||||
|
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
foreach my $arg ( @ARGV ) {
|
foreach my $arg ( @ARGV ) {
|
||||||
@@ -104,6 +105,8 @@ elsif ( $command eq 'install' ) {
|
|||||||
my $bytes = 0;
|
my $bytes = 0;
|
||||||
my $virtfs = 0;
|
my $virtfs = 0;
|
||||||
|
|
||||||
|
setup();
|
||||||
|
|
||||||
foreach my $attrib ( @attribs ) {
|
foreach my $attrib ( @attribs ) {
|
||||||
if ( $string =~ /$attrib\s*:\s*(\S+)/ ) {
|
if ( $string =~ /$attrib\s*:\s*(\S+)/ ) {
|
||||||
$opts->{$attrib} = $1;
|
$opts->{$attrib} = $1;
|
||||||
@@ -331,6 +334,8 @@ elsif ( $command eq 'list' ) {
|
|||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
elsif ( $command eq 'refresh' ) {
|
elsif ( $command eq 'refresh' ) {
|
||||||
|
setup();
|
||||||
|
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
$sources->refresh();
|
$sources->refresh();
|
||||||
@@ -361,6 +366,8 @@ elsif ( $command eq 'reinstall' ) {
|
|||||||
my $packages = [];
|
my $packages = [];
|
||||||
my $virtfs = 0;
|
my $virtfs = 0;
|
||||||
|
|
||||||
|
setup();
|
||||||
|
|
||||||
$sources->readpkgs();
|
$sources->readpkgs();
|
||||||
|
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|||||||
0
SRC/snap/snapinstall
Executable file → Normal file
0
SRC/snap/snapinstall
Executable file → Normal file
Reference in New Issue
Block a user