Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary images cause tmppath to remain #237

Closed
detly opened this issue Feb 21, 2024 · 4 comments · Fixed by #239
Closed

Temporary images cause tmppath to remain #237

detly opened this issue Feb 21, 2024 · 4 comments · Fixed by #239

Comments

@detly
Copy link

detly commented Feb 21, 2024

Given this config:

image usb.img {
    hdimage {
        partition-table-type = gpt
    }
    partition root {
        image = "root.img"
    }
}

image root.img {
    size = "64M"
    temporary = true
    vfat {
        files = {
            "readme.md"
        }
    }
}

...if I run genimage --config usb.cfg then the following files are generated:

images/usb.img
root/ # empty
tmp/root.img
tmp/root/ # empty

If I then try to run genimage a second time, I get this output:

$ genimage --config usb.cfg
ERROR: tmppath '/home/jason/Code/[project paths]/tmp' exists and is not empty

I can understand the competing goals to (a) leave temporary artefacts around for debugging after running, but also (b) not delete stuff that might be important by default at startup. But it makes it annoying to integrate with other tools if there's this extra cleanup logic that's only needed sometimes. So if it is deliberate and not just an oversight, I'd suggest a flag to control this eg. --cleanup or its opposite --leave-tmp, or something like that.

  • genimage: 16
  • OS: Ubuntu 23.10
@michaelolbrich
Copy link
Member

I cannot reproduce this here. genimage should delete the content of .../tmp at the end.

What's the output of the first genimage run? It should end with something like this:

INFO: cmd: "rm -rf "/home/jason/Code/[project paths]/tmp"/*" (stderr):

@detly
Copy link
Author

detly commented Feb 23, 2024

Here's the full output from a more minimal project:

genimage-test ⚬ genimage --config usb.cfg 
INFO: cmd: "mkdir -p "/home/jason/Code/genimage-test/tmp"" (stderr):
INFO: cmd: "rm -rf "/home/jason/Code/genimage-test/tmp"/*" (stderr):
INFO: cmd: "mkdir -p "/home/jason/Code/genimage-test/tmp"" (stderr):
INFO: cmd: "cp -a "/home/jason/Code/genimage-test/root" "/home/jason/Code/genimage-test/tmp/root"" (stderr):
INFO: cmd: "mkdir -p "/home/jason/Code/genimage-test/images"" (stderr):
INFO: vfat(root.img): cmd: "mkdosfs   '/home/jason/Code/genimage-test/tmp/root.img'" (stderr):
INFO: vfat(root.img): adding file 'readme.md' as 'readme.md' ...
INFO: vfat(root.img): cmd: "MTOOLS_SKIP_CHECK=1 mcopy -sp -i '/home/jason/Code/genimage-test/tmp/root.img' '/home/jason/Code/genimage-test/input/readme.md' '::'" (stderr):
INFO: hdimage(usb.img): adding partition 'root' (in MBR) from 'root.img' ...
INFO: hdimage(usb.img): adding partition '[MBR]' ...
INFO: hdimage(usb.img): adding partition '[GPT header]' ...
INFO: hdimage(usb.img): adding partition '[GPT array]' ...
INFO: hdimage(usb.img): adding partition '[GPT backup]' ...
INFO: hdimage(usb.img): writing GPT
INFO: hdimage(usb.img): writing protective MBR
INFO: hdimage(usb.img): writing MBR
genimage-test ⚬ ls -sR
.:
total 20
4 images  4 input  4 root  4 tmp  4 usb.cfg

./images:
total 188
188 usb.img

./input:
total 0
0 readme.md

./root:
total 0

./tmp:
total 152
  4 root  148 root.img

./tmp/root:
total 0
genimage-test ⚬ genimage --config usb.cfg
ERROR: tmppath '/home/jason/Code/genimage-test/tmp' exists and is not empty

michaelolbrich added a commit to michaelolbrich/genimage that referenced this issue Feb 23, 2024
Right now cleanup is partially broken:
If the tmppath exists, then its content is removed at the end as
expected. However, if the tmppath is missing then it is created but
nothing is removed.

Change this to remove the directory including its content at the end
when the directory was created but stick to removing just the content if
the directory existed before genimage was called.

Fixes: pengutronix#237

Signed-off-by: Michael Olbrich <[email protected]>
@michaelolbrich
Copy link
Member

Ah, in my test, tmppath already existed and in that case, the content was removed as expected. Try #239, that should fix this.

@detly
Copy link
Author

detly commented Mar 5, 2024

Yep, that works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants