Skip to content

Commit

Permalink
Merge pull request #9 from farzadghanei/better-packaging
Browse files Browse the repository at this point in the history
Better packaging
  • Loading branch information
farzadghanei authored May 19, 2024
2 parents cdfed9a + 4d39b07 commit d598098
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 8 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
License for Chkok
=================

Copyright 2022 Farzad Ghanei
Copyright 2024 Farzad Ghanei

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,
Expand Down
15 changes: 11 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ DESTDIR ?=
prefix ?= /usr/local
exec_prefix ?= $(prefix)
bindir ?= $(exec_prefix)/bin
sharedir ?= $(exec_prefix)/share
mandir ?= $(sharedir)/man/man1

# use Make's builtin variable to call 'install'
INSTALL ?= install
Expand Down Expand Up @@ -84,14 +86,18 @@ build: chkok

test:
go test -v -race ./...
./scripts/staticchecks


install: build
$(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) chkok $(DESTDIR)$(bindir)
mkdir -p $(DESTDIR)$(mandir)
cp docs/man/chkok.1 $(DESTDIR)$(mandir)

uninstall:
rm $(DESTDIR)$(bindir)/chkok
rm -f $(DESTDIR)$(bindir)/chkok
rm -f $(DESTDIR)$(mandir)/chkok.1

clean:
rm -f chkok
Expand Down Expand Up @@ -131,8 +137,9 @@ pkg-tgz: build

# override prefix so .rpm package installs binaries to /usr/bin instead of /usr/local/bin
pkg-rpm: export prefix = /usr
# requires golang compiler > 1.22, and rpmdevtools package
# requires golang compiler > 1.22, and rpm-build/rpmdevtools package
pkg-rpm:
mkdir -p $(RPM_DEV_TREE)/RPMS $(RPM_DEV_TREE)/SRPMS $(RPM_DEV_TREE)/SOURCES $(RPM_DEV_TREE)/SPECS
rm -f $(RPM_DEV_SRC_TGZ)
tar --exclude-vcs -zcf $(RPM_DEV_SRC_TGZ) .
cp build/package/chkok.spec $(RPM_DEV_SPEC)
Expand All @@ -151,11 +158,11 @@ pkg-checksum:
if test -e $(PKG_DIST_DIR); then cd $(PKG_DIST_DIR) \
&& (sed -i '/chkok_$(CHKOK_DEB_VERSION).*deb/d' $(PKG_CHECKSUM_NAME) || true) \
&& find . -maxdepth 1 -readable -type f -name 'chkok_$(CHKOK_DEB_VERSION)*.deb' \
-exec sha256sum '{}' \; >> $(PKG_CHECKSUM_NAME); fi
-exec sha256sum '{}' \; | sed 's|./||g' >> $(PKG_CHECKSUM_NAME); fi
if test -e $(PKG_DIST_DIR); then cd $(PKG_DIST_DIR) \
&& (sed -i '/chkok-$(CHKOK_RPM_VERSION).*rpm/d' $(PKG_CHECKSUM_NAME) || true) \
&& find . -maxdepth 1 -readable -type f -name 'chkok-$(CHKOK_RPM_VERSION)*.rpm' \
-exec sha256sum '{}' \; >> $(PKG_CHECKSUM_NAME); fi
-exec sha256sum '{}' \; | sed 's|./||g' >> $(PKG_CHECKSUM_NAME); fi

# sync version from source code to other files (docs, packaging, etc.)
sync-version:
Expand Down
49 changes: 48 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ system state is as expected. It can be used to monitor system health and resourc
Provides different running modes, useful for reporting to local and remote monitoring.
It's written in Go, has a small resource overhead with no runtime dependencies.

Main target platforms are modern GNU/Linux systems, but other operating systems may work as well.


Installation
------------

Download the latest release from the `releases` page.
Released artifacts can be verified with the checksum file containing sha256 hashes.

.. code-block:: shell
sha256sum -c chkok-*SHA256SUMS
Or build and install from source (requires Go 1.22+):

.. code-block:: shell
sudo make install
# or to install in a custom location (e.g. for packaging)
env DESTDIR=/tmp make install
Usage
-----
Expand All @@ -27,6 +49,11 @@ Run in HTTP mode, starting an HTTP server on the configured port:
chkok -conf examples/config.yaml -verbose -mode http
The HTTP mode is useful for checking the results remotely, for example, from a monitoring system.
Currently there is no encryption supported, so it's recommended to use only in trusted networks,
or behind a local SSL terminating service.


Configuration
-------------

Expand Down Expand Up @@ -90,9 +117,29 @@ to be checked.
See the `examples` directory for sample configuration files.


Development
-----------

Make sure you have Go 1.22+ installed.
Most of the development and build tasks are automated with the `Makefile`.

To build the binary from source, run:

.. code-block:: shell
make clean build
To run the tests and static checks, run:

.. code-block:: shell
make test
License
-------

"chkok" is an open source project released under the terms of the `MIT license <https://opensource.org/licenses/MIT>`_.
It uses yaml.v3 library which is licensed under the MIT and Apache License 2.0 licenses.
See LICENSE file for more details.
See LICENSE file for more details.
2 changes: 0 additions & 2 deletions build/package/chkok.spec
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ Provides different running modes, useful for reporting to local and remote monit
%install
rm -rf $RPM_BUILD_ROOT
%make_install
mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1
cp -a docs/man/chkok.1 $RPM_BUILD_ROOT/usr/share/man/man1/%{name}.1
cp -a examples/config.yaml example-config.yaml


Expand Down

0 comments on commit d598098

Please sign in to comment.