AIX Open Source

AIX Open Source

Share your experiences and connect with fellow developers to discover how to build and manage open source software for the AIX operating system

 View Only
  • 1.  generally question: rpm %define macro

    Posted Mon February 20, 2023 08:00 AM

    Hello Community, dear open source team.

    I'm facing a problem creating an rpm which installs different tarballs depending on the AIX OS release.

    I tried to define a variable, where the value is dynamically build by "uname -r", then I want to use this value in %files for choosing the tarball for 7.2 or 7.3

    %define RELEASE %(uname -r)
    
    %files
    /tmp/COOPtestfile_%{RELEASE}.tar

    I also tried:

    %global techLevel `uname -r`
    
    %global techLevel %{expand:uname -r}
    
    %global techLevel %{?shell:uname -r}

    Nothing is working. In the first two example the variable will not be dissolved and for the last two, the variable is empty.

    Do anyone have an idea how to solve this? Is it even possible to do it this way?

    Many thanks in advance for your help and support.

    best regards,
    Joerg



    ------------------------------
    Joerg Kauke
    Unix Administrator
    COOP Switzerland
    ------------------------------


  • 2.  RE: generally question: rpm %define macro

    Posted Mon February 20, 2023 08:22 AM

    should work as described -> https://rpm-packaging-guide.github.io/#defining-your-own



    ------------------------------
    I regret starting this entire conversation
    ------------------------------



  • 3.  RE: generally question: rpm %define macro

    Posted Mon February 20, 2023 08:31 AM

    These are macros decided at the build time, not at installation time. 
    Probably you can look into pre/post installation scripts. 



    ------------------------------
    Ayappan P
    ------------------------------



  • 4.  RE: generally question: rpm %define macro

    Posted Mon February 20, 2023 09:39 AM

    Hi Ayappan,

    thanks a lot for your quick answer.

    In this case I have to copy both versions of the tarball and decide what to install in the pre script.

    Thanks again...

    best regards,

    Joerg



    ------------------------------
    Joerg Kauke
    Unix Administrator
    COOP Switzerland
    ------------------------------



  • 5.  RE: generally question: rpm %define macro

    Posted Mon February 20, 2023 09:53 AM

    Yes, that's right. 
    Otherwise you need to build separate rpms for each AIX level (7.2, 7.3). 



    ------------------------------
    Ayappan P
    ------------------------------



  • 6.  RE: generally question: rpm %define macro

    Posted Wed February 22, 2023 09:02 AM
    You're already on the right track, maybe just having a slightly different goal will make it easier? :)


    First Option:

    Instead of trying to define the macro here, you can use one that RPM defines for you - you'll just have to name your files the right way:
    %{_arch}
    %{_host_os}
    %{_host}

    There are others. You can look at many of them with:
    rpm --showrc


    Better Option:

    It's not great practice to use an RPM to install a tarball. Instead, unpack the tar file and include its contents in the binary RPM. That way RPM can be used to validate the contents of the things you installed, upgrade, uninstall, etc. Otherwise you have no way of knowing if the installed files still represent the version number indicated by the RPM - you're just lying to yourself and future admins.

    There are conditionals that can be used in the SPEC file to pick what is included in %files and generate multiple target RPMs (like one for each version, arch, etc.).

    I hope this helps!

    -- 
    Stephen L. Ulmer
    Enterprise Architect
    Mainline Information Systems