Bug 39849

Summary: Target dependency issue in Makefile
Product: Koha Reporter: David Cook <dcook>
Component: Architecture, internals, and plumbingAssignee: David Cook <dcook>
Status: Pushed to main --- QA Contact: Martin Renvoize (ashimema) <martin.renvoize>
Severity: blocker    
Priority: P5 - low CC: jonathan.druart, martin.renvoize, mtj, paul.derscheid, philippe.blouin
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39623
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
25.05.00
Circulation function:
Bug Depends on: 37911, 36546    
Bug Blocks:    
Attachments: Bug 39849: Fix makefile target dependency order
Bug 39849: Fix makefile target dependency order
Bug 39849: Fix makefile target dependency order

Description David Cook 2025-05-07 06:39:50 UTC
In a clean git working directory or in a "git archive" tarball, you can run "perl Makefile.PL", but if you run "make", you'll get the following error and make will crash:

make: *** No rule to make target 'api/v1/swagger/swagger_bundle.json', needed by 'pm_to_blib'

Bug 36546 added a file mapping for 'api/v1/swagger/swagger_bundle.json' which is used in the "pm_to_blib" target.

At that time, "build-resources.PL" was run *before* "pm_to_blib" via "compile_css_js".

But in Bug 37911, I moved "compile_css_js" to happen *after* "pm_to_blib", so that the Vue files could be copied into the "blib". 

We didn't notice this bug because on all the test builds we were doing, we forgot to "rm 'api/v1/swagger/swagger_bundle.json'" prior to the builds, so the builds were using a previously generated swagger_bundle.json file.

Anyway, I think I know the solution. Let me see if I can bang it out really quickly. Otherwise, I'll do it tomorrow...
Comment 1 David Cook 2025-05-07 07:21:44 UTC
Created attachment 182014 [details] [review]
Bug 39849: Fix makefile target dependency order

This patch fixes the makefile target dependency order, so that it runs
in this order:
1. Build CSS and JS assets
2. Run pm_to_blib, which is the step that copies over most of Koha's files
into blib
3. Move 'vue/dist' files via "move_compiled_js" makefile target/step

To test:
1a. Run 'git archive --format=tar HEAD > "koha.orig.tar"'
1b. sudo mkdir /opt/koha /opt/build_koha
1c. sudo chown kohadev-koha /opt/koha /opt/build_koha
1d. mv koha.orig.tar /opt/build_koha/.
1e. cd /opt/build_koha
1f. tar xvf koha.orig.tar
2. Run "perl Makefile.PL"
Choose "single"
Choose "/opt/koha" for target directory
Choose the defaults for the rest
3. Run "make"
4. Note the first step is the CSS/JS build
5. Note the second step is the copying of files to "blib"
6. Run "find -name 'esm.js.map'" and note it appears in the regular
build location as well as in "blib"
7. Run "find -name 'swagger_bundle.json'" and note it appears in
the regular build location as well as in "blib"
8. Run "make install"
9. Run the above "find" commands using "/opt/koha" and note that
the files appear in the installed directory
Comment 2 Blou 2025-05-07 13:31:09 UTC
Created attachment 182024 [details] [review]
Bug 39849: Fix makefile target dependency order

This patch fixes the makefile target dependency order, so that it runs
in this order:
1. Build CSS and JS assets
2. Run pm_to_blib, which is the step that copies over most of Koha's files
into blib
3. Move 'vue/dist' files via "move_compiled_js" makefile target/step

To test:
1a. Run 'git archive --format=tar HEAD > "koha.orig.tar"'
1b. sudo mkdir /opt/koha /opt/build_koha
1c. sudo chown kohadev-koha /opt/koha /opt/build_koha
1d. mv koha.orig.tar /opt/build_koha/.
1e. cd /opt/build_koha
1f. tar xvf koha.orig.tar
2. Run "perl Makefile.PL"
Choose "single"
Choose "/opt/koha" for target directory
Choose the defaults for the rest
3. Run "make"
4. Note the first step is the CSS/JS build
5. Note the second step is the copying of files to "blib"
6. Run "find -name 'esm.js.map'" and note it appears in the regular
build location as well as in "blib"
7. Run "find -name 'swagger_bundle.json'" and note it appears in
the regular build location as well as in "blib"
8. Run "make install"
9. Run the above "find" commands using "/opt/koha" and note that
the files appear in the installed directory

Signed-off-by: Blou <philippe.blouin@inlibro.com>
Comment 3 Blou 2025-05-07 13:32:53 UTC
Signed off.
Solved my issues in my dev (git, raw, non-docker devbox environment).
Big thanks.
Comment 4 David Cook 2025-05-07 23:19:02 UTC
(In reply to Blou from comment #3)
> Signed off.
> Solved my issues in my dev (git, raw, non-docker devbox environment).
> Big thanks.

Really happy to hear this, Philippe. Thanks for reporting the initial issue. I'll be smarter with my test plans in the future to avoid this kind of scenario again!
Comment 5 David Cook 2025-05-08 05:54:25 UTC
Just noticed a problem in my test plan.

I wrote "esm.js.map" but it should be "erm.js.map". Little typo there!
Comment 6 Martin Renvoize (ashimema) 2025-05-08 12:10:59 UTC
Created attachment 182071 [details] [review]
Bug 39849: Fix makefile target dependency order

This patch fixes the makefile target dependency order, so that it runs
in this order:
1. Build CSS and JS assets
2. Run pm_to_blib, which is the step that copies over most of Koha's files
into blib
3. Move 'vue/dist' files via "move_compiled_js" makefile target/step

To test:
1a. Run 'git archive --format=tar HEAD > "koha.orig.tar"'
1b. sudo mkdir /opt/koha /opt/build_koha
1c. sudo chown kohadev-koha /opt/koha /opt/build_koha
1d. mv koha.orig.tar /opt/build_koha/.
1e. cd /opt/build_koha
1f. tar xvf koha.orig.tar
2. Run "perl Makefile.PL"
Choose "single"
Choose "/opt/koha" for target directory
Choose the defaults for the rest
3. Run "make"
4. Note the first step is the CSS/JS build
5. Note the second step is the copying of files to "blib"
6. Run "find -name 'esm.js.map'" and note it appears in the regular
build location as well as in "blib"
7. Run "find -name 'swagger_bundle.json'" and note it appears in
the regular build location as well as in "blib"
8. Run "make install"
9. Run the above "find" commands using "/opt/koha" and note that
the files appear in the installed directory

Signed-off-by: Blou <philippe.blouin@inlibro.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Comment 7 Katrin Fischer 2025-05-09 07:14:52 UTC
Pushed for 25.05!

Well done everyone, thank you!