- 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:
5
Makefile
5
Makefile
@@ -12,12 +12,11 @@ DEPENDS = bash,binutils,coreutils,gzip,iana-etc,iproute2,inetutils,initscripts,p
|
|||||||
ARCH = x86_64
|
ARCH = x86_64
|
||||||
URL =
|
URL =
|
||||||
DESC = This is the base of the snaplinux system
|
DESC = This is the base of the snaplinux system
|
||||||
SNAPVER = sr0
|
|
||||||
|
|
||||||
ARCHIVE := ''
|
ARCHIVE := ''
|
||||||
SRCDIR := $(PWD)/SRC/snap-*
|
SRCDIR := $(PWD)/SRC/snap
|
||||||
PATCHDIR := $(PWD)/SRC/patches
|
PATCHDIR := $(PWD)/SRC/patches
|
||||||
VERSION := $(shell echo $(SRCDIR)|egrep -o '\-[0-9].*'|sed 's/^-//')$(SNAPVER)
|
VERSION := 0.2sr1
|
||||||
|
|
||||||
MAKEINST = make install
|
MAKEINST = make install
|
||||||
|
|
||||||
|
|||||||
28
SNAP/usher
28
SNAP/usher
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
set -e
|
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
|
bin:x:1:1:bin:/dev/null:/bin/false
|
||||||
daemon:x:6:6:Daemon User:/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
|
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
|
if [ ! -f ${TARGET}/etc/passwd ]; then
|
||||||
echo "Creating /etc/passwd"
|
echo "Creating /etc/passwd"
|
||||||
echo ${PASSWD} > ${TARGET}/etc/passwd
|
echo "${PASSWD}" > ${TARGET}/etc/passwd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f ${TARGET}/etc/group ]; then
|
if [ ! -f ${TARGET}/etc/group ]; then
|
||||||
echo "Creating /etc/group"
|
echo "Creating /etc/group"
|
||||||
echo ${GROUP} > ${TARGET}/etc/group
|
echo "${GROUP}" > ${TARGET}/etc/group
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
postinst)
|
postinst)
|
||||||
|
setpass=`cat ${TARGET}/etc/shadow|grep ^root|awk -F':' '{print $2}'`
|
||||||
|
|
||||||
|
if [ "$setpass" == 'SETPASS' ]; then
|
||||||
|
echo "Setting root password"
|
||||||
|
|
||||||
if [[ ${TARGET} ]]; then
|
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"
|
echo "Refreshing snap"
|
||||||
|
|
||||||
|
if [[ ${TARGET} ]]; then
|
||||||
chroot ${TARGET} snap refresh
|
chroot ${TARGET} snap refresh
|
||||||
|
else
|
||||||
|
snap refresh
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ PACKAGE := $(shell echo $(PWD)|sed 's/.*\///')
|
|||||||
SNAPDIR = $(PWD)/SNAP
|
SNAPDIR = $(PWD)/SNAP
|
||||||
ROOT = $(PWD)/ROOT
|
ROOT = $(PWD)/ROOT
|
||||||
|
|
||||||
BYTES = 0
|
|
||||||
SNAP = $(PACKAGE)-$(VERSION).snap
|
SNAP = $(PACKAGE)-$(VERSION).snap
|
||||||
SNAPINFO = $(SNAPDIR)/snapinfo
|
SNAPINFO = $(SNAPDIR)/snapinfo
|
||||||
MANIFEST = $(SNAPDIR)/manifest
|
MANIFEST = $(SNAPDIR)/manifest
|
||||||
@@ -22,14 +21,6 @@ FILES = $(SNAPDIR)/files.tar.gz
|
|||||||
|
|
||||||
# The following values must be set in the Makefile for the package
|
# 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
|
ifndef VERSION
|
||||||
$(error VERSION is not set)
|
$(error VERSION is not set)
|
||||||
endif
|
endif
|
||||||
@@ -50,17 +41,16 @@ $(SNAP): $(SNAPINFO) $(FILES)
|
|||||||
|
|
||||||
$(SNAPINFO): $(MANIFEST)
|
$(SNAPINFO): $(MANIFEST)
|
||||||
@>$(SNAPINFO)
|
@>$(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" \
|
printf "depends: $(DEPENDS)\narch: $(ARCH)\nbytes: $(BYTES)\n" \
|
||||||
>> $(SNAPINFO); \
|
>> $(SNAPINFO) && \
|
||||||
printf "url: $(URL)\ndescription: $(DESC)\n" >> $(SNAPINFO)
|
printf "url: $(URL)\ndescription: $(DESC)\n" >> $(SNAPINFO)
|
||||||
|
|
||||||
$(MANIFEST): $(FILES)
|
$(MANIFEST): $(FILES)
|
||||||
@>$(MANIFEST)
|
@>$(MANIFEST)
|
||||||
|
|
||||||
@bytes=0; \
|
|
||||||
rootfiles=`cd $(ROOT) && find ! -path .|sed 's/^\.\///'|sort -r`; \
|
rootfiles=`cd $(ROOT) && find ! -path .|sed 's/^\.\///'|sort -r`; \
|
||||||
while read -r file; do \
|
while read -r file; do \
|
||||||
info=`ls -ld "$(ROOT)/$$file"`; \
|
info=`ls -ld "$(ROOT)/$$file"`; \
|
||||||
@@ -82,14 +72,19 @@ $(FILES): $(ROOT)
|
|||||||
|
|
||||||
@find $(ROOT) -name perllocal.pod -exec rm {} \;
|
@find $(ROOT) -name perllocal.pod -exec rm {} \;
|
||||||
|
|
||||||
@files=`find $(ROOT) -type f -exec file -i '{}' \;| grep \
|
@find $(ROOT) -type f | while read -r file; do \
|
||||||
'application/x-\(executable\|object\|sharedlib\);' | \
|
type=`file -i $$file|sed 's/.*: //'`; \
|
||||||
grep ' charset=binary'`; \
|
case $$type in \
|
||||||
while read -r line; do \
|
*'/x-executable; charset=binary') \
|
||||||
file=`echo $$line|sed 's/: application\/x-.*//'`; \
|
strip --strip-unneeded $$file \
|
||||||
if [ "$$file" != '' ]; then \
|
;; \
|
||||||
strip --strip-unneeded $$file; \
|
*'/x-object; charset=binary') \
|
||||||
fi; \
|
strip --strip-debug $$file \
|
||||||
done <<< "$$files"
|
;; \
|
||||||
|
*'/x-sharedlib; charset=binary') \
|
||||||
|
strip --strip-debug $$file \
|
||||||
|
;; \
|
||||||
|
esac; \
|
||||||
|
done
|
||||||
@cd $(ROOT) && tar cvzf $(FILES) *
|
@cd $(ROOT) && tar cvzf $(FILES) *
|
||||||
|
|
||||||
@@ -158,10 +158,9 @@ sub depends {
|
|||||||
if ( $packages->{$package} && $packages->{$package}{'depends'} ) {
|
if ( $packages->{$package} && $packages->{$package}{'depends'} ) {
|
||||||
foreach my $depend ( split( ',',
|
foreach my $depend ( split( ',',
|
||||||
$packages->{$package}{'depends'} ) ) {
|
$packages->{$package}{'depends'} ) ) {
|
||||||
depends( $packages, $depend, $depends );
|
|
||||||
|
|
||||||
if ( ! grep( /^$depend$/, @$depends ) ) {
|
if ( ! grep( /^$depend$/, @$depends ) ) {
|
||||||
push( @$depends, $depend );
|
push( @$depends, $depend );
|
||||||
|
depends( $packages, $depend, $depends );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -640,7 +639,7 @@ sub install {
|
|||||||
|
|
||||||
print STDOUT "\e[K$filenum files extracted\e[?25h\n\n";
|
print STDOUT "\e[K$filenum files extracted\e[?25h\n\n";
|
||||||
|
|
||||||
usher( $pkgfile, $target, 'postinst' );
|
%result = usher( $pkgfile, $target, 'postinst' );
|
||||||
|
|
||||||
return( \%result );
|
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 $depdir = "$target/$conf->{'general'}{'snapdir'}/$depend";
|
||||||
my $dlpath = $packages->{$depend}{'path'};
|
my $dlpath = $packages->{$depend}{'path'};
|
||||||
( my $file = $dlpath ) =~ s/.*\///;
|
( my $file = $dlpath ) =~ s/.*\///;
|
||||||
Reference in New Issue
Block a user