-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddabui.ld
executable file
·143 lines (114 loc) · 4.06 KB
/
addabui.ld
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
PKG_NAME=""
PKG_ROOT_IT=""
PKG_VERS="default"
if ! echo "${BASH_SOURCE}" | grep "/" --silent; then
BB_SCRIPT_DIR=$(readlink -f $PWD)
else
BB_SCRIPT_DIR=$(readlink -f ${BASH_SOURCE%/*})
fi
while [[ ${#} -gt 0 ]]; do
key="$1"
case $key in
-n)
if [[ ${#} -lt 2 ]]; then
echo "[ERROR]: ${1} expected a value."
exit 1
fi
PKG_NAME="$2"
echo "[OPT]: Attempting to build package named: \"${PKG_NAME}\""
shift # past argument
;;
-r)
if [[ ${#} -lt 2 ]]; then
echo "[ERROR]: ${1} expected a value."
exit 1
fi
PKG_ROOT_IT="$2"
echo "[OPT]: Building for root image: \"${PKG_ROOT_IT}\""
shift # past argument
;;
-v)
if [[ ${#} -lt 2 ]]; then
echo "[ERROR]: ${1} expected a value."
exit 1
fi
PKG_VERS="$2"
echo "[OPT]: Building version: \"${PKG_VERS}\""
shift # past argument
;;
-D|--root-dir)
if [[ ${#} -lt 2 ]]; then
echo "[ERROR]: ${1} expected a value."
exit 1
fi
BB_ROOT="$2"
echo "[OPT]: BB_ROOT=${BB_ROOT}"
shift # past argument
;;
-?|--help)
echo "[RUNLIKE] ${SCRIPTNAME} -n <pkg> -r <base os:tag> [opts]"
echo -e "\t-n <package name> : The name of the container "
echo -e "\t package to build."
echo -e "\t-r <package name> : The name of the root image "
echo -e "\t to use, this describes the "
echo -e "\t base OS: e.g centos:7"
echo -e "\t-v <version> : Specify a version of the "
echo -e "\t software to build."
echo -e "\t defaults to \"default\"."
echo -e "\t-D|--root-dir <bb manifest root dir> : The directory to use as the"
echo -e "\t root of the container build"
echo -e "\t script manifest. This option"
echo -e "\t overrides the BB_ROOT env"
echo -e "\t var. If BB_ROOT is not set"
echo -e "\t then the parent directory of "
echo -e "\t this script will be used."
echo -e "\t-?|--help : Print this message."
exit 0
;;
*)
# unknown option
echo "Unknown option $1"
exit 1
;;
esac
shift # past argument or value
done
if [ -z ${BB_ROOT} ]; then
BB_ROOT=${BB_SCRIPT_DIR}
fi
export BB_ROOT
source ${BB_SCRIPT_DIR}/framework.funcs
if [ -z ${PKG_ROOT_IT} ] && [ ! -z ${BB_ROOT_IT} ]; then
PKG_ROOT_IT=${BB_ROOT_IT}
fi
if [ -z $PKG_NAME ]; then
echo "Must specify a Name for the new container structure."
exit 1
fi
if [ -z $PKG_ROOT_IT ]; then
echo "Must specify a root image name for the new container structure."
exit 1
fi
if [ -z $PKG_VERS ]; then
PKG_VERS=default
fi
if bb_dir_structure_exists $PKG_NAME $PKG_ROOT_IT $PKG_VERS; then
echo "Directory for $PKG_NAME with version $PKG_VERS rooted on $PKG_ROOT_IT already exists."
exit 1
fi
PKG_ROOT_IMAGE=${PKG_ROOT_IT%%:*}
PKG_ROOT_TAG=${PKG_ROOT_IT##*:}
if [ "${PKG_ROOT_TAG}" = "${PKG_ROOT_IMAGE}" ]; then
PKG_ROOT_TAG=latest
fi
mkdir -p $BB_ROOT/$PKG_NAME/$PKG_VERS/$PKG_ROOT_IMAGE/$PKG_ROOT_TAG
echo "#!/bin/bash" > $BB_ROOT/$PKG_NAME/$PKG_VERS/$PKG_ROOT_IMAGE/$PKG_ROOT_TAG/build.ah
chmod +x $BB_ROOT/$PKG_NAME/$PKG_VERS/$PKG_ROOT_IMAGE/$PKG_ROOT_TAG/build.ah
echo "#!/bin/bash" > $BB_ROOT/$PKG_NAME/$PKG_VERS/$PKG_ROOT_IMAGE/$PKG_ROOT_TAG/injectin.to
chmod +x $BB_ROOT/$PKG_NAME/$PKG_VERS/$PKG_ROOT_IMAGE/$PKG_ROOT_TAG/injectin.to
echo "# PKG_NAME[@Version=default][:Tag=<ROOT_IMAGE_TAG>] ROOT_IMAGE_NAME[:Tag=latest]" > $BB_ROOT/$PKG_NAME/$PKG_VERS/$PKG_ROOT_IMAGE/$PKG_ROOT_TAG/depends.on
if [ ! "${PKG_VERS}" = "default" ] && [ ! -e $BB_ROOT/$PKG_NAME/default ]; then
cd $BB_ROOT/$PKG_NAME/
ln -s $PKG_VERS default
fi