File: test-binaries-exist.sh

package info (click to toggle)
supermin 5.2.2-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,324 kB
  • sloc: ansic: 15,089; sh: 4,913; ml: 2,599; makefile: 251; perl: 26
file content (63 lines) | stat: -rwxr-xr-x 1,981 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash -
# supermin
# (C) Copyright 2009-2014 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

set -e

tmpdir=`mktemp -d`

d1=$tmpdir/d1
d2=$tmpdir/d2

test "$USE_NETWORK" = 1 || USE_INSTALLED=--use-installed

# We assume that 'bash' and 'coreutils' package names exist in every distro.
../src/supermin -v --prepare $USE_INSTALLED bash coreutils -o $d1

# Build a chroot.
../src/supermin -v --build -f chroot $d1 -o $d2

# Check that some well-known binaries were created.
if [ "$(find $d2 -name bash | wc -l)" -lt 1 ]; then
    echo "$0: 'bash' binary was not created in chroot"
    ls -lR $d2
    exit 1
fi
if [ "$(find $d2 -name sync | wc -l)" -lt 1 ]; then
    echo "$0: 'sync' binary was not created in chroot"
    ls -lR $d2
    exit 1
fi

# Check the mode of the binaries.
if [ "$(find $d2 -name bash -perm -0555 | wc -l)" -lt 1 ]; then
    echo "$0: 'bash' binary was not created with the right mode"
    ls -lR $d2
    exit 1
fi
if [ "$(find $d2 -name sync -perm -0555 | wc -l)" -lt 1 ]; then
    echo "$0: 'sync' binary was not created with the right mode"
    ls -lR $d2
    exit 1
fi

# These binaries should be runnable (since they are the same as the host).
`find $d2 -name sync ! -path '*/bash/*' | head`

# Need to chmod $d2 since rm -r can't remove unwritable directories.
chmod -R +w $d2 ||:
rm -rf $tmpdir