mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-09-04 20:17:55 +00:00
1f376f5dd0
The two builders read and wrote files three different ways. buildrpms.pl used File::Slurper, builddebs.pl opened and closed handles inline, and BuildUtils.pm carried its own read_file/write_file pair to avoid the dependency. The result was that the same operation was spelled differently in each place, and the Version stamp was read by hand in both builders: buildrpms.pl chomped it ten lines after reading it, which is how a stamp keeps a trailing newline nobody notices until it reaches a package name. Drop the hand-rolled pair and use File::Slurper throughout, and add BuildUtils::read_line for the one-line Version and Release stamps -- it strips the newline at the point of reading and reports an absent file as undef, which is what builddebs.pl's fallback to snap_release needs. File::Slurper is already required by buildrpms.pl and is already in the CI package list, so this adds no new build-host prerequisite. The lock file still uses a raw open: flock needs a real handle. Behaviour note: Version is now read as its first line rather than the whole file with the final newline removed. For the one-line file it is, these are the same; a malformed multi-line Version now yields its first line instead of an embedded newline. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>