pax_global_header00006660000000000000000000000064115277334710014524gustar00rootroot0000000000000052 comment=3e10ef98a38b6301b94c24ead69693ba221e5f7d gear-cronbuild-1.08/000075500000000000000000000000001152773347100143475ustar00rootroot00000000000000gear-cronbuild-1.08/.gear/000075500000000000000000000000001152773347100153435ustar00rootroot00000000000000gear-cronbuild-1.08/.gear/rules000064400000000000000000000000071152773347100164150ustar00rootroot00000000000000tar: . gear-cronbuild-1.08/gear-cronbuild000075500000000000000000000000771152773347100171760ustar00rootroot00000000000000#!/bin/sh -ve gear-cronbuild-apply-hooks gear "$@" gear-commit gear-cronbuild-1.08/gear-cronbuild-apply-hooks000075500000000000000000000040331152773347100214360ustar00rootroot00000000000000#!/bin/sh ############################## ## TODO: PIPESTATUS is bashism ############################## logfile=cronbuild-apply-hooks.log difffile=cronbuild-apply-hooks.diff EXIT_MAGIC_CODE_NOTHING_TO_DO=77 error_hook() { local hook_name="$1"; shift; echo "cronbuild: the hook $hook_name exited ubnormally. see $logfile for details." exit 2 } do_hook() { local hook="$1"; shift; local default_hook="$1"; shift; cronbuild_hook_name=`basename "$hook"` if [ -x "$hook" ]; then echo running "$hook" "$@" "$hook" "$@" 2>&1 | tee -a "$logfile" [ ${PIPESTATUS[0]} -gt 0 ] && error_hook "$hook" else echo running default $cronbuild_hook_name "$default_hook" "$@" $default_hook "$@" 2>&1 | tee -a "$logfile" [ ${PIPESTATUS[0]} -gt 0 ] && error_hook "$default_hook" fi return 0 } missing_hook() { echo "cronbuild: the required hook $cronbuild_hook_name is missing." exit 3 } add_changelog_builtin() { local gear_specfile="$1"; shift; adate=$(date +"%Y%m%d") add_changelog -e "- repocop cronbuild $adate. At your service." $gear_specfile } if ! [ -d .gear ]; then echo ".gear directory not found. exiting." exit 1 fi [ -e "$logfile" ] && rm -f "$logfile" [ -e "$difffile" ] && rm -f "$difffile" gear_specfile="$(gear --command sh -- -c 'printf %s "$gear_specfile"')" if [ -z "$gear_specfile" ] || ! [ -e "$gear_specfile" ]; then echo "cronbuild: can't find spec file. exiting." exit 1 fi last_commit=`git show-ref --head HEAD | awk '{if ($2=="HEAD") print $1;}'` last_commit=${last_commit:=HEAD} do_hook ./.gear/cronbuild-update-source missing_hook $gear_specfile git diff $last_commit > "$difffile" if ! [ -s "$difffile" ]; then echo "INFO: source files did not change after cronbuild-update. Nothing to do."; rm -f "$difffile" exit $EXIT_MAGIC_CODE_NOTHING_TO_DO; fi rm -f "$difffile" do_hook ./.gear/cronbuild-update-version gear-cronbuild-update-spec-timestamp $gear_specfile do_hook ./.gear/cronbuild-add-changelog add_changelog_builtin $gear_specfile git add $gear_specfile gear-cronbuild-1.08/gear-cronbuild-update-spec-timestamp000075500000000000000000000031751152773347100234110ustar00rootroot00000000000000#!/usr/bin/perl -w #use strict; use warnings; use Carp; use Getopt::Long; use File::Basename; use RPM qw/vercmp/; use RPM::Source::Editor; my ($spec); my $verbose=1; my $result = GetOptions ( "verbose+" => \$verbose); $specfile=$ARGV[0]; if (!$specfile) { print "usage:$0 specfile\n"; exit (1); } if (! -e $specfile) { print "ERROR: $specfile does not found\n"; exit (64); } $spec=RPM::Source::Editor->new( SPECFILE=> $specfile, VERBOSE=> $verbose, ); my $mainsec=$spec->get_section('package',''); my $timestamp=`date +"\%Y\%m\%d"`; chomp $timestamp; &update_tag('Release'); &update_tag('Version'); &update_tag('Serial'); &update_tag('Epoch'); sub update_tag{ my $tagname=shift; my $val = $mainsec->get_tag($tagname, RAW=>1); if ($val and $val=~/20[012]\d(?:0[1-9]|1[0-2])[0-3][0-9]/) { $val=~s/20[012]\d(?:0[1-9]|1[0-2])[0-3][0-9]/$timestamp/; print "changed timestamp in tag $tagname\n"; $mainsec->set_tag($tagname, $val); &write_spec_and_exit(); } } if ($mainsec->match(qr'^\%define\s+[\w_]+\s+20[012]\d(?:0[1-9]|1[0-2])[0-3][0-9]\s*$')) { print "changed timestamp in macro definition\n"; $mainsec->subst_if(qr'20[012]\d(?:0[1-9]|1[0-2])[0-3][0-9]',$timestamp, qr'^\%define\s+[\w_]+\s+20[012]\d(?:0[1-9]|1[0-2])[0-3][0-9]\s*$'); &write_spec_and_exit(); }; print "timestamp not found in spec file. exiting.\n"; exit 3; sub write_spec_and_exit { system('mv',$specfile,$specfile.'~')==0 or die "can't backup specfile $specfile"; open SPEC, '>', $specfile or die "can't rewrite specfile $specfile: $!"; print SPEC $spec->get_spec(); close SPEC; exit 0; } gear-cronbuild-1.08/gear-cronbuild.spec000064400000000000000000000032221152773347100201170ustar00rootroot00000000000000Name: gear-cronbuild Version: 1.08 Release: alt0.M51.1 Summary: gear repository automated build utility License: GPL Group: Development/Other Packager: Igor Vlasenko Url: http://www.altlinux.org/Gear/cronbuild BuildArch: noarch Source: %name-%version.tar BuildRequires: perl-RPM-Source-Editor perl-RPM BuildRequires: gear, help2man %description %summary %prep %setup %build #make_build rm gear-cronbuild.spec %install #make_install install DESTDIR=%buildroot install -D -m755 gear-cronbuild %buildroot%_bindir/gear-cronbuild install -D -m755 gear-cronbuild-update-spec-timestamp %buildroot%_bindir/gear-cronbuild-update-spec-timestamp install -D -m755 gear-cronbuild-apply-hooks %buildroot%_bindir/gear-cronbuild-apply-hooks %files %_bindir/* #_mandir/man?/* %changelog * Sat Feb 19 2011 Igor Vlasenko 1.08-alt0.M51.1 - M51 backport * Sat Feb 19 2011 Igor Vlasenko 1.08-alt1 - bugfix release * Wed Feb 16 2011 Igor Vlasenko 1.07-alt1 - bugfix release * Sat Oct 16 2010 Igor Vlasenko 1.06-alt1 - no eval in sh script (thanks to raorn@) * Sat Jul 03 2010 Igor Vlasenko 1.05-alt1 - added proper commit diff * Thu Jul 01 2010 Igor Vlasenko 1.04-alt1 - added nothing-to-do check * Wed Jun 30 2010 Igor Vlasenko 1.03-alt1 - bugfix release * Tue Jun 29 2010 Igor Vlasenko 1.02-alt1 - renamed gear-cronbuild-apply to gear-cronbuild-apply-hooks * Sat Jun 26 2010 Igor Vlasenko 1.01-alt1 - added gear-cronbuild-apply * Thu Jun 24 2010 Igor Vlasenko 1.0-alt1 - first release