- Moved away from versioned directory for better tracking

- Modified usher to set root password if not already set
 - Modified snap to deal with circular dependencies properly
 - Now snap properly checks exit value for usher postinst
This commit is contained in:
2016-11-04 08:32:24 -05:00
parent 388430ed37
commit 997a8d69b5
10 changed files with 48 additions and 34 deletions

View File

@@ -12,12 +12,11 @@ DEPENDS = bash,binutils,coreutils,gzip,iana-etc,iproute2,inetutils,initscripts,p
ARCH = x86_64
URL =
DESC = This is the base of the snaplinux system
SNAPVER = sr0
ARCHIVE := ''
SRCDIR := $(PWD)/SRC/snap-*
SRCDIR := $(PWD)/SRC/snap
PATCHDIR := $(PWD)/SRC/patches
VERSION := $(shell echo $(SRCDIR)|egrep -o '\-[0-9].*'|sed 's/^-//')$(SNAPVER)
VERSION := 0.2sr1
MAKEINST = make install

View File

@@ -2,7 +2,7 @@
set -e
PASSWD="root:x:0:0:root:/root:/bin/bash
PASSWD="root:SETPASS:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/dev/null:/bin/false
daemon:x:6:6:Daemon User:/dev/null:/bin/false
messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
@@ -84,18 +84,38 @@ case $1 in
if [ ! -f ${TARGET}/etc/passwd ]; then
echo "Creating /etc/passwd"
echo ${PASSWD} > ${TARGET}/etc/passwd
echo "${PASSWD}" > ${TARGET}/etc/passwd
fi
if [ ! -f ${TARGET}/etc/group ]; then
echo "Creating /etc/group"
echo ${GROUP} > ${TARGET}/etc/group
echo "${GROUP}" > ${TARGET}/etc/group
fi
;;
postinst)
setpass=`cat ${TARGET}/etc/shadow|grep ^root|awk -F':' '{print $2}'`
if [ "$setpass" == 'SETPASS' ]; then
echo "Setting root password"
if [[ ${TARGET} ]]; then
if ! mountpoint ${TARGET}/dev; then
mount -o ro -t devtmpfs devtmpfs ${TARGET}/dev
chroot ${TARGET} passwd root
umount ${TARGET}/dev
else
chroot ${TARGET} passwd root
fi
else
passwd root
fi
fi
echo "Refreshing snap"
if [[ ${TARGET} ]]; then
chroot ${TARGET} snap refresh
else
snap refresh
fi
exit 0
;;

View File

@@ -13,7 +13,6 @@ PACKAGE := $(shell echo $(PWD)|sed 's/.*\///')
SNAPDIR = $(PWD)/SNAP
ROOT = $(PWD)/ROOT
BYTES = 0
SNAP = $(PACKAGE)-$(VERSION).snap
SNAPINFO = $(SNAPDIR)/snapinfo
MANIFEST = $(SNAPDIR)/manifest
@@ -22,14 +21,6 @@ FILES = $(SNAPDIR)/files.tar.gz
# The following values must be set in the Makefile for the package
ifndef ARCHIVE
$(error ARCHIVE is not set)
endif
ifndef SRCDIR
$(error SRCDIR is not set)
endif
ifndef VERSION
$(error VERSION is not set)
endif
@@ -50,17 +41,16 @@ $(SNAP): $(SNAPINFO) $(FILES)
$(SNAPINFO): $(MANIFEST)
@>$(SNAPINFO)
$(eval BYTES := $(shell du -sB1 $(ROOT)|awk '{print $$1}'))
$(eval BYTES := $(shell gzip -l $(FILES)|tail -1|awk '{print $$2}'))
@printf "package: $(PACKAGE)\nversion: $(VERSION)\n" > $(SNAPINFO); \
@printf "package: $(PACKAGE)\nversion: $(VERSION)\n" > $(SNAPINFO) && \
printf "depends: $(DEPENDS)\narch: $(ARCH)\nbytes: $(BYTES)\n" \
>> $(SNAPINFO); \
>> $(SNAPINFO) && \
printf "url: $(URL)\ndescription: $(DESC)\n" >> $(SNAPINFO)
$(MANIFEST): $(FILES)
@>$(MANIFEST)
@bytes=0; \
rootfiles=`cd $(ROOT) && find ! -path .|sed 's/^\.\///'|sort -r`; \
while read -r file; do \
info=`ls -ld "$(ROOT)/$$file"`; \
@@ -82,14 +72,19 @@ $(FILES): $(ROOT)
@find $(ROOT) -name perllocal.pod -exec rm {} \;
@files=`find $(ROOT) -type f -exec file -i '{}' \;| grep \
'application/x-\(executable\|object\|sharedlib\);' | \
grep ' charset=binary'`; \
while read -r line; do \
file=`echo $$line|sed 's/: application\/x-.*//'`; \
if [ "$$file" != '' ]; then \
strip --strip-unneeded $$file; \
fi; \
done <<< "$$files"
@find $(ROOT) -type f | while read -r file; do \
type=`file -i $$file|sed 's/.*: //'`; \
case $$type in \
*'/x-executable; charset=binary') \
strip --strip-unneeded $$file \
;; \
*'/x-object; charset=binary') \
strip --strip-debug $$file \
;; \
*'/x-sharedlib; charset=binary') \
strip --strip-debug $$file \
;; \
esac; \
done
@cd $(ROOT) && tar cvzf $(FILES) *

View File

@@ -158,10 +158,9 @@ sub depends {
if ( $packages->{$package} && $packages->{$package}{'depends'} ) {
foreach my $depend ( split( ',',
$packages->{$package}{'depends'} ) ) {
depends( $packages, $depend, $depends );
if ( ! grep( /^$depend$/, @$depends ) ) {
push( @$depends, $depend );
depends( $packages, $depend, $depends );
}
}
}
@@ -640,7 +639,7 @@ sub install {
print STDOUT "\e[K$filenum files extracted\e[?25h\n\n";
usher( $pkgfile, $target, 'postinst' );
%result = usher( $pkgfile, $target, 'postinst' );
return( \%result );
}
@@ -1807,7 +1806,8 @@ elsif ( $ARGV[0] eq 'install' || $ARGV[0] eq 'reinstall' ){
}
}
foreach my $depend ( @depends ) {
for ( my $i = $#depends; $i >= 0; $i-- ) {
my $depend = $depends[$i];
my $depdir = "$target/$conf->{'general'}{'snapdir'}/$depend";
my $dlpath = $packages->{$depend}{'path'};
( my $file = $dlpath ) =~ s/.*\///;