new magpie command: fixspec

i just released magpie 1.110390, which brings a new subcommand: magpie fixspec

as you can guess, this command will try to sanitize a rpm spec file a bit. to use it, you must be in a package checkout, and run it without any argument.
$ eval $( magpie co perl-Foo-Bar )
$ magpie fixspec -v

# to see the list of options
$ magpie help fix

among the things that fixspec does:
  • it updates %doc depending on the existing files, including meta files
  • it splits multiple bundled build-/requires to have only one per line
  • it lines up vertically the summary / etc
  • it extracts perl buildrequires from meta.json/meta.yml if present
  • it removes buildroot definition
  • it removes mdv macros
note that the code is not really clean, it might gain from being in its
own module, with real rpm parsing instead of big regexes. also, it
assumes that we're cleaning a perl module spec file, so you're on your
own if you're using it on other spec file: it might remove the whole
svn, eat your babies, or even convert your rpm database to rpm5. you've
been warned. :-)


  1. This command sounds backwards. Why remove Mandriva macros? Which ones? Why remove Buildroot, it just makes the spec file unusable on older (but some still current or latestmstable) distros (RHEL5, CentOS5, OEL5 and older) and there is no real issue in keeping it.

  2. @buchan: mandriva macros do not exist in mageia, therefore they throw an error on mageia build system - so we need to trim them out.

    buildroot is also removed to follow mageia guidelines. could we keep it? yes. but it was decided to use the package importing in mageia as an opportunity to clean up stuff which is not really needed.

    note also that all spec files have some specificities depending on the linux distribution. and we could have a spec file with lots of %if to make sure the package compiles on mageia / mandriva / suse / fedora / rhel / centos / whatever... but then the spec would be 5 times bigger, and rather unreadable - for a possibility which doesn't happen really often (read: almost never). i prefer having a straightforward spec file, easy to port, rather than a big amount of code that bitrots.

    finally - fixspec also provides some really cool features, such as buildrequires update, and %doc completion.