RPM spec file parsing



  • I’m currently trying to modify a RPM spec file to change some build options. For those who do not know, a spec file (a textual file with a .spec extension) is a file describing how to create a software package for RedHat-derived Linux distributions (a RPM package). Everything is contained in a single file: package description, source download URLs, patches file names, build scripts, install/remove scripts, changelogs... This format it a WTF by itself.



    The build script I’m modifying looks like this :

    # blah blah blah some comment
    %configure $COMMON_ARGS --generate-useless-docs
    make
    

    I want to remove the --generate-useless-docs option, so I copy the line, comment it, and edit it.

    # blah blah blah some comment
    #%configure $COMMON_ARGS --useless-option
    %configure $COMMON_ARGS
    make
    

    Looks good, right ? Wrong. After restarting the build, I found out that the --useless-option was still passed to the configure script. After checking for 10 minutes if the configuration options were cached somewhere, out of desperation, I removed the commented out line. It worked.


    After some tests, it appears that despite what my code editor’s syntax highlighter is saying, a commented out "%configure some options..." will execute anyway. Even "# some comment %configure some options" will execute the %configure part. I cannot really imagine how the parser for this file type works.



  • I could understand that for a given task, commented-out code is forbidden, and I could understand that executing it anyway is a great way to ensure that no code is commented out.

     But I can't really find a reason for a public format to implement that. In addition, I am willing to bet that this was up before source control could allow for easy old code retrieval, making commented out code much less stupid.



  • @VinDuv said:

    Looks good, right ? Wrong. After restarting the build, I found out that the --useless-option was still passed to the configure script. After checking for 10 minutes if the configuration options were cached somewhere, out of desperation, I removed the commented out line. It worked.

    After some tests, it appears that despite what my code editor’s syntax highlighter is saying, a commented out "%configure some options..." will execute anyway. Even "# some comment %configure some options" will execute the %configure part. I cannot really imagine how the parser for this file type works.

    It turns out that RPM uses very simple-minded string macro expansion, and since the expansion of %configure begins with a newline followed by the configure command line, you get an empty comment line followed by a configure command.  The "solution" apparently is that you need to escape % signs in comments by doubling them up.

    Yes, that sucks.

     



  • You better have a good reason for using a non-Debian-based Linux distro.



  • @MiffTheFox said:

    You better have a good reason for using a non-Debian-based Linux distro.

    I have a Chromebook. Does that count?


  • ♿ (Parody)

    @MiffTheFox said:

    You better have a good reason for using a non-Debian-based Linux distro.

    Seriously? Management loves them a RedHat contract. Also, if you're going to run Oracle on Linux, you pretty much need to, or I don't think Oracle will offer you support.



  • @Ben L. said:

    @MiffTheFox said:

    You better have a good reason for using a non-Debian-based Linux distro.

    I have a Chromebook. Does that count?

    Chromebooks can count to five. Then they overflow.


  • Considered Harmful

    Mine counts 1, 2, Many.



  • @boomzilla said:

    @MiffTheFox said:

    You better have a good reason for using a non-Debian-based Linux distro.

    Seriously? Management loves them a RedHat contract. Also, if you're going to run Oracle on Linux, you pretty much need to, or I don't think Oracle will offer you support.

    Well that's a good reason. Shouldn't the recommended OS for Oracle be Solaris now though?



  • @Ben L. said:

    @MiffTheFox said:

    You better have a good reason for using a non-Debian-based Linux distro.

    I have a Chromebook. Does that count?

    Eh. I can accept "it doesn't matter if next to nobody supports my distro because I only run one application on it ever" but I have a problem with a distro optimized to only run one application ever.



  • @MiffTheFox said:

    I can accept "it doesn't matter if next to nobody supports my distro because I only run one application on it ever" but I have a problem with a distro optimized to only run one application ever.

    So I take it you don't approve of firewall/router Linux distros?


  • ♿ (Parody)

    @MiffTheFox said:

    Well that's a good reason. Shouldn't the recommended OS for Oracle be Solaris now though?

    I don't know what they recommend over all (I try to stay away from this level of decision making), but if you're going to run Linux, they have their own distro, OracleLinux, derived from RHEL.



  • @boomzilla said:

    @MiffTheFox said:
    Well that's a good reason. Shouldn't the recommended OS for Oracle be Solaris now though?

    I don't know what they recommend over all (I try to stay away from this level of decision making), but if you're going to run Linux, they have their own distro, OracleLinux, derived from RHEL.

    Yeah, Ellison's got his dick in a number of pies. Solaris and a Linux distro. ZFS and btrfs. Java and HIV.



  • @morbiuswilters said:

    @boomzilla said:
    @MiffTheFox said:
    Well that's a good reason. Shouldn't the recommended OS for Oracle be Solaris now though?

    I don't know what they recommend over all (I try to stay away from this level of decision making), but if you're going to run Linux, they have their own distro, OracleLinux, derived from RHEL.

    Yeah, Ellison's got his dick in a number of pies. Solaris and a Linux distro. ZFS and btrfs. Java and HIV.

    You spelled Oracle wrong.



  • @morbiuswilters said:

    @MiffTheFox said:
    I can accept "it doesn't matter if next to nobody supports my distro because I only run one application on it ever" but I have a problem with a distro optimized to only run one application ever.

    So I take it you don't approve of firewall/router Linux distros?

    Who says that a firewall/router Linux distro needs to only run one applicaiton ever?



  • @MiffTheFox said:

    @morbiuswilters said:
    @MiffTheFox said:
    I can accept "it doesn't matter if next to nobody supports my distro because I only run one application on it ever" but I have a problem with a distro optimized to only run one application ever.

    So I take it you don't approve of firewall/router Linux distros?

    Who says that a firewall/router Linux distro needs to only run one applicaiton ever?

    Is Chrome-dows OS 8 capable of running only one application? I thought you were saying distros that were optimized for a single application..



  • @morbiuswilters said:

    @MiffTheFox said:
    @morbiuswilters said:
    @MiffTheFox said:
    I can accept "it doesn't matter if next to nobody supports my distro because I only run one application on it ever" but I have a problem with a distro optimized to only run one application ever.

    So I take it you don't approve of firewall/router Linux distros?

    Who says that a firewall/router Linux distro needs to only run one applicaiton ever?

    Is Chrome-dows OS 8 capable of running only one application? I thought you were saying distros that were optimized for a single application..



  • So Linux system shit and Chrome. Let me know when you have something like Pidgin running on it.



  • @Ben L. said:

    "Let me answer your question with a huge image of gibberish."



  • @blakeyrat said:

    @Ben L. said:

    "Let me answer your question with a huge image of gibberish."

    Who said anything about answering questions?



  • @Ben L. said:

    That's one application: Chrome. Even your shell there is running in Chrome..

    Although I guess you could argue that all of the "applications" running inside Chrome actually qualify.


Log in to reply