mirror of
https://github.com/hectorm/hblock.git
synced 2026-04-18 21:16:32 +05:30
Create deb and rpm packages
This commit is contained in:
parent
285427adb9
commit
6bdc2d210a
12 changed files with 230 additions and 35 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -1,5 +1,5 @@
|
|||
/debian/
|
||||
/dist/
|
||||
/rpmbuild/
|
||||
node_modules/
|
||||
npm-debug.log*
|
||||
|
||||
/.tmp/
|
||||
/dist/
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ image: alpine:latest
|
|||
stages:
|
||||
- lint
|
||||
- build
|
||||
- package
|
||||
- deploy
|
||||
|
||||
lint:
|
||||
|
|
@ -25,14 +26,14 @@ build:ubuntu:latest:
|
|||
script:
|
||||
- >
|
||||
make
|
||||
DISTDIR=dist/ubuntu-latest
|
||||
DISTDIR=dist/build-ubuntu-latest
|
||||
HOSTNAME=
|
||||
SKIP_LINT=1
|
||||
release -j4
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- dist/ubuntu-latest/
|
||||
- dist/build-ubuntu-latest/
|
||||
|
||||
build:debian:latest:
|
||||
image: debian:latest
|
||||
|
|
@ -46,14 +47,14 @@ build:debian:latest:
|
|||
script:
|
||||
- >
|
||||
make
|
||||
DISTDIR=dist/debian-latest
|
||||
DISTDIR=dist/build-debian-latest
|
||||
HOSTNAME=
|
||||
SKIP_LINT=1
|
||||
release -j4
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- dist/debian-latest/
|
||||
- dist/build-debian-latest/
|
||||
|
||||
build:fedora:latest:
|
||||
image: fedora:latest
|
||||
|
|
@ -67,14 +68,14 @@ build:fedora:latest:
|
|||
script:
|
||||
- >
|
||||
make
|
||||
DISTDIR=dist/fedora-latest
|
||||
DISTDIR=dist/build-fedora-latest
|
||||
HOSTNAME=
|
||||
SKIP_LINT=1
|
||||
release -j4
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- dist/fedora-latest/
|
||||
- dist/build-fedora-latest/
|
||||
|
||||
build:centos:latest:
|
||||
image: centos:latest
|
||||
|
|
@ -88,14 +89,14 @@ build:centos:latest:
|
|||
script:
|
||||
- >
|
||||
make
|
||||
DISTDIR=dist/centos-latest
|
||||
DISTDIR=dist/build-centos-latest
|
||||
HOSTNAME=
|
||||
SKIP_LINT=1
|
||||
release -j4
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- dist/centos-latest/
|
||||
- dist/build-centos-latest/
|
||||
|
||||
build:opensuse:latest:
|
||||
image: opensuse/leap:latest
|
||||
|
|
@ -109,14 +110,14 @@ build:opensuse:latest:
|
|||
script:
|
||||
- >
|
||||
make
|
||||
DISTDIR=dist/opensuse-latest
|
||||
DISTDIR=dist/build-opensuse-latest
|
||||
HOSTNAME=
|
||||
SKIP_LINT=1
|
||||
release -j4
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- dist/opensuse-latest/
|
||||
- dist/build-opensuse-latest/
|
||||
|
||||
build:alpine:latest:
|
||||
image: alpine:latest
|
||||
|
|
@ -130,14 +131,14 @@ build:alpine:latest:
|
|||
script:
|
||||
- >
|
||||
make
|
||||
DISTDIR=dist/alpine-latest
|
||||
DISTDIR=dist/build-alpine-latest
|
||||
HOSTNAME=
|
||||
SKIP_LINT=1
|
||||
release -j4
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- dist/alpine-latest/
|
||||
- dist/build-alpine-latest/
|
||||
|
||||
build:busybox:latest:
|
||||
image: busybox:latest
|
||||
|
|
@ -146,7 +147,7 @@ build:busybox:latest:
|
|||
- uname -a
|
||||
- busybox | head -1 || true
|
||||
variables:
|
||||
DISTDIR: dist/busybox-latest
|
||||
DISTDIR: dist/build-busybox-latest
|
||||
script:
|
||||
# Partial build, since Busybox does not have the necessary tools
|
||||
- mkdir -p "$DISTDIR"
|
||||
|
|
@ -157,12 +158,50 @@ build:busybox:latest:
|
|||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- dist/busybox-latest/
|
||||
- dist/build-busybox-latest/
|
||||
|
||||
package:deb:
|
||||
image: ubuntu:latest
|
||||
stage: package
|
||||
before_script:
|
||||
- uname -a
|
||||
- cat /etc/os-release
|
||||
- >
|
||||
apt-get update && apt-get install -y --no-install-recommends
|
||||
build-essential debhelper dh-systemd
|
||||
script:
|
||||
- >
|
||||
make
|
||||
DISTDIR=dist/package-deb
|
||||
package-deb
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- dist/package-deb/
|
||||
|
||||
package:rpm:
|
||||
image: fedora:latest
|
||||
stage: package
|
||||
before_script:
|
||||
- uname -a
|
||||
- cat /etc/os-release
|
||||
- >
|
||||
dnf install -y
|
||||
make rpm-build rpmdevtools systemd
|
||||
script:
|
||||
- >
|
||||
make
|
||||
DISTDIR=dist/package-rpm
|
||||
package-rpm
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- dist/package-rpm/
|
||||
|
||||
pages:
|
||||
stage: deploy
|
||||
script:
|
||||
- cp -r dist/ubuntu-latest/ public/
|
||||
- cp -r dist/build-ubuntu-latest/ public/
|
||||
artifacts:
|
||||
paths:
|
||||
- public/
|
||||
|
|
|
|||
81
Makefile
81
Makefile
|
|
@ -7,18 +7,23 @@ DESTDIR :=
|
|||
PREFIX := $(DESTDIR)/usr/local
|
||||
BINDIR := $(PREFIX)/bin
|
||||
SYSCONFDIR := $(DESTDIR)/etc
|
||||
SYSTEMDUNITDIR := $(DESTDIR)/etc/systemd/system
|
||||
|
||||
SYSTEMCTL := $(shell command -v systemctl 2>/dev/null)
|
||||
SHELLCHECK := $(shell command -v shellcheck 2>/dev/null)
|
||||
SYSTEMCTL := $(shell command -v systemctl 2>/dev/null)
|
||||
|
||||
DISTDIR := ./dist
|
||||
RESOURCESDIR := ./resources
|
||||
HBLOCK := ./hblock
|
||||
HBLOCK_VERSION := $(shell sed -n 's|.*"version":\s*"\([0-9]\.[0-9]\.[0-9]\)",.*|\1|p' ./package.json)
|
||||
|
||||
HOSTS := $(DISTDIR)/hosts
|
||||
HOSTS_ALT_FORMATS_SH := $(wildcard $(RESOURCESDIR)/alt-formats/*.sh)
|
||||
HOSTS_ALT_FORMATS := $(HOSTS_ALT_FORMATS_SH:$(RESOURCESDIR)/alt-formats/%.sh=$(DISTDIR)/hosts_%)
|
||||
HOSTS_STATS := $(DISTDIR)/most_abused_tlds.txt $(DISTDIR)/most_abused_suffixes.txt
|
||||
HOSTS_INDEX := $(DISTDIR)/index.html
|
||||
DEB_PACKAGE := $(DISTDIR)/hblock-$(HBLOCK_VERSION).deb
|
||||
RPM_PACKAGE := $(DISTDIR)/hblock-$(HBLOCK_VERSION).rpm
|
||||
|
||||
##################################################
|
||||
## "all" target
|
||||
|
|
@ -121,13 +126,19 @@ logo:
|
|||
.PHONY: install
|
||||
|
||||
install:
|
||||
mkdir -p '$(BINDIR)'
|
||||
install -m 0755 '$(HBLOCK)' '$(BINDIR)'/hblock
|
||||
if [ -x '$(SYSTEMCTL)' ] && [ -d '$(SYSCONFDIR)'/systemd/system ]; then \
|
||||
install -m 0644 '$(RESOURCESDIR)'/systemd/hblock.service '$(SYSCONFDIR)'/systemd/system/hblock.service; \
|
||||
install -m 0644 '$(RESOURCESDIR)'/systemd/hblock.timer '$(SYSCONFDIR)'/systemd/system/hblock.timer; \
|
||||
'$(SYSTEMCTL)' daemon-reload; \
|
||||
'$(SYSTEMCTL)' enable hblock.timer; \
|
||||
'$(SYSTEMCTL)' start hblock.timer; \
|
||||
@if [ -x '$(SYSTEMCTL)' ]; then \
|
||||
if [ '$(SKIP_SERVICE_INSTALL)' != 1 ]; then \
|
||||
mkdir -p '$(SYSTEMDUNITDIR)'; \
|
||||
install -m 0644 '$(RESOURCESDIR)'/systemd/hblock.service '$(SYSTEMDUNITDIR)'/hblock.service; \
|
||||
install -m 0644 '$(RESOURCESDIR)'/systemd/hblock.timer '$(SYSTEMDUNITDIR)'/hblock.timer; \
|
||||
if [ '$(SKIP_SERVICE_START)' != 1 ]; then \
|
||||
'$(SYSTEMCTL)' daemon-reload; \
|
||||
'$(SYSTEMCTL)' enable hblock.timer; \
|
||||
'$(SYSTEMCTL)' start hblock.timer; \
|
||||
fi; \
|
||||
fi; \
|
||||
fi
|
||||
|
||||
##################################################
|
||||
|
|
@ -137,9 +148,11 @@ install:
|
|||
|
||||
installcheck:
|
||||
[ -x '$(BINDIR)'/hblock ] || exit 1
|
||||
if [ -x '$(SYSTEMCTL)' ] && [ -d '$(SYSCONFDIR)'/systemd/system ]; then \
|
||||
[ -f '$(SYSCONFDIR)'/systemd/system/hblock.service ]; \
|
||||
[ -f '$(SYSCONFDIR)'/systemd/system/hblock.timer ]; \
|
||||
@if [ -x '$(SYSTEMCTL)' ]; then \
|
||||
if [ '$(SKIP_SERVICE_INSTALL)' != 1 ]; then \
|
||||
[ -f '$(SYSTEMDUNITDIR)'/hblock.service ]; \
|
||||
[ -f '$(SYSTEMDUNITDIR)'/hblock.timer ]; \
|
||||
fi; \
|
||||
fi
|
||||
|
||||
##################################################
|
||||
|
|
@ -149,23 +162,57 @@ installcheck:
|
|||
|
||||
uninstall:
|
||||
rm -f '$(BINDIR)'/hblock
|
||||
if [ -x '$(SYSTEMCTL)' ] && [ -d '$(SYSCONFDIR)'/systemd/system ]; then \
|
||||
if [ -f '$(SYSCONFDIR)'/systemd/system/hblock.timer ]; then \
|
||||
@if [ -x '$(SYSTEMCTL)' ]; then \
|
||||
if [ -f '$(SYSTEMDUNITDIR)'/hblock.timer ]; then \
|
||||
'$(SYSTEMCTL)' stop hblock.timer; \
|
||||
'$(SYSTEMCTL)' disable hblock.timer; \
|
||||
rm -f '$(SYSCONFDIR)'/systemd/system/hblock.timer; \
|
||||
rm -f '$(SYSTEMDUNITDIR)'/hblock.timer; \
|
||||
fi; \
|
||||
if [ -f '$(SYSCONFDIR)'/systemd/system/hblock.service ]; then \
|
||||
rm -f '$(SYSCONFDIR)'/systemd/system/hblock.service; \
|
||||
if [ -f '$(SYSTEMDUNITDIR)'/hblock.service ]; then \
|
||||
rm -f '$(SYSTEMDUNITDIR)'/hblock.service; \
|
||||
fi; \
|
||||
'$(SYSTEMCTL)' daemon-reload; \
|
||||
fi
|
||||
|
||||
##################################################
|
||||
## "package-*" targets
|
||||
##################################################
|
||||
.PHONY: package-deb package-rpm
|
||||
|
||||
package-deb: $(DEB_PACKAGE)
|
||||
|
||||
$(DEB_PACKAGE):
|
||||
rm -rf ./debian/
|
||||
cp -r '$(RESOURCESDIR)'/deb/ ./debian/
|
||||
sed -i 's|__PKG_VERSION__|$(HBLOCK_VERSION)|g' ./debian/changelog
|
||||
sed -i "s|__PKG_DATE__|$$(LANG=C date -R)|g" ./debian/changelog
|
||||
dpkg-buildpackage -us -uc
|
||||
mkdir -p "$$(dirname '$@')"
|
||||
mv ../hblock_'$(HBLOCK_VERSION)'_all.deb '$@'
|
||||
rm -f ../hblock_'$(HBLOCK_VERSION)'.dsc ../hblock_'$(HBLOCK_VERSION)'.tar.gz
|
||||
rm -f ../hblock_'$(HBLOCK_VERSION)'_*.buildinfo ../hblock_'$(HBLOCK_VERSION)'_*.changes
|
||||
rm -rf ./debian/
|
||||
|
||||
package-rpm: $(RPM_PACKAGE)
|
||||
|
||||
$(RPM_PACKAGE):
|
||||
rm -rf ./rpmbuild/
|
||||
cp -r '$(RESOURCESDIR)'/rpm/ ./rpmbuild/
|
||||
sed -i 's|__PKG_VERSION__|$(HBLOCK_VERSION)|g' ./rpmbuild/SPECS/hblock.spec
|
||||
tar -czf ./rpmbuild/SOURCES/hblock-'$(HBLOCK_VERSION)'.tar.gz --exclude=./rpmbuild --exclude=./.git ./
|
||||
rpmbuild -D "_topdir $$(pwd)/rpmbuild" -bb ./rpmbuild/SPECS/hblock.spec
|
||||
mkdir -p "$$(dirname '$@')"
|
||||
mv ./rpmbuild/RPMS/noarch/hblock-'$(HBLOCK_VERSION)'-*.noarch.rpm '$@'
|
||||
rm -rf ./rpmbuild/
|
||||
|
||||
##################################################
|
||||
## "clean" target
|
||||
##################################################
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
rm -f $(HOSTS) $(HOSTS_ALT_FORMATS) $(HOSTS_STATS) $(HOSTS_INDEX)
|
||||
if [ -d '$(DISTDIR)' ]; then rmdir '$(DISTDIR)'; fi
|
||||
rm -f $(addprefix ', $(addsuffix ', \
|
||||
$(HOSTS) $(HOSTS_ALT_FORMATS) $(HOSTS_STATS) $(HOSTS_INDEX) \
|
||||
$(DEB_PACKAGE) $(RPM_PACKAGE) \
|
||||
))
|
||||
if [ -d '$(DISTDIR)' ] && [ -z "$$(ls -A '$(DISTDIR)')" ]; then rmdir '$(DISTDIR)'; fi
|
||||
|
|
|
|||
5
resources/deb/changelog
Normal file
5
resources/deb/changelog
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
hblock (__PKG_VERSION__) unstable; urgency=medium
|
||||
|
||||
* __PKG_VERSION__ release.
|
||||
|
||||
-- Héctor Molinero Fernández <hector@molinero.xyz> __PKG_DATE__
|
||||
1
resources/deb/compat
Normal file
1
resources/deb/compat
Normal file
|
|
@ -0,0 +1 @@
|
|||
9
|
||||
16
resources/deb/control
Normal file
16
resources/deb/control
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
Source: hblock
|
||||
Section: utils
|
||||
Priority: optional
|
||||
Maintainer: Héctor Molinero Fernández <hector@molinero.xyz>
|
||||
Build-Depends: debhelper (>=9), dh-systemd (>=1.5), make (>=4)
|
||||
Standards-Version: 4.0.0
|
||||
Homepage: https://github.com/hectorm/hblock
|
||||
|
||||
Package: hblock
|
||||
Architecture: all
|
||||
Depends: curl, ${misc:Depends}
|
||||
Description: Improve your security and privacy by blocking ads, tracking and malware domains
|
||||
This POSIX-compliant shell script, designed for Unix-like systems, gets a list
|
||||
of domains that serve ads, tracking scripts and malware from multiple sources
|
||||
and creates a hosts file (alternative formats are also supported) that prevents
|
||||
your system from connecting to them.
|
||||
23
resources/deb/copyright
Normal file
23
resources/deb/copyright
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: hBlock
|
||||
Upstream-Contact: Héctor Molinero Fernández <hector@molinero.xyz>
|
||||
Source: https://github.com/hectorm/hblock
|
||||
|
||||
Files: *
|
||||
Copyright: 2019 Héctor Molinero Fernández
|
||||
License: MIT
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
1
resources/deb/hblock.dirs
Normal file
1
resources/deb/hblock.dirs
Normal file
|
|
@ -0,0 +1 @@
|
|||
usr/bin
|
||||
7
resources/deb/postinst
Executable file
7
resources/deb/postinst
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
||||
14
resources/deb/rules
Executable file
14
resources/deb/rules
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/make -f
|
||||
|
||||
%:
|
||||
dh $@ --with=systemd
|
||||
|
||||
override_dh_auto_build:
|
||||
cp -f "$$(pwd)/resources/systemd/hblock.timer" "$$(pwd)/debian/"
|
||||
cp -f "$$(pwd)/resources/systemd/hblock.service" "$$(pwd)/debian/"
|
||||
|
||||
override_dh_auto_install:
|
||||
'$(MAKE)' DESTDIR="$$(pwd)/debian/hblock" PREFIX="$$(pwd)/debian/hblock/usr" SKIP_SERVICE_INSTALL=1 install
|
||||
|
||||
override_dh_installinit:
|
||||
true
|
||||
0
resources/rpm/SOURCES/.gitkeep
Normal file
0
resources/rpm/SOURCES/.gitkeep
Normal file
42
resources/rpm/SPECS/hblock.spec
Normal file
42
resources/rpm/SPECS/hblock.spec
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
%define name hblock
|
||||
%define version __PKG_VERSION__
|
||||
|
||||
Name: %{name}
|
||||
Version: %{version}
|
||||
Release: 1
|
||||
Summary: Improve your security and privacy by blocking ads, tracking and malware domains
|
||||
Packager: Héctor Molinero Fernández <hector@molinero.xyz>
|
||||
License: MIT
|
||||
URL: https://github.com/hectorm/hblock
|
||||
Source0: %{name}-%{version}.tar.gz
|
||||
BuildArch: noarch
|
||||
BuildRequires: make systemd
|
||||
Requires: curl
|
||||
|
||||
%{?systemd_requires}
|
||||
|
||||
%description
|
||||
This POSIX-compliant shell script, designed for Unix-like systems, gets a list
|
||||
of domains that serve ads, tracking scripts and malware from multiple sources
|
||||
and creates a hosts file (alternative formats are also supported) that prevents
|
||||
your system from connecting to them.
|
||||
|
||||
%prep
|
||||
%setup -c
|
||||
|
||||
%install
|
||||
make DESTDIR="%{buildroot}" PREFIX="%{buildroot}%{_prefix}" SYSTEMDUNITDIR="%{buildroot}%{_unitdir}" SKIP_SERVICE_START=1 install
|
||||
|
||||
%clean
|
||||
rm -rf "%{buildroot}"
|
||||
|
||||
%post
|
||||
%systemd_post hblock.timer
|
||||
|
||||
%preun
|
||||
%systemd_preun hblock.timer
|
||||
|
||||
%files
|
||||
%{_prefix}/bin/hblock
|
||||
%{_unitdir}/hblock.timer
|
||||
%{_unitdir}/hblock.service
|
||||
Loading…
Add table
Add a link
Reference in a new issue