Skip to content

Commit 7039d14

Browse files
committed
Improve the per-branch build dir support
The release script & the patch management script now require the use of an auto-build-save dir that makes it much easier to keep the generated files from melding together, and remembers the configure setup for each patch branch.
1 parent ec3c9f2 commit 7039d14

10 files changed

+101
-64
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ aclocal.m4
4848
/testsuite/devices-fake.test
4949
/testsuite/xattrs-hlink.test
5050
/patches
51-
/SaVeDiR
51+
/patches.gen
5252
/build
53+
/auto-build-save
5354
.deps

NEWS.md

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ Protocol: 31 (unchanged)
5353
checksum routines. Just make sure that the new rsync package depends on
5454
xxhash >= 0.8.0.
5555

56+
### DEVELOPER RELATED:
57+
58+
- Moved the version number out of configure.ac into its own version.h file so
59+
that we don't need to reconfigure just because the version number changes.
60+
5661
------------------------------------------------------------------------------
5762
<a name="3.2.1"></a>
5863

configure

+9-7
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
# then transfer control to the configure.sh script to do the real work.
55

66
dir=`dirname $0`
7+
if test x"$dir" = x; then
8+
dir=.
9+
fi
710

8-
# Support automatic switching to build/$BRANCH subdirs. It's also good
9-
# to put packaging/make somewhere early in your $PATH if you use this!
10-
if test "$dir" = '.' -a ! -f Makefile -a -d build/master -a -d .git; then
11-
builddir=build/`git rev-parse --abbrev-ref HEAD | tr / %`
12-
test -d "$builddir" || mkdir "$builddir"
13-
cd "$builddir" || exit 1
14-
dir=../..
11+
if test "$dir" = '.'; then
12+
branch=`packaging/prep-auto-dir` || exit 1
13+
if test x"$branch" != x; then
14+
cd build || exit 1
15+
dir=..
16+
fi
1517
fi
1618

1719
if test ! -f configure.sh; then

packaging/auto-Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
TARGETS := all install install-ssl-daemon install-all install-strip conf gen gensend reconfigure restatus \
2+
proto man clean cleantests distclean test check check29 check30 installcheck splint doxygen doxygen-upload
3+
4+
.PHONY: $(TARGETS)
5+
6+
$(TARGETS):
7+
@if test x`packaging/prep-auto-dir` = x; then echo "auto-build-save is not setup"; exit 1; fi
8+
make -C build $@

packaging/make

-18
This file was deleted.

packaging/patch-update

+12-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ from pkglib import *
1414

1515
MAKE_GEN_CMDS = [
1616
'./prepare-source'.split(),
17-
'make restatus gen'.split(),
17+
'cd build && if test -f config.status ; then ./config.status ; else ../configure ; fi',
18+
'make -C build gen'.split(),
1819
]
1920
TMP_DIR = "patches.gen"
2021

@@ -32,6 +33,9 @@ def main():
3233

3334
master_commit = latest_git_hash(args.base_branch)
3435

36+
if cmd_txt_chk(['packaging/prep-auto-dir']) == '':
37+
die('You must setup an auto-build-save dir to use this script.')
38+
3539
if args.gen:
3640
if os.path.lexists(TMP_DIR):
3741
die(f'"{TMP_DIR}" must not exist in the current directory.')
@@ -41,7 +45,7 @@ def main():
4145
cmd_chk(cmd)
4246
cmd_chk(['rsync', '-a', *gen_files, f'{TMP_DIR}/master/'])
4347

44-
last_touch = time.time()
48+
last_touch = int(time.time())
4549

4650
# Start by finding all patches so that we can load all possible parents.
4751
patches = sorted(list(get_patch_branches(args.base_branch)))
@@ -90,9 +94,10 @@ def main():
9094
if args.gen:
9195
shutil.rmtree(TMP_DIR)
9296

93-
while last_touch >= time.time():
97+
while last_touch >= int(time.time()):
9498
time.sleep(1)
9599
cmd_chk(['git', 'checkout', starting_branch])
100+
cmd_chk(['packaging/prep-auto-dir'], discard='output')
96101

97102

98103
def update_patch(patch):
@@ -112,7 +117,7 @@ def update_patch(patch):
112117

113118
print(f"======== {patch} ========")
114119

115-
while args.gen and last_touch >= time.time():
120+
while args.gen and last_touch >= int(time.time()):
116121
time.sleep(1)
117122

118123
branch = f"patch/{args.base_branch}/{patch}"
@@ -123,6 +128,7 @@ def update_patch(patch):
123128
s = cmd_run(['git', 'merge', based_on])
124129
ok = s.returncode == 0
125130
if not ok or args.shell:
131+
cmd_chk(['packaging/prep-auto-dir'], discard='output')
126132
m = re.search(r'([^/]+)$', parent)
127133
parent_dir = m[1]
128134
if not ok:
@@ -139,6 +145,7 @@ def update_patch(patch):
139145
if is_clean:
140146
break
141147
print(status_txt, end='')
148+
cmd_run('rm -f build/*.o build/*/*.o')
142149

143150
with open(f"{args.patches_dir}/{patch}.diff", 'w', encoding='utf-8') as fh:
144151
fh.write(description[patch])
@@ -151,7 +158,7 @@ def update_patch(patch):
151158
cmd_chk(['rsync', '-a', *gen_files, f"{TMP_DIR}/{patch}/"])
152159
else:
153160
gen_files = [ ]
154-
last_touch = time.time()
161+
last_touch = int(time.time())
155162

156163
proc = cmd_pipe(['git', 'diff', based_on])
157164
skipping = False

packaging/pkglib.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def get_gen_files(want_dir_plus_list=False):
186186

187187
gen_files = [ ]
188188

189-
builddir = os.path.join('build', cmd_txt('git rev-parse --abbrev-ref HEAD').replace('/', '%'))
189+
auto_dir = os.path.join('auto-build-save', cmd_txt('git rev-parse --abbrev-ref HEAD').strip().replace('/', '%'))
190190

191191
with open('Makefile.in', 'r', encoding='utf-8') as fh:
192192
for line in fh:
@@ -202,18 +202,18 @@ def get_gen_files(want_dir_plus_list=False):
202202
break
203203

204204
if want_dir_plus_list:
205-
return (builddir, gen_files)
205+
return (auto_dir, gen_files)
206206

207-
return [ os.path.join(builddir, fn) for fn in gen_files ]
207+
return [ os.path.join(auto_dir, fn) for fn in gen_files ]
208208

209209

210-
def get_configure_version():
211-
with open('configure.ac', 'r', encoding='utf-8') as fh:
212-
for line in fh:
213-
m = re.match(r'^AC_INIT\(\[rsync\],\s*\[(\d.+?)\]', line)
214-
if m:
215-
return m[1]
216-
die("Unable to find AC_INIT with version in configure.ac")
210+
def get_rsync_version():
211+
with open('version.h', 'r', encoding='utf-8') as fh:
212+
txt = fh.read()
213+
m = re.match(r'^#define\s+RSYNC_VERSION\s+"(\d.+?)"', txt)
214+
if m:
215+
return m[1]
216+
die("Unable to find RSYNC_VERSION define in version.h")
217217

218218

219219
def get_NEWS_version_info():

packaging/prep-auto-dir

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh -e
2+
3+
# This script will setup the build dir based on the current git branch and the
4+
# directory auto-build-save/$BRANCH. We don't use a symlink for the build dir
5+
# because we want to maximize the ccache reuse, so all builds must happen in
6+
# the same real dir. When a dir is moved out of auto-build-save/$BRANCH to the
7+
# build dir, it is replaced with a symlink so that it can still be found under
8+
# that dir. The build dir also gets a .branch -> $BRANCH symlink so that we
9+
# can figure out the current build dir's branch.
10+
11+
# To get started, just clone the rsync git repo and create the auto-build-save
12+
# dir. If you have an existing git checkout and it is not in a pristine state,
13+
# run "make distclean" before creating the auto-build-save dir.
14+
15+
auto_top='auto-build-save'
16+
if test -d $auto_top -a -d .git; then
17+
desired_branch=`git rev-parse --abbrev-ref HEAD | tr / %`
18+
auto_dir="$auto_top/$desired_branch"
19+
if test -d build; then
20+
cur_branch=`readlink build/.branch`
21+
else
22+
cur_branch='/'
23+
fi
24+
if test "$desired_branch" != "$cur_branch"; then
25+
if test "$cur_branch" != /; then
26+
rm -f "$auto_top/$cur_branch"
27+
mv build "$auto_top/$cur_branch"
28+
fi
29+
test -d "$auto_dir" || mkdir "$auto_dir"
30+
test -h "$auto_dir/.branch" || ln -s "$desired_branch" "$auto_dir/.branch"
31+
mv "$auto_dir" build
32+
ln -s ../build "$auto_dir"
33+
fi
34+
if test ! -h Makefile; then
35+
rm -f Makefile
36+
ln -s packaging/auto-Makefile Makefile
37+
fi
38+
echo $desired_branch
39+
fi

packaging/release-rsync

+10-16
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ def main():
3030

3131
signal.signal(signal.SIGINT, signal_handler)
3232

33-
builddir, gen_files = get_gen_files(True)
34-
gen_pathnames = [ os.path.join(builddir, fn) for fn in gen_files ]
33+
if cmd_txt_chk(['packaging/prep-auto-dir']) == '':
34+
die('You must setup an auto-build-save dir to use this script.');
35+
36+
auto_dir, gen_files = get_gen_files(True)
37+
gen_pathnames = [ os.path.join(auto_dir, fn) for fn in gen_files ]
3538

3639
dash_line = '=' * 74
3740

@@ -54,13 +57,13 @@ def main():
5457

5558
check_git_state(args.master_branch, True, 'patches')
5659

57-
confversion = get_configure_version()
60+
curversion = get_rsync_version()
5861

5962
# All version values are strings!
6063
lastversion, last_protocol_version = get_NEWS_version_info()
6164
protocol_version, subprotocol_version = get_protocol_versions()
6265

63-
version = confversion
66+
version = curversion
6467
m = re.search(r'pre(\d+)', version)
6568
if m:
6669
version = re.sub(r'pre\d+', 'pre' + str(int(m[1]) + 1), version)
@@ -90,8 +93,8 @@ def main():
9093
cmd_chk(['git', 'tag', '-d', v_ver])
9194

9295
version = re.sub(r'[-.]*pre[-.]*', 'pre', version)
93-
if 'pre' in version and not confversion.endswith('dev'):
94-
lastversion = confversion
96+
if 'pre' in version and not curversion.endswith('dev'):
97+
lastversion = curversion
9598

9699
ans = input(f"Enter the previous version to produce a patch against: [{lastversion}] ")
97100
if ans != '':
@@ -177,7 +180,7 @@ About to:
177180
with open(fn, 'r', encoding='utf-8') as fh:
178181
old_txt = txt = fh.read()
179182
if fn == 'version.h':
180-
txt = f"#define RSYNC_VERSION {version}\n"
183+
txt = f'#define RSYNC_VERSION "{version}"\n'
181184
elif '.spec' in fn:
182185
for var, val in specvars.items():
183186
x_re = re.compile(r'^%s .*' % re.escape(var), re.M)
@@ -238,7 +241,6 @@ About to:
238241
die('Aborting')
239242

240243
cmd_chk('make gen')
241-
cmd_chk(['rsync', '-a', *gen_pathnames, 'SaVeDiR/'])
242244

243245
print(f'Creating any missing patch branches.')
244246
s = cmd_run(f'packaging/branch-from-patch --branch={args.master_branch} --add-missing')
@@ -254,9 +256,6 @@ About to:
254256
print(f'\nVisiting all "patch/{args.master_branch}/*" branches ...')
255257
cmd_run(f"packaging/patch-update --branch={args.master_branch} --skip-check --shell")
256258

257-
cmd_run("rm -f *.[o15] *.html")
258-
cmd_chk('rsync -a SaVeDiR/ .'.split())
259-
260259
if os.path.isdir('patches/.git'):
261260
s = cmd_run(f"cd patches && git commit -a -m 'The patches for {version}.'")
262261
if s.returncode:
@@ -318,11 +317,6 @@ About to:
318317
os.mkdir(f"{rsync_ver}/patches", 0o755)
319318
cmd_chk(f"packaging/patch-update --skip-check --branch={args.master_branch} --gen={rsync_ver}/patches".split())
320319

321-
cmd_run("rm -f *.[o15] *.html")
322-
cmd_chk('rsync -a SaVeDiR/ .'.split())
323-
shutil.rmtree('SaVeDiR')
324-
cmd_chk('make gen'.split())
325-
326320
print(f"Creating {pattar_file} ...")
327321
cmd_chk(['fakeroot', 'tar', 'chzf', pattar_file, rsync_ver + '/patches'])
328322
shutil.rmtree(rsync_ver)

prepare-source

+6-7
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ if test x"$dir" = x; then
1616
dir=.
1717
fi
1818

19-
# Support automatic switching to build/$BRANCH subdirs. It's also good
20-
# to put packaging/make somewhere early in your $PATH if you use this!
21-
if test "$dir" = . -a ! -f Makefile -a -d build/master -a -d .git; then
22-
builddir=build/`git rev-parse --abbrev-ref HEAD | tr / %`
23-
test -d "$builddir" || mkdir "$builddir"
24-
cd "$builddir" || exit 1
25-
dir=../..
19+
if test "$dir" = '.'; then
20+
branch=`packaging/prep-auto-dir` || exit 1
21+
if test x"$branch" != x; then
22+
cd build || exit 1
23+
dir=..
24+
fi
2625
fi
2726

2827
if test "$dir" != '.'; then

0 commit comments

Comments
 (0)