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

iso-graft wrong dir workdir vs. outroot #1404

Closed duaneguthrie closed 2 months ago

duaneguthrie commented 3 months ago

all the .tmplate dirs have if os.path.exists(workdir + "/iso-graft"): filegraft += " " + workdir + "/iso-graft" workdir is not set. should it not be outroot if os.path.exists(outroot + "/iso-graft"): filegraft += " " + outroot + "/iso-graft"

bcl commented 2 months ago

No, workdir is correct. See commit 67217f56425ce24e74f0a75010b22f5c462de239 for the background on this.

duaneguthrie commented 2 months ago

i studied the commit many times. I looked for a unit test as an example of usage. workdir seems null when i run the script.

am i to use --add-arch-template-var to set workdir? i am not very familiar with these templates. outroot is defined at top of the file but not workdir.

Thanks in advance. Sorry for my lack of background

On Tue, Jul 9, 2024 at 7:48 PM Brian C. Lane @.***> wrote:

No, workdir is correct. See commit 67217f5 https://github.com/weldr/lorax/commit/67217f56425ce24e74f0a75010b22f5c462de239 for the background on this.

— Reply to this email directly, view it on GitHub https://github.com/weldr/lorax/issues/1404#issuecomment-2219223066, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFMPMMSICWFLC2N3BSB6FHTZLSAGVAVCNFSM6AAAAABKEHO6EWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJZGIZDGMBWGY . You are receiving this because you authored the thread.Message ID: @.***>

--

This message is intended exclusively for the individual(s) or entity to which it is addressed. It may contain information that is privileged or otherwise legally exempt from disclosure.  If you are not the named addressee, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this message in error, please notify the sender immediately by e-mail and delete all copies of the message.

Any digital signatures or certifications transmitted with this email are for sender verification purposes only and have not been included in this email for the purposes of binding the company to any statement or attachment made herein or for any other purpose.

duaneguthrie commented 2 months ago

i am trying to make an iso with mock and livemedia-creator . that path takes me to the live templates in /usr/share/lorax/templates.d/80-rocky. i tried to copy the

# Inherit iso-graft/ if it exists from external templates
<%
    import os
    if os.path.exists(workdir + "/iso-graft"):
        filegraft += " " + workdir + "/iso-graft"
%>

code in /var/lib/mock/sensor-9-x86_64/root/usr/share/lorax/templates.d/80-rocky/x86.tmpl to /var/lib/mock/sensor-9-x86_64/root/usr/share/lorax/templates.d/80-rocky/live/x86.tmpl

when i do that workdir is None.

bcl commented 2 months ago

Odd. I'll take a look at it when I have time.

duaneguthrie commented 2 months ago

Thank you so much.

bcl commented 2 months ago

Ah, I see what was happening here. The workdir variable is only set when running lorax, not livemedia-creator so that's why it was None when you tried to use it with the live template. With lorax if you pass it --workdir /path/to/tree and the tree has iso-graft under it it will copy the content of that to the root of the iso. Beware though, this is an override for the usual tempdir creation and it will clean up the workdir when it is done so if you use that method you need to set it up before running lorax each time. Don't put irreplaceable files in there :)

The whole mechanism of adding templates and variables and overriding workdir is really not a well documented feature.

duaneguthrie commented 2 months ago

thanks for digging in. the way i got it to work in lorax was to modify x86.tmpl like so: <% import os if os.path.exists(workdir + "/installtree/iso-graft"): filegraft += " /=" + workdir + "/installtree/iso-graft" print("DAG: content filegraft: ", filegraft) %> adding the "/installtree" fyi the /run/install/repo/Latest/ did not work in the kick start. so i went back to url --noverifyssl --url=file:///iso-graft/rpm/Latest repo --name=distribution --baseurl=file:///iso-graft/rpm/Latest because that is working. Latest is a link to a parallel directory.

At this point , it all seems be be working so i am moving on to next steps in the project.

just for your information. in runtime-postinstall.tmpl i had to add mkdir /iso-graft <% shutil.copytree("/builddir", root + "/iso-graft") %> runcmd echo "DAG end of postinstall tmpl" to get files to the needed location.

Thanks for all the help! Are you still ad redhat? this centos 7 migration stuff is ruff. :) this is a lot of code to maintain as a side job.

On Tue, Aug 6, 2024 at 4:42 PM Brian C. Lane @.***> wrote:

Ah, I see what was happening here. The workdir variable is only set when running lorax, not livemedia-creator so that's why it was None when you tried to use it with the live template. With lorax if you pass it --workdir /path/to/tree and the tree has iso-graft under it it will copy the content of that to the root of the iso. Beware though, this is an override for the usual tempdir creation and it will clean up the workdir when it is done so if you use that method you need to set it up before running lorax each time. Don't put irreplaceable files in there :)

The whole mechanism of adding templates and variables and overriding workdir is really not a well documented feature.

— Reply to this email directly, view it on GitHub https://github.com/weldr/lorax/issues/1404#issuecomment-2272200717, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFMPMMWIWKSK4MNATAWA2FLZQE7LFAVCNFSM6AAAAABKEHO6EWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZSGIYDANZRG4 . You are receiving this because you authored the thread.Message ID: @.***>

--

This message is intended exclusively for the individual(s) or entity to which it is addressed. It may contain information that is privileged or otherwise legally exempt from disclosure.  If you are not the named addressee, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this message in error, please notify the sender immediately by e-mail and delete all copies of the message.

Any digital signatures or certifications transmitted with this email are for sender verification purposes only and have not been included in this email for the purposes of binding the company to any statement or attachment made herein or for any other purpose.

bcl commented 2 months ago

I guess as long as it works, but you shouldn't have needed to change the templates to get this working.