mirror of
https://github.com/hectorm/hblock.git
synced 2026-04-21 22:46:32 +05:30
Add Makefile
This commit is contained in:
parent
312b3dcf74
commit
2dc64c7fa1
3 changed files with 56 additions and 26 deletions
|
|
@ -2,32 +2,8 @@ image: alpine
|
|||
|
||||
pages:
|
||||
script:
|
||||
# Install required packages
|
||||
- apk add --no-cache curl file gawk grep libidn sed zip
|
||||
# Create public folder
|
||||
- mkdir ./public
|
||||
# Create hosts file
|
||||
- sh ./hblock -O ./public/hosts
|
||||
# Create a gzipped version of hosts file
|
||||
- gzip -c ./public/hosts > ./public/hosts.gz
|
||||
# Create Android installer
|
||||
- mkdir /tmp/hosts_android
|
||||
- cp -r ./resources/android/* ./public/hosts /tmp/hosts_android
|
||||
- cd /tmp/hosts_android
|
||||
- zip -r "$CI_PROJECT_DIR"/public/hosts_android.zip ./
|
||||
- cd "$CI_PROJECT_DIR"
|
||||
# Create Windows installer
|
||||
- mkdir /tmp/hosts_windows
|
||||
- cp -r ./resources/windows/* ./public/hosts /tmp/hosts_windows
|
||||
- cd /tmp/hosts_windows
|
||||
- unix2dos ./install.bat ./hosts
|
||||
- zip -r "$CI_PROJECT_DIR"/public/hosts_windows.zip ./
|
||||
- cd "$CI_PROJECT_DIR"
|
||||
# Create stats files
|
||||
- ./resources/stats/suffix.sh ./public/hosts none > ./public/most_abused_tlds.txt
|
||||
- ./resources/stats/suffix.sh ./public/hosts > ./public/most_abused_suffixes.txt
|
||||
# Create HTML index
|
||||
- ./resources/template/index.sh ./public > ./public/index.html
|
||||
- apk add --no-cache curl file gawk grep libidn make sed zip
|
||||
- make all
|
||||
artifacts:
|
||||
paths:
|
||||
- public
|
||||
|
|
|
|||
54
Makefile
Executable file
54
Makefile
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/make -f
|
||||
|
||||
RESOURCES_DIR:=$(CURDIR)/resources
|
||||
PUBLIC_DIR:=$(CURDIR)/public
|
||||
TEMP_DIR:=$(shell mktemp -dt 'hblock.XXXXXXXX')
|
||||
|
||||
HBLOCK_SCRIPT:=$(CURDIR)/hblock
|
||||
STATS_SCRIPT:=$(RESOURCES_DIR)/stats/suffix.sh
|
||||
TEMPLATE_SCRIPT:=$(RESOURCES_DIR)/templates/index.sh
|
||||
|
||||
.PHONY: DEFAULT all \
|
||||
build build-hosts build-gz build-android build-windows \
|
||||
stats stats-tlds stats-suffixes \
|
||||
index \
|
||||
clean
|
||||
|
||||
DEFAULT: all
|
||||
|
||||
all: clean build stats index
|
||||
|
||||
build: build-hosts build-gz build-android build-windows
|
||||
|
||||
build-hosts:
|
||||
mkdir -p "$(PUBLIC_DIR)"
|
||||
"$(HBLOCK_SCRIPT)" -O "$(PUBLIC_DIR)"/hosts
|
||||
|
||||
build-gz: build-hosts
|
||||
gzip -c "$(PUBLIC_DIR)"/hosts > "$(PUBLIC_DIR)"/hosts.gz
|
||||
|
||||
build-android: build-hosts
|
||||
mkdir -p "$(TEMP_DIR)"/android
|
||||
cp -r "$(RESOURCES_DIR)"/android/* "$(PUBLIC_DIR)"/hosts "$(TEMP_DIR)"/android
|
||||
cd "$(TEMP_DIR)"/android && zip -r "$(PUBLIC_DIR)"/hosts_android.zip .
|
||||
|
||||
build-windows: build-hosts
|
||||
mkdir -p "$(TEMP_DIR)"/windows
|
||||
cp -r "$(RESOURCES_DIR)"/windows/* "$(PUBLIC_DIR)"/hosts "$(TEMP_DIR)"/windows
|
||||
unix2dos "$(TEMP_DIR)"/windows/install.bat "$(TEMP_DIR)"/windows/hosts
|
||||
cd "$(TEMP_DIR)"/windows && zip -r "$(PUBLIC_DIR)"/hosts_windows.zip .
|
||||
|
||||
stats: stats-tlds stats-suffixes
|
||||
|
||||
stats-tlds: build-hosts
|
||||
"$(STATS_SCRIPT)" "$(PUBLIC_DIR)"/hosts none > "$(PUBLIC_DIR)"/most_abused_tlds.txt
|
||||
|
||||
stats-suffixes: build-hosts
|
||||
"$(STATS_SCRIPT)" "$(PUBLIC_DIR)"/hosts > "$(PUBLIC_DIR)"/most_abused_suffixes.txt
|
||||
|
||||
index: build-hosts
|
||||
"$(TEMPLATE_SCRIPT)" "$(PUBLIC_DIR)" > "$(PUBLIC_DIR)"/index.html
|
||||
|
||||
clean:
|
||||
rm -rf "$(PUBLIC_DIR)"
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue