Skip to content

Commit

Permalink
Revert "Revert "Rework build system" due to base url bug" (#8)
Browse files Browse the repository at this point in the history
* Revert "Revert "Rework build system" due to base url bug"

* revert github actions to use jekyl-build-pages@v1
  • Loading branch information
kuflierl authored Jun 6, 2024
1 parent 555e1c2 commit b3bb85d
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Check out repository code
uses: actions/checkout@v4
- name: build
run: make
run: make build_hostfiles
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
Expand All @@ -35,7 +35,7 @@ jobs:
path: pages/resources/Hosts
- name: Make Resource List
working-directory: ./pages
run: make
run: make generate
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
Expand Down
40 changes: 29 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# deployment config
project_owner := kuflierl
project_online_home := https://github.com/kuflierl/Blocklists
project_rawonline_root := https://kuflierl.github.io/Blocklists/resources

Expand All @@ -22,11 +23,11 @@ UBLOCK_COMBINELISTS := $(shell find $(COMBINELIST_DIR) -name '*.ublocklist')
DOMAIN_COMBINEFINALS := $(patsubst $(COMBINELIST_DIR)/%,$(BUILD_DIR)/%,$(DOMAIN_COMBINELISTS))

define deploader_template =
$(patsubst $(COMBINELIST_DIR)/%,$(BUILD_DIR)/combineobj/%.deploader,$(1)): $(shell sh $(SRC_DIR)/scripts/getdeps-host.sh $(1))
$(patsubst $(COMBINELIST_DIR)/%,$(BUILD_DIR)/combineobj/%.deploader,$(1)): $(shell sh tools/getdeps-host.sh $(1))
endef

.PHONY: all
all: build_hostfiles
all: build_hostfiles build_site

$(foreach dcl,$(DOMAIN_COMBINELISTS),$(eval $(call deploader_template,$(dcl))))

Expand All @@ -42,18 +43,18 @@ $(BUILD_DIR)/%.host: $(BUILD_DIR)/combineobj/%.host.header $(BUILD_DIR)/combineo
$(BUILD_DIR)/combineobj/%.host.header: $(BUILD_DIR)/combineobj/%.host.o
mkdir -p $(dir $@)
cat $(TEMPLATE_DIR)/host | \
title="$(@F:%.header=%)" \
title="$(project_owner)'s $(@F:%.header=%)" \
update_date="$(update_date)" \
update_url="$(project_rawonline_root)/$(*).host" \
project_home="$(project_online_home)" \
uniq_domains=`cat $< | wc -l` \
envsubst > $@

$(BUILD_DIR)/combineobj/%.host.o: SHELL = /bin/bash
$(BUILD_DIR)/combineobj/%.host.o: $(COMBINELIST_DIR)/%.host $(BUILD_DIR)/combineobj/%.host.deploader
mkdir -p $(dir $@)
touch $@
regex='^domain(black|white)list (text|web)source [\w-]+(\/[\w-]+)*$$'; \
sed '1!G;h;$$!d' "$<" | \
while IFS="" read -r p || [ -n "$$p" ]; \
do \
echo "$$p" | grep -oPq "$$regex" || continue; \
Expand All @@ -63,11 +64,11 @@ $(BUILD_DIR)/combineobj/%.host.o: $(COMBINELIST_DIR)/%.host $(BUILD_DIR)/combine
out="$(BUILD_DIR)/$$p2/$$p3.$$p1.o"; \
if [ "$$p1" = 'domainblacklist' ]; \
then sort -mu $@ $$out > $@.tmp; \
elif [ "$$p1" = 'domainwhitelist' ]; \
then comm -23 $@ $$out > $@.tmp; \
fi; \
mv $@.tmp $@; \
done <<< `sed '1!G;h;$$!d' "$<"`
elif [ "$$p1" = 'domainwhitelist' ]; \
then comm -23 $@ $$out > $@.tmp; \
fi; \
mv $@.tmp $@; \
done
# sed reverses the lines

#todo autogen deploader using eval!!
Expand Down Expand Up @@ -111,12 +112,29 @@ $(BUILD_DIR)/websource/%.domainwhitelist.o: $(BUILD_DIR)/websource-orig/%.domain
mkdir -p $(dir $@)
grep -oP '^[ \t]*\d{1,3}(\.\d{1,3}){3}\K([ \t]+[^#!\/ \t\n]*)+' $< | awk 'OFS="\n" {if($$NF > 0) {$$1=$$1;print $$0}}' | sort -u > $@

.PHONY: generate_site
generate_site: build_hostfiles
mkdir -p pages/resources
cp -r $(BUILD_DIR)/Hosts pages/resources/
make -C pages generate

.PHONY: build_site
build_site: generate_site
make -C pages build

.PHONY: build_hostfiles
build_hostfiles: $(DOMAIN_COMBINEFINALS)

.PHONY: clean_build
clean_build:
rm -rf $(BUILD_DIR)

.PHONY: clean_pages
clean_pages:
make -C pages clean

.PHONY: clean
clean:
rm -r $(BUILD_DIR)
clean: clean_build clean_pages

.PHONY: dumpvar
dumpvar:
Expand Down
1 change: 1 addition & 0 deletions pages/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.3
4 changes: 3 additions & 1 deletion pages/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@ GEM
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (5.0.5)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.8)
strscan (>= 3.0.9)
rouge (4.2.1)
safe_yaml (1.0.5)
sass-embedded (1.69.5-x86_64-linux-gnu)
sass-embedded (1.69.5)
google-protobuf (~> 3.23)
rake (>= 13.0.0)
strscan (3.1.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
Expand Down
42 changes: 37 additions & 5 deletions pages/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
BUILD_DIR := ./_generated
$(BUILD_DIR)/resources.md:
GENERATE_DIR := ./_generated
BUILD_DIR := ./_site

.PHONY: all
all: generate build

.PHONY: generate
generate: $(GENERATE_DIR)/resources.md

.PHONY: build
build: generate install_deps
bundle exec jekyll build

.PHONY: install_deps
install_deps:
bundle install

$(GENERATE_DIR)/resources.md:
mkdir -p _generated
sh _make/generate_resources.sh > $(BUILD_DIR)/resources.md
sh _make/generate_resources.sh > $(GENERATE_DIR)/resources.md

.PHONY: clean_generated
clean_generated:
rm -rf $(GENERATE_DIR)

.PHONY: clean_site
clean_site:
rm -rf $(BUILD_DIR) .jekyll-cache

.PHONY: clean_resources
clean_resources:
rm -rf resources

.PHONY: clean
clean:
rm -r $(BUILD_DIR)
clean: clean_generated clean_site clean_resources

# for development
.PHONY: interactive_serve
interactive_serve:
bundle exec jekyll serve -l
2 changes: 2 additions & 0 deletions pages/_make/generate_resources.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env sh
set -e
[ -d "resources" ] || (echo "find: ‘resources’: No such file or directory" >&2; exit 1)
find resources -mindepth 1 -type d | while read folder; do
echo "$folder" | awk -F "/" '{while (i++ < NF-1) printf "#"; printf " "; print $NF}'
for file in `find "$folder" -maxdepth 1 -type f -printf "%f\n"`; do
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit b3bb85d

Please sign in to comment.