commit f79dbf614a060a002c64ed48148b7bc0e7668401
parent d225d94bc2b4364843bd56dbc4269adecc52af3c
Author: Yersa Nordman <yersa@finwo.nl>
Date: Sat, 7 Oct 2023 23:05:50 +0200
Restructured building and CI
Diffstat:
16 files changed, 217 insertions(+), 259 deletions(-)
diff --git a/.github/workflows/tag-assets.yml b/.github/workflows/tag-assets.yml
@@ -5,20 +5,32 @@ on:
tags:
- stable
- edge
+
jobs:
- attach_asset:
- name: Attach assets to release
- runs-on: ubuntu-latest
+ publish:
+ name: Publish for ${{ matrix.target }}
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ include:
+ - os: ubuntu-latest
+ target: linux-glibc-amd64
+ - os: alpine-latest
+ target: linux-musl-amd64
steps:
- uses: actions/checkout@v3
- uses: finwo/dep@edge
- - run: dep install
- - run: make clean
- - run: make package
-
- - name: Release
- uses: softprops/action-gh-release@v1
+ - name: Build generic package
+ run: make package SVC=generic
+ - name: Build openrc package
+ run: make package SVC=openrc
+ - name: Build procd package
+ run: make package SVC=procd
+ - name: Upload packages to release
+ uses: svenstaro/upload-release-action@v2
with:
- files: |
- package/pmlag-openwrt-amd64.tar.gz
- package/pmlag-linux-amd64.tar.gz
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: build/${{ matrix.target }}/pmlag-*-${{ matrix.target }}.tar.gz
+ file_glob: true
+ overwrite: true
+ tag: ${{ github.ref }}
diff --git a/.gitignore b/.gitignore
@@ -1,5 +1,2 @@
/bak/
-/lib/
-/pmlag
-*.o
-/package/
+/build/
diff --git a/Makefile b/Makefile
@@ -1,59 +1,75 @@
-# Initial config
-LIBS=
-SRC:=
-SRC+=$(wildcard src/*.c)
-SRC+=$(wildcard src/*/*.c)
+TARGET:=linux-glibc-amd64
+SVC:=generic
-override CFLAGS?=-Wall -s -O2
+# # Initial config
+# LIBS=
+# SRC:=
+# SRC+=$(wildcard src/*.c)
+# SRC+=$(wildcard src/*/*.c)
-INCLUDES:=
-INCLUDES+=-I src
+# override CFLAGS?=-Wall -s -O2
-include lib/.dep/config.mk
+# INCLUDES:=
+# INCLUDES+=-I src
-override CFLAGS+=$(INCLUDES)
+# include lib/.dep/config.mk
-# Which objects to generate before merging everything together
-OBJ:=$(SRC:.c=.o)
+# override CFLAGS+=$(INCLUDES)
-BIN=pmlag
+# # Which objects to generate before merging everything together
+# OBJ:=$(SRC:.c=.o)
.PHONY: default
-default: $(BIN) $(BIN).1 README.md
-
-include Makefile.pkg
-
-%.o: %.c $(LIBS)
- $(CC) $(CFLAGS) $(@:.o=.c) -D__NAME=\"$(BIN)\" -c -o $@
-
-$(BIN): $(OBJ)
- $(CC) $(CFLAGS) $(OBJ) --static -o $@
-
-# Build manpage
-$(BIN).1: manpage.1.md
- env NAME=$(BIN) envsubst < manpage.1.md | pandoc --standalone --from markdown --to man -o $(BIN).1
- env NAME=$(BIN) envsubst < manpage.1.md | pandoc --standalone --from markdown --to html -o $(BIN).html
-
-package: default
- rm -rf package
- ### linux-amd64 ###
- mkdir -p package/pmlag-linux-amd64
- cp pmlag package/pmlag-linux-amd64/pmlag
- cp pmlag.1 package/pmlag-linux-amd64/pmlag.1
- cp -r service package/pmlag-linux-amd64/service
- cp Makefile.pkg package/pmlag-linux-amd64/Makefile
- (cd package ; tar c pmlag-linux-amd64 | gzip -9 > pmlag-linux-amd64.tar.gz)
- ### openwrt-amd64 ###
- mkdir -p package/pmlag-openwrt-amd64/etc
- mkdir -p package/pmlag-openwrt-amd64/etc/init.d
- mkdir -p package/pmlag-openwrt-amd64/usr/bin
- mkdir -p package/pmlag-openwrt-amd64/usr/share/man/man1
- cp pmlag package/pmlag-openwrt-amd64/usr/bin/pmlag
- cp pmlag.1 package/pmlag-openwrt-amd64/usr/share/man/man1/pmlag.1
- cp service/procd/etc/init.d/pmlag package/pmlag-openwrt-amd64/etc/init.d/pmlag
- cp service/common/etc/pmlag.ini package/pmlag-openwrt-amd64/etc/pmlag.ini
- (cd package ; tar c pmlag-openwrt-amd64 | gzip -9 > pmlag-openwrt-amd64.tar.gz)
+default: build/${TARGET}/pmlag
+
+.PHONY: package
+package: build/${TARGET}/pmlag-${SVC}-${TARGET}.tar.gz
+
+build/${TARGET}: $(wildcard src/*.c src/*.h src/*/*.c src/*/*.h)
+ mkdir -p build/${TARGET}
+ cp package.ini build/${TARGET}/package.ini
+ cp manpage.1.md build/${TARGET}/manpage.1.md
+ cp -rT src/ build/${TARGET}/src
+ cp -rT package/ build/${TARGET}/package
+ cp -rT arch/common/ build/${TARGET}
+ cp -rT arch/${TARGET}/ build/${TARGET}
+ cp -rT arch/${TARGET}/ build/${TARGET}
+
+build/${TARGET}/pmlag: build/${TARGET}
+ cd build/${TARGET} && dep install
+ $(MAKE) --directory build/${TARGET} TARGET=${TARGET}
+
+build/${TARGET}/pmlag-${SVC}-${TARGET}.tar.gz: build/${TARGET}/pmlag
+ $(MAKE) --directory build/${TARGET} TARGET=${TARGET} SVC=${SVC} pmlag-${SVC}-${TARGET}.tar.gz
+
+# include Makefile.pkg
+
+# %.o: %.c $(LIBS)
+# $(CC) $(CFLAGS) $(@:.o=.c) -D__NAME=\"$(BIN)\" -c -o $@
+
+# $(BIN): $(OBJ)
+# $(CC) $(CFLAGS) $(OBJ) --static -o $@
+
+# # Build manpage
+# $(BIN).1: manpage.1.md
+# env NAME=$(BIN) envsubst < manpage.1.md | pandoc --standalone --from markdown --to man -o $(BIN).1
+# env NAME=$(BIN) envsubst < manpage.1.md | pandoc --standalone --from markdown --to html -o $(BIN).html
+
+# package: default
+# rm -rf package
+
+
+# ### openwrt-amd64 ###
+# mkdir -p package/pmlag-openwrt-amd64/etc
+# mkdir -p package/pmlag-openwrt-amd64/etc/init.d
+# mkdir -p package/pmlag-openwrt-amd64/usr/bin
+# mkdir -p package/pmlag-openwrt-amd64/usr/share/man/man1
+# cp pmlag package/pmlag-openwrt-amd64/usr/bin/pmlag
+# cp pmlag.1 package/pmlag-openwrt-amd64/usr/share/man/man1/pmlag.1
+# cp service/procd/etc/init.d/pmlag package/pmlag-openwrt-amd64/etc/init.d/pmlag
+# cp service/common/etc/pmlag.ini package/pmlag-openwrt-amd64/etc/pmlag.ini
+# (cd package ; tar c pmlag-openwrt-amd64 | gzip -9 > pmlag-openwrt-amd64.tar.gz)
.PHONY: clean
clean:
- rm -f $(OBJ)
+ rm -rf build
diff --git a/Makefile.pkg b/Makefile.pkg
@@ -1,16 +0,0 @@
-DESTDIR?=/usr/local
-
-.PHONY: default
-default:
- # Run 'make install' to install this package
-
-.PHONY: install
-install: default
- install pmlag $(DESTDIR)/bin
- install pmlag.1 $(DESTDIR)/share/man/man1
-
-.PHONY: svc_openrc
-svc_openrc: default
- DESTDIR=$(DESTDIR) envsubst < ./service/openrc/etc/init.d/pmlag > /etc/init.d/pmlag
- DESTDIR=$(DESTDIR) envsubst < ./service/common/etc/pmlag.ini > /etc/pmlag.ini
- DESTDIR=$(DESTDIR) envsubst '$$DESTDIR' < ./service/openrc/etc/init.d/pmlag > svc
diff --git a/arch/common/Makefile b/arch/common/Makefile
@@ -0,0 +1,60 @@
+TARGET?=
+SVC?=
+
+# Initial config
+LIBS=
+SRC:=
+SRC+=$(wildcard src/*.c)
+SRC+=$(wildcard src/*/*.c)
+
+override CFLAGS?=-Wall -s -O2
+
+INCLUDES:=
+INCLUDES+=-I src
+
+include lib/.dep/config.mk
+
+override CFLAGS+=$(INCLUDES)
+
+# Which objects to generate before merging everything together
+OBJ:=$(SRC:.c=.o)
+
+BIN=pmlag
+
+.PHONY: default
+default: $(BIN) $(BIN).1
+
+include Makefile.pkg
+
+%.o: %.c $(LIBS)
+ $(CC) $(CFLAGS) $(@:.o=.c) -D__NAME=\"$(BIN)\" -c -o $@
+
+$(BIN): $(OBJ)
+ $(CC) $(CFLAGS) $(OBJ) -o $@
+
+# Build manpage
+$(BIN).1: manpage.1.md
+ env NAME=$(BIN) envsubst < manpage.1.md | pandoc --standalone --from markdown --to man -o $(BIN).1
+
+${BIN}-${SVC}-${TARGET}.tar.gz: $(BIN)
+ package/${SVC}/build.sh
+
+# package: default
+# rm -rf package
+# ### linux-amd64 ###
+# mkdir -p package/pmlag-linux-amd64
+# cp pmlag package/pmlag-linux-amd64/pmlag
+# cp pmlag.1 package/pmlag-linux-amd64/pmlag.1
+# cp -r service package/pmlag-linux-amd64/service
+# cp Makefile.pkg package/pmlag-linux-amd64/Makefile
+# (cd package ; tar c pmlag-linux-amd64 | gzip -9 > pmlag-linux-amd64.tar.gz)
+# ### openwrt-amd64 ###
+# mkdir -p package/pmlag-openwrt-amd64/etc
+# mkdir -p package/pmlag-openwrt-amd64/etc/init.d
+# mkdir -p package/pmlag-openwrt-amd64/usr/bin
+# mkdir -p package/pmlag-openwrt-amd64/usr/share/man/man1
+# cp pmlag package/pmlag-openwrt-amd64/usr/bin/pmlag
+# cp pmlag.1 package/pmlag-openwrt-amd64/usr/share/man/man1/pmlag.1
+# cp service/procd/etc/init.d/pmlag package/pmlag-openwrt-amd64/etc/init.d/pmlag
+# cp service/common/etc/pmlag.ini package/pmlag-openwrt-amd64/etc/pmlag.ini
+# (cd package ; tar c pmlag-openwrt-amd64 | gzip -9 > pmlag-openwrt-amd64.tar.gz)
diff --git a/arch/common/Makefile.pkg b/arch/common/Makefile.pkg
@@ -0,0 +1,7 @@
+default:
+ # Run 'make install' to install this package
+
+.PHONY: install
+install: default
+ install pmlag $(DESTDIR)/bin
+ install pmlag.1 $(DESTDIR)/share/man/man1
diff --git a/arch/linux-glibc-amd64/.gitkeep b/arch/linux-glibc-amd64/.gitkeep
diff --git a/arch/linux-musl-amd64/.gitkeep b/arch/linux-musl-amd64/.gitkeep
diff --git a/service/common/etc/pmlag.ini b/package/common/files/etc/pmlag.ini
diff --git a/package/generic/build.sh b/package/generic/build.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+
+set -ex
+
+NAM=pmlag-generic-${TARGET}
+
+cd $(dirname $0)/../../
+mkdir -p ${NAM}
+cp Makefile.pkg ${NAM}/Makefile
+cp pmlag ${NAM}/pmlag
+cp pmlag.1 ${NAM}/pmlag.1
+mkdir -p ${NAM}/svc
+cp -rT package/common/files ${NAM}/svc/common
+cp -rT package/openrc/files ${NAM}/svc/openrc
+cp -rT package/procd/files ${NAM}/svc/procd
+tar c ${NAM} | gzip -9 > ${NAM}.tar.gz
+rm -rf ${NAM}
diff --git a/package/openrc/build.sh b/package/openrc/build.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+
+set -ex
+
+NAM=pmlag-openrc-${TARGET}
+
+cd $(dirname $0)/../../
+mkdir -p ${NAM}/usr/bin
+mkdir -p ${NAM}/usr/share/man/man1
+mkdir -p ${NAM}/etc/init.d
+install pmlag ${NAM}/usr/bin
+install pmlag.1 ${NAM}/usr/share/man/man1
+cp -rT package/common/files ${NAM}/
+cp -rT package/openrc/files ${NAM}/
+DESTDIR=/usr envsubst '${DESTDIR}' < package/openrc/files/etc/init.d/pmlag > ${NAM}/etc/init.d/pmlag
+tar c ${NAM} | gzip -9 > ${NAM}.tar.gz
+rm -rf ${NAM}
diff --git a/service/openrc/etc/init.d/pmlag b/package/openrc/files/etc/init.d/pmlag
diff --git a/package/procd/build.sh b/package/procd/build.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+
+set -ex
+
+NAM=pmlag-procd-${TARGET}
+
+cd $(dirname $0)/../../
+mkdir -p ${NAM}/usr/bin
+mkdir -p ${NAM}/usr/share/man/man1
+mkdir -p ${NAM}/etc/init.d
+install pmlag ${NAM}/usr/bin
+install pmlag.1 ${NAM}/usr/share/man/man1
+cp -rT package/common/files ${NAM}/
+cp -rT package/procd/files ${NAM}/
+DESTDIR=/usr envsubst '${DESTDIR}' < package/procd/files/etc/init.d/pmlag > ${NAM}/etc/init.d/pmlag
+tar c ${NAM} | gzip -9 > ${NAM}.tar.gz
+rm -rf ${NAM}
diff --git a/package/procd/files/etc/init.d/pmlag b/package/procd/files/etc/init.d/pmlag
@@ -0,0 +1,10 @@
+#!/bin/sh /etc/rc.common
+
+USE_PROCD=1
+START=95
+STOP=01
+start_service() {
+ procd_open_instance
+ procd_set_param command ${DESTDIR}/bin/pmlag -c /etc/pmlag.ini
+ procd_close_instance
+}
diff --git a/pmlag.1 b/pmlag.1
@@ -1,169 +0,0 @@
-'\" t
-.\" Automatically generated by Pandoc 2.17.1.1
-.\"
-.\" Define V font for inline verbatim, using C font in formats
-.\" that render this, and otherwise B font.
-.ie "\f[CB]x\f[]"x" \{\
-. ftr V B
-. ftr VI BI
-. ftr VB B
-. ftr VBI BI
-.\}
-.el \{\
-. ftr V CR
-. ftr VI CI
-. ftr VB CB
-. ftr VBI CBI
-.\}
-.TH "pmlag" "1" "" "" "General Commands Manual"
-.hy
-.SH NAME
-.PP
-pmlag - Poor man\[cq]s link aggregator
-.PP
-pmlag is a tool for bonding network interfaces together when the
-hardware on the other side of the cable(s) doesn\[cq]t support it.
-.SH SYNOPSIS
-.PP
-\f[V]pmlag [options]\f[R]
-.SH OPTIONS
-.PP
-.TS
-tab(@);
-lw(35.0n) lw(35.0n).
-T{
-Option
-T}@T{
-Description
-T}
-_
-T{
-\[hy]c <file>
-T}@T{
-Select the config file to use (default: /etc/pmlag/pmlag.ini)
-T}
-T{
-T}@T{
-T}
-T{
-\[hy]h | \[hy]\[hy]help
-T}@T{
-Show basic usage of the utility
-T}
-.TE
-.SH CONFIGURATION
-.PP
-TODO
-.SH LICENSE
-.PP
-This program itself is licensed under the MIT license:
-.PP
-Copyright 2023 finwo
-.PP
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-\[lq]Software\[rq]), 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:
-.PP
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-.PP
-THE SOFTWARE IS PROVIDED \[lq]AS IS\[rq], 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.
-.PP
- * * * * *
-.PP
-This project makes use of the following libraries, each of which having
-their own license.
-Please note that the licenses shown here may be out of date.
-.IP \[bu] 2
-benhoyt/inih (https://github.com/benhoyt/inih)
-.RS 2
-.PP
-The \[lq]inih\[rq] library is distributed under the New BSD license:
-.PP
-Copyright (c) 2009, Ben Hoyt All rights reserved.
-.PP
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met: * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright
-notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution.
-* Neither the name of Ben Hoyt nor the names of its contributors may be
-used to endorse or promote products derived from this software without
-specific prior written permission.
-.PP
-THIS SOFTWARE IS PROVIDED BY BEN HOYT `\[cq]AS IS'\[cq] AND ANY EXPRESS
-OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED.
-IN NO EVENT SHALL BEN HOYT BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-.RE
-.IP \[bu] 2
-cofyc/argparse (https://github.com/cofyc/argparse)
-.RS 2
-.PP
-The MIT License (MIT)
-.PP
-Copyright (c) 2012-2013 Yecheng Fu <cofyc.jackson@gmail.com>
-.PP
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-\[lq]Software\[rq]), 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:
-.PP
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-.PP
-THE SOFTWARE IS PROVIDED \[lq]AS IS\[rq], 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.
-.RE
-.IP \[bu] 2
-finwo/mindex (https://github.com/finwo/c-mindex)
-.RS 2
-.PP
-Copyright 2023 finwo
-.PP
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-\[lq]Software\[rq]), 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:
-.PP
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-.PP
-THE SOFTWARE IS PROVIDED \[lq]AS IS\[rq], 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.
-.RE
diff --git a/service/procd/etc/init.d/pmlag b/service/procd/etc/init.d/pmlag
@@ -1,10 +0,0 @@
-#!/bin/sh /etc/rc.common
-
-USE_PROCD=1
-START=95
-STOP=01
-start_service() {
- procd_open_instance
- procd_set_param command /usr/bin/pmlag -c /etc/pmlag.ini
- procd_close_instance
-}