Another thing to consider is that we may be using use these directories outside of Java environment. I haven't checked but maybe some python code and even some Salt code. On 13.01.22 13:56, Can Bulut Bayburt wrote:
On 13.01.22 13:25, Stefan Bluhm wrote:
I see, a mixed approach sounds interesting.
What is your thought on setting SUSEMANAGER_DIR by ant parameters at build time using tokens in the .java files (controlled within the spec)?
That way we skip the post script, DB code or other additional complexity and still have foll control in the spec file. You're right. We could either use tokens, or the jar manifest.
----- Ursprüngliche Mail ----- Von: "Can Bulut Bayburt" An: "devel" <devel@lists.uyuni-project.org> Gesendet: Donnerstag, 13. Januar 2022 13:07:33 Betreff: Re: OS dependent folders in Java
Hi Stefan,
IMHO, especially /srv/susemanager is essential and completely internal, so we should prefer to do it on build time to make sure it never changes, and definitely not let users configure these on their own, so probably not in 'rhn.conf'. And actually the .spec file doesn't sound that bad to me. This way we can have the folders served properly with rpm. We can have a tiny post script that somehow writes the OS-specific locations somewhere for Java to read (maybe in the DB?)
On 13.01.22 09:20, Stefan Bluhm wrote:
Hello,
I started working on removing hard coded file/folder locations to make Uyuni less OS dependent.
In the end, thic COULD boil down to these used folders (ignoring folders defined in test cases and giving them a tag for discussion): /srv/www/htdocs (WEBROOT) /srv/www/os-images (OSIMAGES) /srv/susemanager (SUSEMANAGER_DIR)
code/src/com/suse/manager/webui/services/SaltConstants.java
Where would be the best place to parameterise them?
- rhn.conf WEBROOT is already in there. I would think that this would be the best place to put ALL folder locations in there to keep it central. This would need a migration script for existing systems to add the folders.
- spec file Doesn't sound like the best idea.
- build.xml Not sure how to detect the right OS. So maybe a flag can be passed on to use SUSE or RHEL file structure. Then we copy the relevant config file to the build folder.
- java class This would be double maintenance and just increasing the amount of hard coding.
I would see two approaches:
1. Add all folders (starting with the ones above as common denominator) into rhn.conf. Put an update logic into the SPEC file for existing systems. Adapt the existing Java classes and constant files (i.e. SaltConstants.java) to read the value from rhn.conf.
2. Adapt Java classes to use a central OS dependent constant file (like SaltConstants.java). Get build.xml to use the right one during build. Control the ant build via the spec file (as I am not sure we can detect the OS reliably/easily with ant).
Would be great to hear your thoughs.
Best wishes,
Stefan