Skip to content

Commit d46a068

Browse files
committed
image - use distribution name for default chroot location
When making a chroot use the distribution name rather than the default $md_build/chroot Require the chroot location parameter for the chroot, init and deinit functions. Adjust the _get_info function so it can be used directly from the builder module.
1 parent a9602fc commit d46a068

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

scriptmodules/admin/image.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ function depends_image() {
2323
function _get_info_image() {
2424
local dist="$1"
2525
local key="$2"
26-
local ini="$md_data/dists/${dist}.ini"
26+
# don't use $md_data so this function can be used directly from builder.sh
27+
local ini="${__mod_info[image/path]%/*}/image/dists/${dist}.ini"
2728
[[ ! -f "$ini" ]] && fatalError "Definition file $ini does not exist"
2829

2930
iniConfig "=" "\"" "$ini"
@@ -37,7 +38,7 @@ function create_chroot_image() {
3738
[[ -z "$dist" ]] && return 1
3839

3940
local chroot="$2"
40-
[[ -z "$chroot" ]] && chroot="$md_build/chroot"
41+
[[ -z "$chroot" ]] && chroot="$md_build/$dist"
4142

4243
mkdir -p "$md_build"
4344
pushd "$md_build"
@@ -105,7 +106,7 @@ function install_rp_image() {
105106
fi
106107

107108
local chroot="$3"
108-
[[ -z "$chroot" ]] && chroot="$md_build/chroot"
109+
[[ -z "$chroot" ]] && chroot="$md_build/$dist"
109110

110111
local dist_version="$(_get_info_image "$dist" "version")"
111112

@@ -180,6 +181,9 @@ _EOF_
180181
}
181182

182183
function _init_chroot_image() {
184+
local chroot="$1"
185+
[[ -z "$chroot" ]] && return 1
186+
183187
# unmount on ctrl+c
184188
trap "_trap_chroot_image '$chroot'" INT
185189

@@ -202,7 +206,7 @@ function _init_chroot_image() {
202206

203207
function _deinit_chroot_image() {
204208
local chroot="$1"
205-
[[ -z "$chroot" ]] && chroot="$md_build/chroot"
209+
[[ -z "$chroot" ]] && return 1
206210

207211
trap "" INT
208212

@@ -224,7 +228,7 @@ function _trap_chroot_image() {
224228

225229
function chroot_image() {
226230
local chroot="$1"
227-
[[ -z "$chroot" ]] && chroot="$md_build/chroot"
231+
[[ -z "$chroot" ]] && return 1
228232
shift
229233

230234
printMsgs "console" "Chrooting to $chroot ..."
@@ -311,7 +315,7 @@ function create_bb_image() {
311315
[[ -z "$image" ]] && return 1
312316

313317
local chroot="$2"
314-
[[ -z "$chroot" ]] && chroot="$md_build/chroot"
318+
[[ -z "$chroot" ]] && return 1
315319

316320
# replace fstab
317321
echo "proc /proc proc defaults 0 0" >"$chroot/etc/fstab"
@@ -346,7 +350,7 @@ function platform_image() {
346350
printMsgs "heading" "Building $platform image based on $dist ..."
347351

348352
rp_callModule image create_chroot "$dist"
349-
rp_callModule image install_rp "$platform" "$dist" "$md_build/chroot"
353+
rp_callModule image install_rp "$platform" "$dist" "$md_build/$dist"
350354

351355
local dist_name="$(_get_info_image "$dist" "name")"
352356
local file_add="$(_get_info_image "$dist" "file_${platform}")"

0 commit comments

Comments
 (0)