2022-09-09 13:13:22 -05:00
SHELL = /bin/bash
2021-10-16 17:41:17 -05:00
PREFIX ?= /usr/local
2022-08-31 04:01:15 -05:00
BUILD_DIR ?= build
2022-08-04 05:41:23 -05:00
KEYRING_TARGET_DIR ?= $( PREFIX) /share/pacman/keyrings/
2023-11-17 14:09:00 -06:00
RELEASE ?=
2023-02-14 14:54:51 -06:00
SCRIPT_TARGET_DIR ?= $( PREFIX) /bin
2022-08-04 05:41:23 -05:00
SYSTEMD_SYSTEM_UNIT_DIR ?= $( shell pkgconf --variable systemd_system_unit_dir systemd)
2022-08-31 04:01:15 -05:00
WKD_FQDN ?= archlinux.org
WKD_BUILD_DIR ?= $( BUILD_DIR) /wkd
2022-08-04 05:41:23 -05:00
KEYRING_FILE = archlinux.gpg
KEYRING_REVOKED_FILE = archlinux-revoked
KEYRING_TRUSTED_FILE = archlinux-trusted
2023-11-17 14:09:00 -06:00
PROJECT = archlinux-keyring
2022-08-04 05:41:23 -05:00
WKD_SYNC_SCRIPT = archlinux-keyring-wkd-sync
2022-08-04 05:59:24 -05:00
WKD_SYNC_SERVICE_IN = archlinux-keyring-wkd-sync.service.in
2022-08-04 05:41:23 -05:00
WKD_SYNC_SERVICE = archlinux-keyring-wkd-sync.service
WKD_SYNC_TIMER = archlinux-keyring-wkd-sync.timer
2022-07-22 18:47:38 -05:00
SYSTEMD_TIMER_DIR = $( SYSTEMD_SYSTEM_UNIT_DIR) /timers.target.wants/
2021-11-26 16:40:11 -06:00
SOURCES := $( shell find keyring) $( shell find libkeyringctl -name '*.py' -or -type d) keyringctl
2012-02-13 07:37:52 -06:00
2021-10-16 17:41:17 -05:00
all : build
2012-02-13 07:37:52 -06:00
2021-10-16 17:41:17 -05:00
lint :
2021-11-01 11:36:02 -06:00
black --check --diff keyringctl libkeyringctl tests
2021-10-16 17:41:17 -05:00
isort --diff .
2021-11-01 11:36:02 -06:00
flake8 keyringctl libkeyringctl tests
mypy --install-types --non-interactive keyringctl libkeyringctl tests
2012-02-13 07:37:52 -06:00
2021-10-24 15:10:14 -05:00
fmt :
black .
isort .
2021-11-07 16:31:19 -06:00
check :
./keyringctl -v check
2021-10-31 11:53:20 -06:00
test :
2021-10-31 14:26:27 -06:00
coverage run
2021-11-01 15:25:11 -06:00
coverage xml
2021-11-14 09:10:23 -06:00
coverage report --fail-under= 100.0
2021-10-31 11:53:20 -06:00
2021-11-26 16:40:11 -06:00
build : $( SOURCES )
2024-04-29 10:02:40 -06:00
./keyringctl -v build
2022-08-31 04:01:15 -05:00
wkd : build
2024-04-29 10:02:40 -06:00
sq -f network wkd generate -s $( WKD_BUILD_DIR) / $( WKD_FQDN) $( BUILD_DIR) /$( KEYRING_FILE)
2022-08-31 04:01:15 -05:00
wkd_inspect : wkd
for file in $( WKD_BUILD_DIR) /.well-known/openpgpkey/$( WKD_FQDN) /hu/*; do sq inspect $$ file; done
2012-02-13 07:37:52 -06:00
2022-08-04 05:59:24 -05:00
wkd_sync_service : wkd_sync /$( WKD_SYNC_SERVICE_IN )
2022-08-31 04:01:15 -05:00
sed -e 's|SCRIPT_TARGET_DIR|$(SCRIPT_TARGET_DIR)|' wkd_sync/$( WKD_SYNC_SERVICE_IN) > $( BUILD_DIR) /$( WKD_SYNC_SERVICE)
2022-08-04 05:59:24 -05:00
2021-11-26 16:40:11 -06:00
clean :
2022-08-31 04:01:15 -05:00
rm -rf $( BUILD_DIR) $( WKD_BUILD_DIR)
2021-11-26 16:40:11 -06:00
2023-11-17 14:09:00 -06:00
release : clean build
$( if $( RELEASE) ,,$( error RELEASE was not specified!) )
@glab auth status -h gitlab.archlinux.org
@git tag -s $( RELEASE) -m " release version $( RELEASE) "
@git push origin refs/tags/$( RELEASE)
@mkdir -p $( BUILD_DIR) /$( PROJECT) -$( RELEASE) /
@cp $( BUILD_DIR) /{ $( KEYRING_FILE) ,$( KEYRING_REVOKED_FILE) ,$( KEYRING_TRUSTED_FILE) } $( BUILD_DIR) /$( PROJECT) -$( RELEASE) /
@tar cvfz $( BUILD_DIR) /$( PROJECT) -$( RELEASE) .tar.gz -C $( BUILD_DIR) / $( PROJECT) -$( RELEASE) /
@gpg -o $( BUILD_DIR) /$( PROJECT) -$( RELEASE) .tar.gz.sig --default-key " $( shell git config --local --get user.signingkey) " -s $( BUILD_DIR) /$( PROJECT) -$( RELEASE) .tar.gz
# NOTE: we specify GITLAB_HOST, because otherwise glab YOLO uses whatever is specified by the `host` key in its config and silently breaks all links...
GITLAB_HOST = gitlab.archlinux.org glab release create $( RELEASE) ./build/$( PROJECT) -$( RELEASE) .tar.gz* --name= $( RELEASE) --notes= " release version $( RELEASE) "
2022-08-04 05:59:24 -05:00
install : build wkd_sync_service
2022-08-04 05:41:23 -05:00
install -vDm 644 build/{ $( KEYRING_FILE) ,$( KEYRING_REVOKED_FILE) ,$( KEYRING_TRUSTED_FILE) } -t $( DESTDIR) $( KEYRING_TARGET_DIR)
install -vDm 755 wkd_sync/$( WKD_SYNC_SCRIPT) -t $( DESTDIR) $( SCRIPT_TARGET_DIR)
2022-08-04 05:59:24 -05:00
install -vDm 644 build/$( WKD_SYNC_SERVICE) -t $( DESTDIR) $( SYSTEMD_SYSTEM_UNIT_DIR)
install -vDm 644 wkd_sync/$( WKD_SYNC_TIMER) -t $( DESTDIR) $( SYSTEMD_SYSTEM_UNIT_DIR)
2022-08-04 05:41:23 -05:00
install -vdm 755 $( DESTDIR) $( SYSTEMD_TIMER_DIR)
2022-09-02 06:26:29 -05:00
ln -fsv ../$( WKD_SYNC_TIMER) $( DESTDIR) $( SYSTEMD_TIMER_DIR) /$( WKD_SYNC_TIMER)
2012-02-13 07:37:52 -06:00
2021-10-16 17:41:17 -05:00
uninstall :
2022-08-04 05:41:23 -05:00
rm -fv $( DESTDIR) $( KEYRING_TARGET_DIR) /{ $( KEYRING_FILE) ,$( KEYRING_REVOKED_FILE) ,$( KEYRING_TRUSTED_FILE) }
rmdir -pv --ignore-fail-on-non-empty $( DESTDIR) $( KEYRING_TARGET_DIR)
rm -v $( DESTDIR) $( SCRIPT_TARGET_DIR) /$( WKD_SYNC_SCRIPT)
rmdir -pv --ignore-fail-on-non-empty $( DESTDIR) $( SCRIPT_TARGET_DIR)
rm -v $( DESTDIR) $( SYSTEMD_SYSTEM_UNIT_DIR) /{ $( WKD_SYNC_SERVICE) ,$( WKD_SYNC_TIMER) }
rmdir -pv --ignore-fail-on-non-empty $( DESTDIR) $( SYSTEMD_SYSTEM_UNIT_DIR)
rm -v $( DESTDIR) $( SYSTEMD_TIMER_DIR) /$( WKD_SYNC_TIMER)
rmdir -pv --ignore-fail-on-non-empty $( DESTDIR) $( SYSTEMD_TIMER_DIR)
2012-02-13 07:37:52 -06:00
2023-11-17 14:09:00 -06:00
.PHONY : all lint fmt check test clean install release uninstall wkd wkd_inspect