Skip to content

Commit

Permalink
Refactor CI to build in containers across RHEL, SLES, Fedora and Debian
Browse files Browse the repository at this point in the history
Only run the Debian specific cleanup tasks when running under Debian

Refactor all packaging files under linux/<distro>
  • Loading branch information
gs-kamnas committed Aug 23, 2024
1 parent 9e903ad commit 272ab4b
Show file tree
Hide file tree
Showing 27 changed files with 98 additions and 155 deletions.
25 changes: 18 additions & 7 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Update repo metadata
run: sudo apt update -y
- name: Install stuff for creating packages
run: sudo apt install -y fakeroot rpm dpkg debhelper
run: sudo apt install -y fakeroot rpm dpkg debhelper systemd
- name: Install packages required for optional configurations of cntlm
run: sudo apt install -y libkrb5-dev
- name: Install further tools (clang-tools for scan-build)
Expand All @@ -35,10 +37,10 @@ jobs:
make DEBUG=1
./cntlm -h
make distclean
- name: Verify package creation and installation
git diff-files --quiet || ( echo "Changes detected in working tree after make distclean" ; git status ; exit 1 )
- name: Verify debian package creation and installation
run: |
./configure
make rpm
make deb
make clean
sudo make install
Expand All @@ -49,6 +51,7 @@ jobs:
./configure
make duktape.o
scan-build --force-analyze-debug-code make
package:
runs-on: ubuntu-latest
strategy:
Expand All @@ -58,14 +61,16 @@ jobs:
image: registry.access.redhat.com/ubi9/ubi:latest
- os: sles
image: registry.suse.com/suse/sle15:latest
- os: fedora
image: docker.io/fedora:latest
container:
image: ${{ matrix.image }}
steps:
- name: Install build dependencies (RHEL)
run: dnf install -y make gcc systemd rpm-build git shadow-utils && dnf clean all
if: ${{ matrix.os == 'rhel' }}
- name: Install build dependencies (RHEL / Fedora)
run: dnf install -y make gcc systemd rpm-build git shadow-utils which && dnf clean all
if: ${{ matrix.os == 'rhel' || matrix.os == 'fedora' }}
- name: Install build dependencies (SLES)
run: zypper install -y make gcc systemd rpm-build git shadow && zypper clean -a
run: zypper install -y make gcc systemd rpm-build git shadow which && zypper clean -a
if: ${{ matrix.os == 'sles' }}
- name: Checkout repo
uses: actions/checkout@v4
Expand All @@ -79,3 +84,9 @@ jobs:
run: 'rpm -iv cntlm*.rpm'
- name: Invoke cNTLM to ensure it is installed properly
run: cntlm -h
- name: Enforce that the debug symbols have been stripped in the packaged binary
run: |
du -h /usr/sbin/cntlm
file /usr/sbin/cntlm | grep -E ', stripped$'
- name: Enforce that the make distclean target removes all changes to the source tree
run: git diff-files --quiet || ( echo "Changes detected in working tree after make distclean while packaging:" ; git status ; exit 1 )
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ cntlm*.zip
cntlm*.rpm
cntlm*.deb
cntlm*.tar.gz
cntlm*.tar.bz2
/configure-stamp
/config/config.h
/config/endian
Expand All @@ -17,6 +18,9 @@ cntlm*.tar.gz
/config/memset_s
/config/gss
/config/*.exe
/linux/debian/changelog
/linux/rpm/BUILD*
/linux/rpm/SPECS/cntlm.spec
/win/*.exe
/win/*.dll
/win/setup.iss
Expand Down
46 changes: 28 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ DESTDIR :=
PREFIX := /usr/local
SYSCONFDIR := $(DESTDIR)/etc
BINDIR := $(DESTDIR)$(PREFIX)/sbin
INST_BINDIR := $(PREFIX)/sbin
LIBEXECDIR := $(DESTDIR)$(PREFIX)/libexec
MANDIR := $(DESTDIR)$(PREFIX)/share/man

STAMP := configure-stamp
Expand All @@ -27,7 +29,7 @@ LDFLAGS := -lpthread -lm $(OSLDFLAGS)
CYGWIN_REQS := cygwin1.dll cygrunsrv.exe

ifeq ($(CC),gcc)
GCC_VER := $(shell ${CC} -dumpfullversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/')
GCC_VER := $(shell ${CC} -dumpfullversion -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/')
GCC_GTEQ_430 := $(shell expr ${GCC_VER} \>= 40300)
GCC_GTEQ_450 := $(shell expr ${GCC_VER} \>= 40500)
GCC_GTEQ_600 := $(shell expr ${GCC_VER} \>= 60000)
Expand Down Expand Up @@ -153,6 +155,8 @@ install: $(NAME)
install -m 600 doc/$(NAME).conf $(SYSCONFDIR)/$(NAME).conf; \
else \
install -D -m 755 $(STRIP) $(NAME) $(BINDIR)/$(NAME); \
sed "s#%BINDIR%#$(INST_BINDIR)#g" linux/cntlm-user.in > linux/cntlm-user; \
install -D -m 755 linux/$(NAME)-user $(LIBEXECDIR)/$(NAME)-user; \
install -D -m 644 doc/$(NAME).1 $(MANDIR)/man1/$(NAME).1; \
[ -f $(SYSCONFDIR)/$(NAME).conf -o -z "$(SYSCONFDIR)" ] \
|| install -D -m 600 doc/$(NAME).conf $(SYSCONFDIR)/$(NAME).conf; \
Expand All @@ -176,21 +180,22 @@ tbz2:
rmdir tmp 2>/dev/null || true

deb:
sed -i "s/^\(cntlm *\)([^)]*)/\1($(VER))/g" debian/changelog
if [ `id -u` = 0 ]; then \
debian/rules binary; \
debian/rules clean; \
else \
fakeroot debian/rules binary; \
fakeroot debian/rules clean; \
ln -sf linux/debian
sed "s/^\(cntlm *\)([^)]*)/\1($(VER))/g" linux/debian/changelog.in > linux/debian/changelog
if [ `id -u` = 0 ] && [ -L debian ]; then \
linux/debian/rules binary; \
linux/debian/rules clean; \
elif [ -L debian ]; then \
fakeroot linux/debian/rules binary; \
fakeroot linux/debian/rules clean; \
fi
mv ../cntlm_$(VER)*.deb .

rpm: tbz2
sed -i "s/^\(Version:[\t ]*\)\(.*\)/\1$(VER)/g" rpm/SPECS/cntlm.spec
@cp $(NAME)-$(VER).tar.bz2 rpm/SOURCES/
rpmbuild --define '_topdir $(CURDIR)/rpm' -ba rpm/SPECS/cntlm.spec
mv rpm/RPMS/**/*.rpm .
sed "s/^\(Version:[\t ]*\)\(.*\)/\1$(VER)/g" linux/rpm/SPECS/cntlm.spec.in > linux/rpm/SPECS/cntlm.spec
@cp $(NAME)-$(VER).tar.bz2 linux/rpm/SOURCES/
rpmbuild --define '_topdir $(CURDIR)/linux/rpm' -ba linux/rpm/SPECS/cntlm.spec
mv linux/rpm/RPMS/**/*.rpm .

win: win/setup.iss $(NAME) win/cntlm_manual.pdf win/cntlm.ini win/LICENSE.txt $(NAME)-$(VER)-win64.exe $(NAME)-$(VER)-win64.zip

Expand Down Expand Up @@ -238,17 +243,22 @@ uninstall:

clean:
@rm -f config/endian config/gethostname config/socklen_t config/strdup config/arc4random_buf config/strlcat config/strlcpy config/memset_s config/gss config/*.exe
@rm -f *.o cntlm cntlm.exe configure-stamp build-stamp config/config.h
@rm -f *.o cntlm cntlm.exe configure-stamp build-stamp config/config.h cntlm-user
@rm -f $(patsubst %, win/%, $(CYGWIN_REQS) cntlm.exe cntlm.ini LICENSE.txt resources.o setup.iss cntlm_manual.pdf)

distclean: clean
ifeq ($(findstring CYGWIN,$(OS)),)
if [ `id -u` = 0 ]; then \
debian/rules clean; \
else \
fakeroot debian/rules clean; \
if [ -L debian ]; then \
if command -v dh_testdir && [ `id -u` = 0 ]; then \
debian/rules clean; \
elif command -v dh_testdir; then \
fakeroot debian/rules clean; \
fi \
fi
endif
@rm -f *.exe *.deb *.rpm *.tgz *.tar.gz *.tar.bz2 *.zip *.exe tags ctags pid 2>/dev/null
@rm -f *.exe *.deb *.rpm *.tgz *.tar.gz *.tar.bz2 *.zip *.exe \
linux/rpm/specs/cntlm.spec linux/cntlm-user linux/debian/changelog tags ctags pid 2>/dev/null
@rm -rf linux/rpm/BUILD linux/rpm/BUILDROOT 2>/dev/null


.PHONY: all install tgz tbz2 deb rpm win uninstall clean distclean
1 change: 1 addition & 0 deletions debian
87 changes: 0 additions & 87 deletions debian/cntlm.init

This file was deleted.

15 changes: 0 additions & 15 deletions debian/prerm

This file was deleted.

2 changes: 1 addition & 1 deletion rpm/SOURCES/cntlm-user → linux/cntlm-user.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ if [ ! -e "${CNTLM_CONFIG_LOC}" ] ; then
exit 0
fi

exec /usr/sbin/cntlm -f -c "${CNTLM_CONFIG_LOC}" "$@"
exec %BINDIR%/cntlm -f -c "${CNTLM_CONFIG_LOC}" "$@"
2 changes: 1 addition & 1 deletion debian/changelog → linux/debian/changelog.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cntlm (0.94beta1) unstable; urgency=low
cntlm (0.95.0beta1) unstable; urgency=low

* Ad-hoc source build, not a Debian maintained package!

Expand Down
3 changes: 1 addition & 2 deletions debian/cntlm.default → linux/debian/cntlm.default
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Additional options that are passed to the Daemon.
TIMEOUT=1
RUNAS=cntlm
OPTARGS=""
13 changes: 13 additions & 0 deletions linux/debian/cntlm.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=cNTLM authentication proxy
After=network.target

[Service]
Type=simple
Environment="RUNAS=cntlm"
EnvironmentFile=-/etc/default/cntlm
ExecStart=/usr/sbin/cntlm -f -U $RUNAS -c /etc/cntlm.conf $OPTARGS
Restart=on-failure

[Install]
WantedBy=default.target
12 changes: 12 additions & 0 deletions linux/debian/cntlm.user.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=cNTLM authentication proxy - per user instance
After=network.target

[Service]
Type=simple
EnvironmentFile=-/etc/default/cntlm
ExecStart=/usr/libexec/cntlm-user $OPTARGS
Restart=on-failure

[Install]
WantedBy=default.target
File renamed without changes.
4 changes: 2 additions & 2 deletions debian/control → linux/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Priority: optional
Maintainer: David Watson <[email protected]>
Build-Depends: debhelper (>= 5), krb5-multidev
Standards-Version: 3.8.0
Vcs-Git: git://planetwatson.co.uk/cntlm
Vcs-Browser: http://projects.planetwatson.co.uk/repositories/show/cntlm
Vcs-Git: git+https://github.com/versat/cntlm.git
Vcs-Browser: https://github.com/versat/cntlm
Homepage: http://cntlm.sourceforge.net/

Package: cntlm
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 0 additions & 11 deletions debian/postinst → linux/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,3 @@ if ! [ -d $HOME ]; then
fi

#DEBHELPER#

# Automatically added by dh_installinit
if [ -x "/etc/init.d/cntlm" ]; then
update-rc.d cntlm defaults >/dev/null
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
invoke-rc.d cntlm start || exit $?
else
/etc/init.d/cntlm start || exit $?
fi
fi
# End automatically added section
6 changes: 0 additions & 6 deletions debian/postrm → linux/debian/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,3 @@ if [ "$1" = "purge" ]; then
fi

#DEBHELPER#

# Automatically added by dh_installinit
if [ "$1" = "purge" ] ; then
update-rc.d cntlm remove >/dev/null || exit $?
fi
# End automatically added section
5 changes: 5 additions & 0 deletions linux/debian/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

set -e

#DEBHELPER#
3 changes: 2 additions & 1 deletion debian/rules → linux/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ binary-arch: build install
dh_install
cp debian/lintian-override debian/cntlm/usr/share/lintian/overrides/cntlm
dh_installdebconf
dh_installinit -n
dh_installsystemd --no-enable
dh_installsystemduser --no-enable
dh_installman doc/cntlm.1
dh_link
dh_strip
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 272ab4b

Please sign in to comment.