Skip to content

Commit

Permalink
Minor adjustments to build Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-massa committed Aug 4, 2024
1 parent 6f9c8d6 commit eab5539
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
25 changes: 14 additions & 11 deletions .build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,38 @@
BUILD_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))

VERSION := $(shell git describe --tags)
IMAGE_NAME := ifmqtoggle-builder:${VERSION}
CONTAINER_NAME := ifmqtoggle-build-${VERSION}
IMAGE_NAME := ifmqtoggle-builder:$(VERSION)
CONTAINER_NAME := ifmqtoggle-build-$(VERSION)
OPENWRT_RELEASE := v23.05.3

build:
cd $(shell dirname $(BUILD_DIR)); \
docker image build --build-arg OPENWRT_RELEASE=${OPENWRT_RELEASE} -f $(BUILD_DIR)/Dockerfile -t ${IMAGE_NAME} .
docker image build --build-arg OPENWRT_RELEASE=$(OPENWRT_RELEASE) -f $(BUILD_DIR)/Dockerfile -t $(IMAGE_NAME) .

run:
docker container run -d --name ${CONTAINER_NAME} ${IMAGE_NAME} tail -f /dev/null
docker container run -d --name $(CONTAINER_NAME) $(IMAGE_NAME) tail -f /dev/null

copy:
docker container cp ${CONTAINER_NAME}:$(shell docker exec ${CONTAINER_NAME} sh -c "readlink -f bin/packages/*/mypackages/ifmqtoggle_*_all.ipk") $(BUILD_DIR)/
docker container cp $(CONTAINER_NAME):$(shell docker exec $(CONTAINER_NAME) sh -c "readlink -f bin/packages/*/mypackages/ifmqtoggle_*_all.ipk") $(BUILD_DIR)/

down:
docker container rm -f ${CONTAINER_NAME}
docker image rm -f ${IMAGE_NAME}
docker container rm -f $(CONTAINER_NAME)

checksum:
@filename=$(shell ls $(BUILD_DIR)/ifmqtoggle_*_all.ipk); \
shasum -a 256 $$filename > $$filename.sha256
$(eval filepath := $(shell ls $(BUILD_DIR)/ifmqtoggle_*_all.ipk))
cd $(shell dirname $(filepath)); \
shasum -a 256 $(shell basename $(filepath)) > $(shell basename $(filepath)).sha256

verify:
@filename=$(shell ls $(BUILD_DIR)/ifmqtoggle_*_all.ipk); \
shasum -a 256 -c $$filename.sha256
$(eval filepath := $(shell ls $(BUILD_DIR)/ifmqtoggle_*_all.ipk))
cd $(shell dirname $(filepath)); \
shasum -a 256 -c $(shell basename $(filepath)).sha256

clean:
rm -f $(BUILD_DIR)/ifmqtoggle_*_all.ipk
rm -f $(BUILD_DIR)/ifmqtoggle_*_all.ipk.sha256
$(MAKE) -f $(BUILD_DIR)/Makefile down
docker image rm -f $(IMAGE_NAME)

package: build run copy down
all: package checksum verify
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ Always double-check your configuration before applying changes.
> Additionally, devices running on Apple Silicon should enable Rosetta to build the package successfully. \
> Please refer to the [official Docker documentation](https://docs.docker.com/desktop/settings/mac/#general) on how to enable Rosetta in Docker Desktop for macOS.
> [!TIP]
> For instructions on manually building the package, refer to [this wiki page](https://github.com/alex-massa/ifmqtoggle/wiki/Manually-building-the-package).
Clone this repository via Git, then build the package by invoking the `make` utility on the `Makefile` within the `.build` directory:
```sh
cd .build
make
make -f .build/Makefile
```

Once finished, the build process will result in an `.ipk` package in the `.build` directory. \
Expand All @@ -30,9 +32,6 @@ opkg update
opkg install ifmqtoggle_*_all.ipk
```

> [!TIP]
> For instructions on how to build the package manually, refer to this [wiki page](https://github.com/alex-massa/ifmqtoggle/wiki/Manually-building-the-package).
## Configuration

The package configuration is managed through [UCI](https://openwrt.org/docs/guide-user/base-system/uci) and can be updated either through the CLI utility or by directly editing the configuration file found at `/etc/config/ifmqtoggle`. \
Expand Down
8 changes: 4 additions & 4 deletions src/ifmqtoggle
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ MQTT_OPTIONS=$(uci -q get ifmqtoggle."$INSTANCE".mqtt_options)

MQTT_AUTH=""
if [ -n "$MQTT_USERNAME" ]; then
MQTT_AUTH="-u $MQTT_USERNAME"
if [ -n "$MQTT_PASSWORD" ]; then
MQTT_AUTH="$MQTT_AUTH -P $MQTT_PASSWORD"
fi
MQTT_AUTH="$MQTT_AUTH -u $MQTT_USERNAME"
fi
if [ -n "$MQTT_PASSWORD" ]; then
MQTT_AUTH="$MQTT_AUTH -P $MQTT_PASSWORD"
fi

tmp=$(uci -q get ifmqtoggle."$INSTANCE".mqtt_broker_retry_delay)
Expand Down

0 comments on commit eab5539

Please sign in to comment.