openhpi2 / Open-HPI-base

Open HPI is an open source implementation of the SA Forum's Hardware Platform Interface (HPI). HPI provides an abstracted interface to managing computer hardware, typically for chassis and rack based servers
0 stars 1 forks source link

Make autogenerated file output more stable #2569

Closed openhpi2 closed 8 years ago

openhpi2 commented 9 years ago

As reported in https://bugzilla.opensuse.org/show_bug.cgi?id=915949, it seems that some autogenerated files have a random order for the autogenerated code.

Would it be easy to make that autogenerated code more stable.

As a background: we rebuild our packages when ever one of their dependencies change. we have a script called build-compare to find out if the newly build rpms differ from the previous build. if that is the case we skip the current build and do not trigger packages that depend on the current package. the random order of the lines in the generated files kind of break that optimization.

Reported by: darix

openhpi2 commented 9 years ago

Original comment by: dr_mohan

openhpi2 commented 9 years ago

The initial analysis shows the following command autogenerates a el2event.c file ../../../scripts/text2cstr.pl -s eventxml event.xml > el2event.c ../../scripts/text2cstr.pl -s eventxml event.xml > el2event.c The attached file shows the difference in one instance. Even though the source is not changed, looks like the generated file has jumbled lines. The input to this perl script, event.xml, is also an autogenerated file. This was generated by eventmap2code.pl using snmp_bc_event.map which are checked in files. ../../../plugins/snmp_bc/eventmap2code.pl -xml -idir ../../../plugins/snmp_bc -mapfile snmp_bc_event.map ../../plugins/snmp_bc/eventmap2code.pl -xml -idir ../../plugins/snmp_bc -mapfile snmp_bc_event.map

The attached file shows the differences. Any one who is familier with perl and/or blade center plugin could help by creating a patch.

Original comment by: dr_mohan

openhpi2 commented 9 years ago

Please try the attached patch

Original comment by: avpak

openhpi2 commented 9 years ago

The keys of a hash are returned in an apparently random order. The actual random order is subject to change in future versions of Perl, but it is guaranteed to be the same order as either the values or each function produces (given that the hash has not been modified). Since Perl 5.8.1 the ordering is different even between different runs of Perl for security reasons.

http://www.perlmonks.org/?node_id=1005122

Original comment by: avpak

openhpi2 commented 9 years ago

The patch works well on SLES12 which has perl > 5.18.1. Could some one else test it too?

Original comment by: dr_mohan

openhpi2 commented 9 years ago

Original comment by: dr_mohan

openhpi2 commented 9 years ago

Anton's patch works well. It was tested on SLES12 where perl version is >5.18.1. Darix confirmed with his testing that patch works well

Original comment by: dr_mohan

openhpi2 commented 9 years ago

Original comment by: dr_mohan

openhpi2 commented 9 years ago

Fixed with checkin #7617

Original comment by: dr_mohan

openhpi2 commented 9 years ago

Original comment by: dr_mohan