Commit 8dc27ff9 authored by Kevin Atkinson's avatar Kevin Atkinson

Initial implementation of merge-build.

parent bd3210aa
......@@ -117,3 +117,25 @@ check: $(TESTS)
fi \
done
endif
ifeq ($(MERGE_BUILD),1)
.PRECIOUS: ${SRCDIR}/*
#
# I really want to say something like:
# ${TESTBED_SRCDIR}/.merged: $(wildcard ${OBJDIR}/${MERGE_BUILD_SANDBOX}/${SUBDIR}/*)
# but that causes problems if one the prereq. has a rule for it (such
# as when both GNUmakefile and GNUmakefile.in exist in the source tree),
# thus I do the equivalent manually
#
newest=$(shell ls -rtd "${OBJDIR}/${MERGE_BUILD_SANDBOX}/${SUBDIR}/"* "${TESTBED_SRCDIR}/.merged" | tail -n 1)
ifneq ($(newest),${TESTBED_SRCDIR}/.merged)
${TESTBED_SRCDIR}/.merged:
cd ${TESTBED_SRCDIR} && utils/merge-build sync
.PHONY: ${TESTBED_SRCDIR}/.merged
else
${TESTBED_SRCDIR}/.merged:
endif
${SRCDIR}/*: ${TESTBED_SRCDIR}/.merged
endif
......@@ -90,3 +90,6 @@ HAVE_ULXMLRPCPP = @HAVE_ULXMLRPCPP@
STANDALONE_CLEARINGHOUSE = @STANDALONE_CLEARINGHOUSE@
NODE_USAGE_SUPPORT = @NODE_USAGE_SUPPORT@
MERGE_BUILD = @MERGE_BUILD@
MERGE_BUILD_SANDBOX = @MERGE_BUILD_SANDBOX@
......@@ -1496,6 +1496,7 @@ done
#
......@@ -2192,17 +2193,17 @@ for ac_hdr in ulxmlrpcpp/ulxr_config.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:2195: checking for $ac_hdr" >&5
echo "configure:2197: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2200 "configure"
#line 2202 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2205: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2207: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -2241,17 +2242,17 @@ for ac_hdr in linux/videodev.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:2244: checking for $ac_hdr" >&5
echo "configure:2246: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2249 "configure"
#line 2251 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2254: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2256: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -2284,7 +2285,7 @@ done
# Extract the first word of "gtk-config", so it can be a program name with args.
set dummy gtk-config; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:2287: checking for $ac_word" >&5
echo "configure:2289: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_GTK_CONFIG'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -2341,7 +2342,7 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
cross_compiling=$ac_cv_prog_cxx_cross
echo $ac_n "checking how to run the C++ preprocessor""... $ac_c" 1>&6
echo "configure:2344: checking how to run the C++ preprocessor" >&5
echo "configure:2346: checking how to run the C++ preprocessor" >&5
if test -z "$CXXCPP"; then
if eval "test \"`echo '$''{'ac_cv_prog_CXXCPP'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
......@@ -2354,12 +2355,12 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
cross_compiling=$ac_cv_prog_cxx_cross
CXXCPP="${CXX-g++} -E"
cat > conftest.$ac_ext <<EOF
#line 2357 "configure"
#line 2359 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2362: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2364: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
......@@ -2385,17 +2386,17 @@ echo "$ac_t""$CXXCPP" 1>&6
ac_safe=`echo "xercesc/dom/DOM.hpp" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for xercesc/dom/DOM.hpp""... $ac_c" 1>&6
echo "configure:2388: checking for xercesc/dom/DOM.hpp" >&5
echo "configure:2390: checking for xercesc/dom/DOM.hpp" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2393 "configure"
#line 2395 "configure"
#include "confdefs.h"
#include <xercesc/dom/DOM.hpp>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2398: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2400: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -2459,7 +2460,7 @@ fi
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
echo "configure:2462: checking for a BSD compatible install" >&5
echo "configure:2464: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
......@@ -2520,7 +2521,7 @@ esac
# Extract the first word of "rsync", so it can be a program name with args.
set dummy rsync; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:2523: checking for $ac_word" >&5
echo "configure:2525: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_RSYNC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -2563,6 +2564,28 @@ if test "$TBMAINSITE" = 1; then
FANCYBANNER=1
fi
#
# Merge build
#
MERGE_BUILD=0
MERGE_BUILD_SANDBOX=
if test -e "$srcdir/.merge-build"; then
merge_sandbox=`grep source-tree "$srcdir/.merge-build" | cut -d' ' -f2`
merge_tree=`grep merge-tree "$srcdir/.merge-build" | cut -d' ' -f2`
if test "$srcdir" -ef "$srcdir/$merge_tree"; then
MERGE_BUILD=1
MERGE_BUILD_SANDBOX=$srcdir/$merge_sandbox
echo "#/bin/sh" > sync
echo >> sync
echo "cd \"$srcdir\"" >> sync
echo "\"$srcdir/utils/merge-build\" sync" >> sync
chmod +x sync
echo "Merge-build enabled"
fi
fi
outfiles="$outfiles Makeconf GNUmakefile \
assign/GNUmakefile \
named/GNUmakefile firewall/GNUmakefile \
......@@ -3100,6 +3123,8 @@ s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
s%@INSTALL_DATA@%$INSTALL_DATA%g
s%@RSYNC@%$RSYNC%g
s%@MERGE_BUILD@%$MERGE_BUILD%g
s%@MERGE_BUILD_SANDBOX@%$MERGE_BUILD_SANDBOX%g
s%@DISTCLEAN_FILES@%$DISTCLEAN_FILES%g
CEOF
......
......@@ -809,6 +809,28 @@ if test "$TBMAINSITE" = 1; then
FANCYBANNER=1
fi
#
# Merge build
#
MERGE_BUILD=0
MERGE_BUILD_SANDBOX=
if test -e "$srcdir/.merge-build"; then
merge_sandbox=`grep source-tree "$srcdir/.merge-build" | cut -d' ' -f2`
merge_tree=`grep merge-tree "$srcdir/.merge-build" | cut -d' ' -f2`
if test "$srcdir" -ef "$srcdir/$merge_tree"; then
MERGE_BUILD=1
MERGE_BUILD_SANDBOX=$srcdir/$merge_sandbox
echo "#/bin/sh" > sync
echo >> sync
echo "cd \"$srcdir\"" >> sync
echo "\"$srcdir/utils/merge-build\" sync" >> sync
chmod +x sync
echo "Merge-build enabled"
fi
fi
AC_SUBST(MERGE_BUILD)
AC_SUBST(MERGE_BUILD_SANDBOX)
outfiles="$outfiles Makeconf GNUmakefile \
assign/GNUmakefile \
named/GNUmakefile firewall/GNUmakefile \
......
#!/usr/bin/perl
use warnings;
use strict;
sub cd ($) {
print "cd $_[0]\n";
chdir $_[0] or die "Unable to cd to $_[0]\n";
}
sub sys (@) {
print join(' ', @_), "\n";
system @_;
die "ERROR: @_ failed\n" unless $? == 0;
}
sub sysp (@) {
my $cmd = join(' ', @_, '|');
print "$cmd\n";
open F, $cmd or die $!;
local $/ = undef;
my $output = <F>;
close F;
die "ERROR: $cmd faild\n" unless $? == 0;
return $output;
}
sub merge_base(@) {
my $res = shift @_;
while (@_) {
my $other = shift @_;
$res = sysp("git merge-base $res $other");
chomp $res;
}
return $res;
}
sub usage() {
print "usage: merge-build prep|reset|sync\n";
exit(1);
}
open F, ".merge-build" or die "Unable to open .merge-build\n";
my $source_tree;
my $merge_tree;
my @branches;
my $branches_str;
my $merge_branch = "merge";
while (<F>) {
s/#.+//;
next unless /\S/;
my ($key, $value) = /^\s*(\S+)\s+(.+?)\s*$/ or die "Bad Line\n";
if ($key eq 'source-tree') {
$source_tree = $value;
} elsif ($key eq 'merge-tree') {
$merge_tree = $value;
} elsif ($key eq 'branches') {
@branches = split /\s+/, $value;
} elsif ($key eq 'merge-branch') {
$merge_branch = $value;
} else {
die "Unknown key in .merge-build: $key\n";
}
}
sub missing_key($) {die "Missing key in .merge-build: $_[0]\n";}
missing_key('source-tree') unless defined $source_tree;
missing_key('merge-tree') unless defined $merge_tree;
missing_key('branches') unless @branches;
my $branch_str = join ' ', map {"origin/$_"} @branches;
my $op = shift @ARGV || '';
if ($op eq 'prep') {
my $branch_str = join ' ', map {"origin/$_"} @branches;
die "Can't read source tree\n" unless -d $source_tree;
die "Merge tree must not exist\n" if -e $merge_tree;
sys "git clone -sn -b master $source_tree $merge_tree";
cd $merge_tree;
my $base = merge_base $merge_branch, split / /, $branch_str;
sys "git checkout -b $merge_branch $base";
sys "git branch -D master";
sys "ln -s $source_tree/.merge-build";
} elsif ($op eq 'reset') {
cd $merge_tree;
my $base = merge_base $merge_branch, split / /, $branch_str;
sys "git reset --hard $base";
} elsif ($op eq 'sync') {
cd $source_tree;
my $stash_id = sysp "git stash create";
chomp $stash_id;
cd $merge_tree;
sys "git fetch origin";
sys "git reset --hard";
sys "git merge $branch_str";
sys "git stash apply $stash_id | grep -v '^#'"
if $stash_id;
sys "touch .merged";
} else {
usage();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment