Skip to content

Commit f0bc2aa

Browse files
Fix a few warts with the duckdb module patching approach
This uses `git apply` to apply the changes directly, as well as is a bit smarter about ensuring that we don't re-apply patches multiple times, which can lead to compile errors. Since the logic is the same, we also remove some of the duplication here. Signed-off-by: David Christensen <[email protected]>
1 parent fa0a562 commit f0bc2aa

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ delete_old_cluster.sh
4040
**/isolation/isolation.conf
4141
pg_lake_iceberg/logs/polaris.log
4242
.volume/
43-
Dockerfile.alpine
43+
Dockerfile.alpine
44+
/duckdb_pglake/.patches_applied

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ install-duckdb_pglake: duckdb_pglake
165165
$(MAKE) -C duckdb_pglake install; \
166166
fi
167167

168-
pgduck_server: duckdb_pglake
168+
pgduck_server: install-duckdb_pglake
169169
$(MAKE) -C pgduck_server
170170

171-
install-pgduck_server: install-duckdb_pglake pgduck_server
171+
install-pgduck_server: pgduck_server
172172
$(MAKE) -C pgduck_server install
173173

174174
## Overridden targets; basically the ones in CUSTOM_TARGETS above

duckdb_pglake/Makefile

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,23 +132,23 @@ release: patch_duckdb
132132

133133
#### Misc
134134

135-
# patch exit code 1 means the patch is already applied, since we might run this multiple times, be robust
136-
patch_duckdb:
137-
cd duckdb && \
138-
find ../patches/duckdb -type f -name '*.patch' -print | xargs -0 printf '%s ' | \
139-
while read -r patch; do \
140-
patch -l -p1 -N < "$$patch" || [ $$? -eq 1 ]; \
141-
done
142-
cd duckdb-postgres && \
143-
find ../patches/duckdb-postgres -type f -name '*.patch' -print | xargs -0 printf '%s ' | \
144-
while read -r patch; do \
145-
patch -l -p1 -N < "$$patch" || [ $$? -eq 1 ]; \
146-
done
147-
cd duckdb-azure && \
148-
find ../patches/duckdb-azure -type f -name '*.patch' -print | xargs -0 printf '%s ' | \
149-
while read -r patch; do \
150-
patch -l -p1 -N < "$$patch" || [ $$? -eq 1 ]; \
135+
# we assume that any modified files in these subdirs indicate that we have
136+
# already been patched. This does mean if you have updated updating the patches here you
137+
# will need to reset the repositories so the new patches will be picked up.
138+
139+
.patches_applied: $(shell find patches -type f -name '*.patch')
140+
for patchdir in duckdb duckdb-postgres duckdb-azure; do \
141+
(cd $$patchdir && \
142+
git checkout -f . && \
143+
find ../patches/$$patchdir -type f -name '*.patch' -print | sort | xargs -0 printf '%s ' | \
144+
while read -r patch; do \
145+
echo "applying $$patch to $$patchdir" ; \
146+
git apply --ignore-whitespace "$$patch"; \
147+
done;) \
151148
done
149+
touch .patches_applied
150+
151+
patch_duckdb: .patches_applied
152152

153153
format:
154154
find src/ -iname *.hpp -o -iname *.cpp | xargs clang-format --sort-includes=0 -style=file -i

0 commit comments

Comments
 (0)