#! /usr/bin/perl # Copyright (c) 2002-2016, Dirk Krause # All rights reserved. # # Redistribution and use in source and binary forms, # with or without modification, are permitted provided # that the following conditions are met: # # * Redistributions of source code must retain the above # copyright notice, this list of conditions and the # following disclaimer. # * Redistributions in binary form must reproduce the above # opyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials # provided with the distribution. # * Neither the name of the Dirk Krause nor the names of # contributors may be used to endorse or promote # products derived from this software without specific # prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. # IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE. my @lines; my $numlines = 0; my $isfirst = 1; my $inchangelog = 0; my $ifh = undef; my $ofh = undef; my $newwday = ""; my $newmon = ""; my $newmday = ""; my $newyear = ""; my $newname = ""; my $newmail = ""; my $newmajor = ""; my $newminor = ""; my $newmicro = ""; my $wday = ""; my $mon = ""; my $mday = ""; my $year = ""; my $name = ""; my $mail = ""; my $major = ""; my $minor = ""; my $micro = ""; my $line; sub shipout() { my $i; if (0 < $numlines) { if (0 != $isfirst) { $isfirst = 0; print "# DO NOT EDIT THIS FILE!\n"; print "# It is generated automatically from the dktools-el6.spec.in\n"; print "# file."; } print "\ndktools ($major.$minor.$micro-1) unstable; urgency=low\n\n"; for ($i = 0; $i < $numlines; $i++) { $line = $lines[$i]; print "$line\n"; } print "\n -- $name <$mail> $wday, $mday $mon $year 20:00:00 +0200\n\n"; } } if (open($ifh, ") { $line = $_; chomp $line; if ($line =~ /^\s*\%/o) { if ($line =~ /^\s*\%changelog/o) { $inchangelog = 1; } else { $inchangelog = 0; } } else { if (0 != $inchangelog) { if ($line =~ /^\s*$/o) { shipout(); $numlines = 0; } else { if ($line =~ /^\*\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+([^<>]+)\s+<([^<>]+)>\s+(\d+)\.(\d+)\.(\d+)/o) { $newwday = $1; $newmon = $2; $newmday = $3; $newyear = $4; $newname = $5; $newmail = $6; $newmajor = $7; $newminor = $8; $newmicro = $9; shipout(); $numlines = 0; $wday = $newwday; $mon = $newmon; $mday = $newmday; $year = $newyear; $name = $newname; $mail = $newmail; $major = $newmajor; $minor = $newminor; $micro = $newmicro; } else { if ($line =~ /^\s*\-\s*(.*)/o) { $line = "* $1"; } $line = " $line"; $lines[$numlines++] = $line; } } } } } shipout(); close($ifh); }