Skip to content

Commit 9542428

Browse files
committed
Makefile: use sed, instead of uniq for index
1 parent 80a9661 commit 9542428

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

Makefile

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ build: patch-super fetch
7070
dist-zip: default
7171
@echo "Zip compress generated cores"
7272
@cd ./dist/$(PLATFORM); \
73-
for f in *.so; \
74-
do [ -f "$$f" ] && \
73+
for f in *.so; do \
74+
[ -f "$$f" ] && \
7575
zip -m "$$f.zip" "$$f"; \
7676
done
7777

@@ -80,29 +80,36 @@ index:
8080
$(call print_error, The "dist/$(PLATFORM)" dir has no ZIP'ed cores -> run 'make dist-zip'); \
8181
exit 1 ;\
8282
fi
83-
@echo "Update \"cores_list\" in .index-extended"
83+
@echo "Updating \"cores_list\" in ./$(INDEX)"
84+
@echo ""
8485
@cd ./dist/$(PLATFORM); \
85-
for f in *.zip; \
86-
do [ -f "$$f" ] && \
87-
echo "$$(stat -c '%y' $$f | cut -f 1 -d ' ') $$(crc32 $$f) $$f" | tee -a .core-updater-list; \
88-
done
89-
@cat ./dist/$(PLATFORM)/.core-updater-list >> $(INDEX)
90-
@rm ./dist/$(PLATFORM)/.core-updater-list
91-
@sort -r --key=1,1 --key=3,3 $(INDEX) -o $(INDEX); \
92-
uniq --skip-fields=2 $(INDEX) /tmp/index.temp && \
93-
mv /tmp/index.temp $(INDEX);
94-
@sort -r --key=3,3 $(INDEX) -o $(INDEX); \
95-
uniq --skip-fields=2 $(INDEX) /tmp/index.temp && \
96-
mv /tmp/index.temp $(INDEX);
97-
sort -k3,3 $(INDEX) -o $(INDEX)
86+
new_index=false; \
87+
for f in *.zip; do \
88+
if grep -q "$$f" $(WORKDIR)/$(INDEX); then \
89+
echo "Found existing core $$f pkg, updating index"; \
90+
INDEX_FILE="$$(stat -c '%y' $$f | cut -f 1 -d ' ') $$(crc32 $$f) $$f"; \
91+
sed -i "s:.*$$f.*:$$INDEX_FILE:" $(WORKDIR)/$(INDEX); \
92+
echo $$INDEX_FILE; \
93+
INDEX_FILE=""; \
94+
else \
95+
echo "Found new core $$f pkg, adding to index"; \
96+
echo "$$(stat -c '%y' $$f | cut -f 1 -d ' ') $$(crc32 $$f) $$f" | tee -a $(WORKDIR)/$(INDEX); \
97+
new_index=true; \
98+
fi; \
99+
done; \
100+
echo ""; \
101+
if $$new_index; then \
102+
echo "Sorting idex file, with new cores."; \
103+
sort -k3,3 $(WORKDIR)/$(INDEX) -o $(WORKDIR)/$(INDEX); \
104+
fi
98105

99106
index-rebuild:
100-
@echo "Update \"cores_list\" in .index-extended"
107+
@echo "Rebuilding \"cores_list\" in ./$(INDEX)"
101108
@cd cores/$(target_libc)/latest; \
102-
rm -f .index-extended; \
103-
for f in *; \
104-
do [ -f "$$f" ] && \
105-
echo "$$(stat -c '%y' $$f | cut -f 1 -d ' ') $$(crc32 $$f) $$f" | tee -a .index-extended; \
109+
rm -f $(WORKDIR)/$(INDEX); \
110+
for f in *; do \
111+
[ -f "$$f" ] && \
112+
echo "$$(stat -c '%y' $$f | cut -f 1 -d ' ') $$(crc32 $$f) $$f" | tee -a $(WORKDIR)/$(INDEX); \
106113
done
107114

108115
release: dist-zip index

0 commit comments

Comments
 (0)