summaryrefslogtreecommitdiff
path: root/tools/app-bundle-cook-bits
blob: e9003dff4711cadfb7f54fe0e682d07389afa7ed (plain)
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
#!/bin/bash

#
#  Copyright (C) 2017 Rajendra Dendukuri <[email protected]>
#
#  SPDX-License-Identifier:     GPL-2.0
#

# Make an ONIE installer using CentOS 7 chroot environment
#
# inputs: cento7 chroot package
# output: ONIE compatible OS installer image
#
# Comments: This script expects that yumbootsstrap is installed on
#           on the Linux host where it is executed.

#!/bin/sh

set -e

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
INPUT_DIR=$1
WORK_DIR=$2
TARGET_BINARY=$3

echo -n "Creating $TARGET_BINARY: ."

# Repackage $INSTALLDIR into a self-extracting installer image
sharch="$WORK_DIR/sharch.tar"
tar --exclude=*~ --exclude-backups --owner=root --group=root -C $INPUT_DIR -jcf $sharch installer || {
    echo "Error: Problems creating $sharch archive"
    exit 1
}

[ -f "$sharch" ] || {
    echo "Error: $sharch not found"
    exit 1
}

echo -n "."

sha1=$(cat $sharch | sha1sum | awk '{print $1}')
echo -n "."

cp $SCRIPT_DIR/app_bundle_body.sh $TARGET_BINARY || {
    echo "Error: Problems copying app_bundle_body.sh"
    exit 1
}

# Replace variables in the sharch template
sed -i -e "s/%%IMAGE_SHA1%%/$sha1/" $TARGET_BINARY
echo -n "."
cat $sharch >> $TARGET_BINARY
echo " Done."