mirror of
https://github.com/pengutronix/genimage.git
synced 2024-11-26 19:23:55 +08:00
Merge pull request #119 from michaelolbrich/exec
exec-* environment fixes and related stuff
This commit is contained in:
commit
fa592228f5
@ -50,6 +50,9 @@ EXTRA_DIST += \
|
||||
test/basic-images.test \
|
||||
test/cpio.config \
|
||||
test/cramfs.config \
|
||||
test/exec-check.sh \
|
||||
test/exec-fail.config \
|
||||
test/exec.config \
|
||||
test/ext2.config \
|
||||
test/ext2test.dump \
|
||||
test/ext2percent.config \
|
||||
|
@ -465,7 +465,7 @@ static int collect_mountpoints(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *mountpath(struct image *image)
|
||||
const char *mountpath(const struct image *image)
|
||||
{
|
||||
struct mountpoint *mp;
|
||||
|
||||
@ -586,7 +586,7 @@ static int setenv_image(const struct image *image)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = overwriteenv("IMAGEMOUNTPATH", image->mp ? image->mp->mountpath : NULL);
|
||||
ret = overwriteenv("IMAGEMOUNTPATH", image->empty ? NULL : mountpath(image));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -22,7 +22,7 @@ const char *imagepath(void);
|
||||
const char *inputpath(void);
|
||||
const char *rootpath(void);
|
||||
const char *tmppath(void);
|
||||
const char *mountpath(struct image *);
|
||||
const char *mountpath(const struct image *);
|
||||
struct flash_type;
|
||||
|
||||
struct mountpoint {
|
||||
|
@ -40,7 +40,7 @@ static int file_generate(struct image *image)
|
||||
if (!strcmp(f->infile, imageoutfile(image)))
|
||||
return 0;
|
||||
|
||||
ret = systemp(image, "cp %s %s", f->infile, imageoutfile(image));
|
||||
ret = systemp(image, "cp '%s' '%s'", f->infile, imageoutfile(image));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ setup_data() {
|
||||
find "${root_orig}" -print0 | xargs -0 touch -c -d "2011-11-11 UTC"
|
||||
find "${root_orig}"/ -mindepth 1 -printf "%P\n" | sort > "${filelist_orig}"
|
||||
|
||||
cp "${testdir}"/*.conf* .
|
||||
cp "${testdir}"/*.conf* "${testdir}"/*.sh .
|
||||
}
|
||||
|
||||
run_genimage() {
|
||||
@ -373,6 +373,23 @@ test_expect_success rauc "rauc" "
|
||||
test_cmp '${testdir}/test2.raucb.info' test2.raucb.info
|
||||
"
|
||||
|
||||
setup_exec_files() {
|
||||
rm -rf input &&
|
||||
mkdir input &&
|
||||
dd if=/dev/zero of=input/file1.img bs=512 count=7 &&
|
||||
dd if=/dev/zero of=input/file2.img bs=512 count=7 &&
|
||||
dd if=/dev/zero of=input/file3.img bs=512 count=7 &&
|
||||
dd if=/dev/zero of=input/file4.img bs=512 count=7
|
||||
}
|
||||
|
||||
test_expect_success "exec" "
|
||||
setup_exec_files &&
|
||||
run_genimage exec.config"
|
||||
|
||||
test_expect_success "exec-fail" "
|
||||
setup_exec_files &&
|
||||
test_must_fail run_genimage exec-fail.config"
|
||||
|
||||
test_done
|
||||
|
||||
# vim: syntax=sh
|
||||
|
33
test/exec-check.sh
Executable file
33
test/exec-check.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
exec >&2
|
||||
|
||||
name="${1}"
|
||||
empty="${2}"
|
||||
|
||||
set -ex
|
||||
|
||||
: OUTPUTPATH
|
||||
test "${OUTPUTPATH}" = "${PWD}/images"
|
||||
: INPUTPATH
|
||||
test "${INPUTPATH}" = "${PWD}/input"
|
||||
: ROOTPATH
|
||||
test "${ROOTPATH}" = "${PWD}/root"
|
||||
: TMPPATH
|
||||
test "${TMPPATH}" = "${PWD}/tmp"
|
||||
: IMAGE
|
||||
test "${IMAGE}" = "${name}"
|
||||
: IMAGEOUTFILE
|
||||
test "${IMAGEOUTFILE}" = "${PWD}/images/${name}"
|
||||
: IMAGENAME
|
||||
test "${IMAGENAME}" = "exec-test"
|
||||
: IMAGESIZE
|
||||
test "${IMAGESIZE}" = "3584"
|
||||
: IMAGEMOUNTPOINT
|
||||
test "${IMAGEMOUNTPOINT}" = ""
|
||||
: IMAGEMOUNTPATH
|
||||
if [ "${empty}" = "empty" ]; then
|
||||
test "${IMAGEMOUNTPATH}" = ""
|
||||
else
|
||||
test "${IMAGEMOUNTPATH}" = "${PWD}/tmp/root"
|
||||
fi
|
4
test/exec-fail.config
Normal file
4
test/exec-fail.config
Normal file
@ -0,0 +1,4 @@
|
||||
image file1.img {
|
||||
file {}
|
||||
exec-pre = "false"
|
||||
}
|
27
test/exec.config
Normal file
27
test/exec.config
Normal file
@ -0,0 +1,27 @@
|
||||
image file1.img {
|
||||
file {}
|
||||
name = "exec-test"
|
||||
exec-pre = "./exec-check.sh file1.img"
|
||||
}
|
||||
|
||||
image file2.img {
|
||||
file {}
|
||||
name = "exec-test"
|
||||
mountpoint = "/"
|
||||
exec-post = "./exec-check.sh file2.img"
|
||||
}
|
||||
|
||||
image file3.img {
|
||||
file {}
|
||||
name = "exec-test"
|
||||
empty = true
|
||||
exec-pre = "./exec-check.sh file3.img empty"
|
||||
}
|
||||
|
||||
image file4.img {
|
||||
file {}
|
||||
name = "exec-test"
|
||||
empty = true
|
||||
mountpoint = "/"
|
||||
exec-post = "./exec-check.sh file4.img empty"
|
||||
}
|
Loading…
Reference in New Issue
Block a user