weldr / lorax

Tools for creating images, including the Anaconda boot.iso, live disk images, iso's, and filesystem images.
GNU General Public License v2.0
294 stars 157 forks source link

livemedia-creator lacks a way to add files to the iso image #197

Closed lesnake closed 7 years ago

lesnake commented 7 years ago

When livemedia-creator exits, the result is an iso image contains squashfs, which contains ext3f, which is the rootfs. The kickstart allows installing packages, and do post processing in the rootfs. But not in the iso.

.ks files available in /usr/share/doc/lorax/fedora-livemedia.ks contains this %post section :

%post`

--nochroot cp $INSTALL_ROOT/usr/share/licenses/-release/ $LIVE_ROOT/

# only works on x86, x86_64 if [ "$(uname -i)" = "i386" -o "$(uname -i)" = "x86_64" ]; then if [ ! -d $LIVE_ROOT/LiveOS ]; then mkdir -p $LIVE_ROOT/LiveOS ; fi cp /usr/bin/livecd-iso-to-disk $LIVE_ROOT/LiveOS fi %end

Which does not work :

Instead:

livecd-creator mechanism based on %post using $LIVE_ROOT has no equivalent, which is, for me, a lack in the said .ks file compatibility.

Having the possibility to interact with the iso file before its packing could be great to :

nicholseric commented 7 years ago

A recent patch https://github.com/rhinstaller/lorax/commit/c91278a17d34b92d3bd549b5ff862e7375c21975 accomplishes this by modifying share/templates.d/99-generic/live/x86.tmpl . Here BCL is using this to copy a license file to iso /. You could add your own template using this method.

lesnake commented 7 years ago

If I undestand correctely, I have to

Correct ?

nicholseric commented 7 years ago

No, i think, either append your file names to $f or add them to the end mkisofs after copying them to $outroot. Modify lorax x86.tmpl directly or copy all templates to new dir and modify x86 because --lorax-templates uses a directory

lesnake commented 7 years ago

Ok. I get the workflow now.

I think I am going to stick to my actual workflow : a basic mount of the iso, then a copy in a writable location, do my patch/copy job then repack the iso.

For this workflow I think the best could be the calling of a script given by the user as a LMC parameter with the outroot, current path as arguments & environment.

bcl commented 7 years ago

You can do this with --add-arch-template added in commit 67217f56425ce24e74f0a75010b22f5c462de239 which also added including content from iso-graft in the workdir.

frafra commented 7 years ago

I think it should be documented that %post --nochroot is no more working. I tried to create an iso-graft directory inside the working directory the right way to add arbitrary content, but the content has not been included. Am I missing something?

alexbozhenko commented 6 years ago

Hello. I have similar question. I am using lorax to build live image like this: livemedia-creator --vcpus 4 --resultdir lorax-output --make-pxe-live --iso CentOS-7-x86_64-Minimal-1708.iso --ks ks2.cfg --vnc vnc=127.0.0.1:5 Is there a way to inject files to the resulting squashfs image using lorax? @bcl Brian, could you please comment on this?

alcir commented 6 years ago

So you confirm that %post --nochroot doesn't work?

saifeiLee commented 2 years ago

You can do this with --add-arch-template added in commit 67217f5 which also added including content from iso-graft in the workdir.

I found a solution. In share/templates.d/99-generic/live/x86.tmpl source code, it makes iso by xorrisofs. And the key parameter is -graft-points. With option -graft-points it is possible to put files and directories to arbitrary paths in the ISO image.

saifeiLee commented 2 years ago

So you confirm that %post --nochroot doesn't work?

I tried, did not work.

squirrlien commented 1 year ago

Solution is here.. https://pagure.io/fedora-kickstarts/c/1c9fefa1865ced5b357b3ec5f3b7d5bd856809fc

"Adapt for livemedia-creator changes

Now that F24 images are made with livemedia-creator instead of
livecd-creator, the kickstart parser has changed; the new kickstart
parser doesn't understand the $INSTALL_ROOT variable we'd been using in
%post --nochroot scripts. This commit fixes this by replacing
$INSTALL_ROOT usage with hardcoded /mnt/sysimage as docs suggest.

While at this, this commit also fixes a case where resolv.conf would be
incorrectly copied if it is a symlink, thanks to dgilmore for pointing
this out."