/testsuite/xattrs-hlink.test
/patches
/SaVeDiR
-/.gen-stash
+/build
.deps
aclocal -I $(srcdir)/m4
configure.sh config.h.in: configure.ac aclocal.m4
- @test -f "$(srcdir)/configure.sh" && cp -p "$(srcdir)/configure.sh" configure.sh.old || touch configure.sh.old
- @test -f "$(srcdir)/config.h.in" && cp -p "$(srcdir)/config.h.in" config.h.in.old || touch config.h.in.old
- (cd "$(srcdir)" && autoconf -o configure.sh && autoheader && touch config.h.in)
- @if diff "$(srcdir)/configure.sh" configure.sh.old >/dev/null 2>&1; then \
+ @if test -f configure.sh; then cp -p configure.sh configure.sh.old; else touch configure.sh.old; fi
+ @if test -f config.h.in; then cp -p config.h.in config.h.in.old; else touch config.h.in.old; fi
+ autoconf -o configure.sh
+ autoheader && touch config.h.in
+ @if diff configure.sh configure.sh.old >/dev/null 2>&1; then \
echo "configure.sh is unchanged."; \
rm configure.sh.old; \
else \
echo "configure.sh has CHANGED."; \
fi
- @if diff "$(srcdir)/config.h.in" config.h.in.old >/dev/null 2>&1; then \
+ @if diff config.h.in config.h.in.old >/dev/null 2>&1; then \
echo "config.h.in is unchanged."; \
rm config.h.in.old; \
else \
# then transfer control to the configure.sh script to do the real work.
dir=`dirname $0`
-realconfigure="$dir/configure.sh"
-if test ! -f "$realconfigure"; then
- if test -f "$HOME/build_farm/build_test.fns"; then
- # Test the included popt
- set -- --with-included-popt "${@}"
- # Allow the build farm to grab latest files via rsync.
- actions='build fetch'
- else
- actions='build'
- fi
- if "$dir/prepare-source" $actions; then
- :
- else
+# Support automatic switching to build/$BRANCH subdirs. It's also good
+# to put packaging/make somewhere early in your $PATH if you use this!
+if test "$dir" = '.' -a ! -f Makefile -a -d build/master -a -d .git; then
+ builddir=build/`git rev-parse --abbrev-ref HEAD | tr / %`
+ test -d "$builddir" || mkdir "$builddir"
+ cd "$builddir" || exit 1
+ dir=../..
+fi
+
+if test ! -f configure.sh; then
+ if ! "$dir/prepare-source" build; then
echo 'Failed to build configure.sh and/or config.h.in -- giving up.' >&2
- rm -f "$realconfigure"
+ rm -f configure.sh
exit 1
fi
fi
-exec "$realconfigure" "${@}"
+exec ./configure.sh --srcdir="$dir" "${@}"
--- /dev/null
+#!/bin/sh
+
+# You can put this script early on your PATH to support a top-dir "make"
+# changing into a per-branch build dir before running the make. Just start
+# with a pristine top dir (e.g. run "make distclean") and then create the dir
+# "build/master", at which point you can stay in the top dir of the source and
+# run "./configure" and "make" commands and have the appropriate build dir be
+# automatically used (the non-master subdirs will be auto-created).
+
+if [ ! -f Makefile -a -d build/master -a -d .git -a x"$1" != x-* ]; then
+ builddir=build/`git rev-parse --abbrev-ref HEAD | tr / %`
+ [ -d "$builddir" ] || mkdir "$builddir"
+ # Let make do a noisy chdir so that a calling editor knows where the files are.
+ set -- -C "$builddir" ${1+"$@"}
+fi
+
+export PATH="/usr/lib/ccache:$PATH"
+exec /usr/bin/make ${1+"$@"}
from pkglib import *
MAKE_GEN_CMDS = [
- 'make -f prepare-source.mak conf'.split(),
- './config.status'.split(),
- 'make gen'.split(),
+ './prepare-source'.split(),
+ 'make restatus gen'.split(),
]
TMP_DIR = "patches.gen"
starting_branch, args.base_branch = check_git_state(args.base_branch, not args.skip_check, args.patches_dir)
- if not os.path.isdir('.gen-stash'):
- os.mkdir('.gen-stash', 0o700)
- gen_stash(starting_branch)
- if starting_branch == 'master':
- cmd_chk('md5sum configure.ac >.gen-stash/configure.ac.sum')
-
master_commit = latest_git_hash(args.base_branch)
if args.gen:
time.sleep(1)
cmd_chk(['git', 'checkout', starting_branch])
- gen_unstash(starting_branch)
-
def update_patch(patch):
global last_touch
s = cmd_run(['git', 'merge', based_on])
ok = s.returncode == 0
if not ok or args.shell:
- gen_unstash(branch)
m = re.search(r'([^/]+)$', parent)
parent_dir = m[1]
if not ok:
if is_clean:
break
print(status_txt, end='')
- gen_stash(branch)
with open(f"{args.patches_dir}/{patch}.diff", 'w', encoding='utf-8') as fh:
fh.write(description[patch])
return 1
-# The autoconf cache dir can totally mess up if 2 different *.ac files have the same mtime!
-def gen_stash_prep(branch):
- if os.path.isdir('autom4te.cache'):
- shutil.rmtree('autom4te.cache')
- return '.gen-stash/' + branch.replace('/', '%') + '.tar.gz'
-
-
-def gen_stash(branch):
- files = 'configure.sh config.h.in Makefile'.split()
- for fn in files:
- if not os.path.exists(fn):
- return
- tar_fn = gen_stash_prep(branch)
- cmd_run(['./prepare-source'])
- cmd_chk(['tar', 'czf', tar_fn, *files])
-
-
-def gen_unstash(branch):
- tar_fn = gen_stash_prep(branch)
- if os.path.exists(tar_fn):
- cmd_chk(['tar', 'xf', tar_fn])
- out, rc = cmd_txt_status('md5sum --status -c .gen-stash/configure.ac.sum'.split())
- if rc:
- print('*' * 10, "configure.ac differs from master version", '*' * 10)
-
-
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Turn a git branch back into a diff files in the patches dir.", add_help=False)
parser.add_argument('--branch', '-b', dest='base_branch', metavar='BASE_BRANCH', default='master', help="The branch the patch is based on. Default: master.")
# Snag the GENFILES values out of the Makefile.in file and return them as a list.
-def get_gen_files():
+def get_gen_files(want_dir_plus_list=False):
cont_re = re.compile(r'\\\n')
- extras = [ ]
+ gen_files = [ ]
+
+ builddir = os.path.join('build', cmd_txt('git rev-parse --abbrev-ref HEAD').replace('/', '%'))
with open('Makefile.in', 'r', encoding='utf-8') as fh:
for line in fh:
- if not extras:
+ if not gen_files:
chk = re.sub(r'^GENFILES=', '', line)
if line == chk:
continue
line = chk
m = re.search(r'\\$', line)
line = re.sub(r'^\s+|\s*\\\n?$|\s+$', '', line)
- extras += line.split()
+ gen_files += line.split()
if not m:
break
- return extras
+ if want_dir_plus_list:
+ return (builddir, gen_files)
+
+ return [ os.path.join(builddir, fn) for fn in gen_files ]
def get_configure_version():
signal.signal(signal.SIGINT, signal_handler)
- gen_files = get_gen_files()
+ builddir, gen_files = get_gen_files(True)
+ gen_pathnames = [ os.path.join(builddir, fn) for fn in gen_files ]
dash_line = '=' * 74
srctar_name = f"{rsync_ver}.tar.gz"
pattar_name = f"rsync-patches-{version}.tar.gz"
diff_name = f"{rsync_lastver}-{version}.diffs.gz"
- srctar_file = f"{dest}/{srcdir}/{srctar_name}"
- pattar_file = f"{dest}/{srcdir}/{pattar_name}"
- diff_file = f"{dest}/{srcdiffdir}/{diff_name}"
- lasttar_file = f"{dest}/{lastsrcdir}/{rsync_lastver}.tar.gz"
+ srctar_file = os.path.join(dest, srcdir, srctar_name)
+ pattar_file = os.path.join(dest, srcdir, pattar_name)
+ diff_file = os.path.join(dest, srcdiffdir, diff_name)
+ lasttar_file = os.path.join(dest, lastsrcdir, rsync_lastver + '.tar.gz')
print(f"""\
{dash_line}
die('Aborting')
cmd_chk('make gen')
- cmd_chk(['rsync', '-a', *gen_files, 'SaVeDiR/'])
+ cmd_chk(['rsync', '-a', *gen_pathnames, 'SaVeDiR/'])
print(f'Creating any missing patch branches.')
s = cmd_run(f'packaging/branch-from-patch --branch={args.master_branch} --add-missing')
os.environ['PATH'] = ORIGINAL_PATH
# Extract the generated files from the old tar.
- tweaked_gen_files = [ f"{rsync_lastver}/{x}" for x in gen_files ]
+ tweaked_gen_files = [ os.path.join(rsync_lastver, fn) for fn in gen_files ]
cmd_run(['tar', 'xzf', lasttar_file, *tweaked_gen_files])
os.rename(rsync_lastver, 'a')
print(f"Creating {diff_file} ...")
- cmd_chk(['rsync', '-a', *gen_files, 'b/'])
+ cmd_chk(['rsync', '-a', *gen_pathnames, 'b/'])
sed_script = r's:^((---|\+\+\+) [ab]/[^\t]+)\t.*:\1:' # CAUTION: must not contain any single quotes!
cmd_chk(f"(git diff v{lastversion} {v_ver} -- ':!.github'; diff -upN a b | sed -r '{sed_script}') | gzip -9 >{diff_file}")
print(f"Updating the other files in {dest} ...")
md_files = 'README.md NEWS.md'.split()
- html_files = [ fn for fn in gen_files if fn.endswith('.html') ]
+ html_files = [ fn for fn in gen_pathnames if fn.endswith('.html') ]
cmd_chk(['rsync', '-a', *md_files, *html_files, dest])
cmd_chk(["packaging/md2html"] + [ dest +'/'+ fn for fn in md_files ])
dir=.
fi
+# Support automatic switching to build/$BRANCH subdirs. It's also good
+# to put packaging/make somewhere early in your $PATH if you use this!
+if test "$dir" = . -a ! -f Makefile -a -d build/master -a -d .git; then
+ builddir=build/`git rev-parse --abbrev-ref HEAD | tr / %`
+ test -d "$builddir" || mkdir "$builddir"
+ cd "$builddir" || exit 1
+ dir=../..
+fi
+
+if test "$dir" != '.'; then
+ for lnk in configure.ac m4; do
+ if test ! -h $lnk; then
+ rm -f $lnk # Just in case
+ ln -s "$dir/$lnk" $lnk
+ fi
+ done
+ for fn in configure.sh config.h.in aclocal.m4; do
+ test ! -f $fn -a -f "$dir/$fn" && cp -p "$dir/$fn" $fn
+ done
+fi
+
if test $# = 0; then
set -- build
fi
for action in "${@}"; do
case "$action" in
build|make)
- (cd $dir && make -f prepare-source.mak)
+ make -f "$dir/prepare-source.mak"
;;
fetch|fetchgen)
- $dir/rsync-ssl -iip --no-motd rsync://download.samba.org/rsyncftp/generated-files/'[ca]*' $dir
if test "$action" = fetchgen; then
- $dir/rsync-ssl -iip --no-motd rsync://download.samba.org/rsyncftp/generated-files/'[^ca]*' .
+ match='*'
+ else
+ match='[ca]*'
fi
+ $dir/rsync-ssl -iipc --no-motd "rsync://download.samba.org/rsyncftp/generated-files/$match" ./
+ test $? != 0 && continue
sleep 1 # The following files need to be newer than aclocal.m4
touch configure.sh config.h.in
;;
*)
echo "Unknown action: $action"
exit 1
+ ;;
esac
if test $? = 0; then
exit
+SHELL=/bin/sh
+
+.PHONY: conf
conf: configure.sh config.h.in
aclocal.m4: m4/*.m4
makepath "$fromdir/foo"
makepath "$fromdir/bar/baz"
cp -p "$srcdir/configure.ac" "$fromdir/foo/config1"
-cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
+cp -p "$srcdir/config.sub" "$fromdir/foo/config2"
cp -p "$srcdir/rsync.h" "$fromdir/bar/baz/rsync"
chmod 600 "$fromdir"/foo/config? "$fromdir/bar/baz/rsync"
umask 0
umask 0
ln -s ../bar/baz "$todir/foo/sym"
umask 022
-cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
+cp -p "$srcdir/config.sub" "$fromdir/foo/config2"
chmod 600 "$fromdir/foo/config2"
chmod 777 "$todir/bar/baz/rsync"