Compare commits
23 commits
Author | SHA1 | Date | |
---|---|---|---|
3875248c83 | |||
a9adcead12 | |||
9a8528abed | |||
895d46dade | |||
1a69810bea | |||
ff01c36f88 | |||
1620d03671 | |||
c3776dfdd7 | |||
adce9ba9bc | |||
a575fbda37 | |||
2232155b9c | |||
23830523e9 | |||
43a287b307 | |||
3471e70c66 | |||
26e3dea58c | |||
44daec460b | |||
084573165c | |||
2576f4b544 | |||
5d4194d068 | |||
66c5bb84db | |||
889689a0e7 | |||
7421872586 | |||
fc1ed6e96c |
5 changed files with 342 additions and 38 deletions
|
@ -22,13 +22,16 @@ jobs:
|
||||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
-d "{
|
-d "{
|
||||||
|
\"body\": \" SHA256SUMS\",
|
||||||
\"name\": \"break_interval version ${GITHUB_REF_NAME}\",
|
\"name\": \"break_interval version ${GITHUB_REF_NAME}\",
|
||||||
\"tag_name\": \"${GITHUB_REF_NAME}\" }" 2>/dev/null > "${THE_ACTION_WORKING_DIRECTORY}/release_${GITHUB_REF_NAME}_create.json"
|
\"tag_name\": \"${GITHUB_REF_NAME}\" }" 2>/dev/null > "${THE_ACTION_WORKING_DIRECTORY}/release_${GITHUB_REF_NAME}_create.json"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ensure-releases-exists-and-push-build-x86_64:
|
push-build-x86_64:
|
||||||
needs: ensure-release-exists
|
needs: ensure-release-exists
|
||||||
runs-on: any_archLinux
|
concurrency:
|
||||||
|
group: push-build-group
|
||||||
|
runs-on: x86_64_archLinux
|
||||||
steps:
|
steps:
|
||||||
- name: Check release assets and build for x86_64
|
- name: Check release assets and build for x86_64
|
||||||
run: |
|
run: |
|
||||||
|
@ -38,7 +41,7 @@ jobs:
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/break_interval/releases/tags/${GITHUB_REF_NAME}" \
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/break_interval/releases/tags/${GITHUB_REF_NAME}" \
|
||||||
-H 'accept: application/json' -o "${THE_ACTION_WORKING_DIRECTORY}/release_info.json" 2>/dev/null
|
-H 'accept: application/json' -o "${THE_ACTION_WORKING_DIRECTORY}/release_info.json" 2>/dev/null
|
||||||
BUILD_ASSET_EXISTS=0
|
BUILD_ASSET_EXISTS=0
|
||||||
for asset in $(jq '.assets.[].name' < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json"); do
|
for asset in $(jq '.assets.[].name' < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json" | tr -d '"'); do
|
||||||
if [[ "$asset" == "$BUILD_ASSET_NAME" ]]; then
|
if [[ "$asset" == "$BUILD_ASSET_NAME" ]]; then
|
||||||
BUILD_ASSET_EXISTS=1
|
BUILD_ASSET_EXISTS=1
|
||||||
break
|
break
|
||||||
|
@ -54,17 +57,32 @@ jobs:
|
||||||
make -C buildRelease
|
make -C buildRelease
|
||||||
strip --strip-unneeded buildRelease/break_interval
|
strip --strip-unneeded buildRelease/break_interval
|
||||||
zstd --ultra -20 buildRelease/break_interval -o "${THE_ACTION_WORKING_DIRECTORY}/${BUILD_ASSET_NAME}"
|
zstd --ultra -20 buildRelease/break_interval -o "${THE_ACTION_WORKING_DIRECTORY}/${BUILD_ASSET_NAME}"
|
||||||
|
curl --fail-with-body -X GET \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/break_interval/releases/$(jq .id < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json")" \
|
||||||
|
-H 'accept: application/json' -o "${THE_ACTION_WORKING_DIRECTORY}/current_release_info.json" 2>/dev/null
|
||||||
|
curl --fail-with-body -X PATCH \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/break_interval/releases/$(jq .id < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json")" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d "{
|
||||||
|
\"body\": \"$(jq .body < "${THE_ACTION_WORKING_DIRECTORY}/current_release_info.json" | sed -e 's/^"//' -e 's/"$//')
|
||||||
|
$(find "${THE_ACTION_WORKING_DIRECTORY}" -maxdepth 1 -name "*${BUILD_ASSET_NAME}" -execdir sha256sum '{}' ';' | sed -e 's|\./break|break|')\"
|
||||||
|
}" >&/dev/null
|
||||||
curl --fail-with-body -X POST \
|
curl --fail-with-body -X POST \
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/break_interval/releases/$(jq .id < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json")/assets" \
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/break_interval/releases/$(jq .id < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json")/assets" \
|
||||||
-H 'accept: application/json' \
|
-H 'accept: application/json' \
|
||||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
-H 'Content-Type: multipart/form-data' \
|
-H 'Content-Type: multipart/form-data' \
|
||||||
-F "attachment=@${THE_ACTION_WORKING_DIRECTORY}/${BUILD_ASSET_NAME};type=application/zstd" > "${THE_ACTION_WORKING_DIRECTORY}/attach_${GITHUB_REF_NAME}.json"
|
-F "attachment=@${THE_ACTION_WORKING_DIRECTORY}/${BUILD_ASSET_NAME};type=application/zstd" > "${THE_ACTION_WORKING_DIRECTORY}/attach_${GITHUB_REF_NAME}.json" 2>/dev/null
|
||||||
popd >&/dev/null
|
popd >&/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ensure-releases-exists-and-push-build-aarch64:
|
push-build-aarch64:
|
||||||
needs: ensure-release-exists
|
if: ${{ always() }}
|
||||||
|
needs: push-build-x86_64
|
||||||
|
concurrency:
|
||||||
|
group: push-build-group
|
||||||
runs-on: aarch64_archLinux
|
runs-on: aarch64_archLinux
|
||||||
steps:
|
steps:
|
||||||
- name: Check release assets and build for aarch64
|
- name: Check release assets and build for aarch64
|
||||||
|
@ -75,7 +93,7 @@ jobs:
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/break_interval/releases/tags/${GITHUB_REF_NAME}" \
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/break_interval/releases/tags/${GITHUB_REF_NAME}" \
|
||||||
-H 'accept: application/json' -o "${THE_ACTION_WORKING_DIRECTORY}/release_info.json" 2>/dev/null
|
-H 'accept: application/json' -o "${THE_ACTION_WORKING_DIRECTORY}/release_info.json" 2>/dev/null
|
||||||
BUILD_ASSET_EXISTS=0
|
BUILD_ASSET_EXISTS=0
|
||||||
for asset in $(jq '.assets.[].name' < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json"); do
|
for asset in $(jq '.assets.[].name' < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json" | tr -d '"'); do
|
||||||
if [[ "$asset" == "$BUILD_ASSET_NAME" ]]; then
|
if [[ "$asset" == "$BUILD_ASSET_NAME" ]]; then
|
||||||
BUILD_ASSET_EXISTS=1
|
BUILD_ASSET_EXISTS=1
|
||||||
break
|
break
|
||||||
|
@ -91,11 +109,143 @@ jobs:
|
||||||
make -C buildRelease
|
make -C buildRelease
|
||||||
strip --strip-unneeded buildRelease/break_interval
|
strip --strip-unneeded buildRelease/break_interval
|
||||||
zstd --ultra -20 buildRelease/break_interval -o "${THE_ACTION_WORKING_DIRECTORY}/${BUILD_ASSET_NAME}"
|
zstd --ultra -20 buildRelease/break_interval -o "${THE_ACTION_WORKING_DIRECTORY}/${BUILD_ASSET_NAME}"
|
||||||
|
curl --fail-with-body -X GET \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/break_interval/releases/$(jq .id < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json")" \
|
||||||
|
-H 'accept: application/json' -o "${THE_ACTION_WORKING_DIRECTORY}/current_release_info.json" 2>/dev/null
|
||||||
|
curl --fail-with-body -X PATCH \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/break_interval/releases/$(jq .id < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json")" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d "{
|
||||||
|
\"body\": \"$(jq .body < "${THE_ACTION_WORKING_DIRECTORY}/current_release_info.json" | sed -e 's/^"//' -e 's/"$//')
|
||||||
|
$(find "${THE_ACTION_WORKING_DIRECTORY}" -maxdepth 1 -name "*${BUILD_ASSET_NAME}" -execdir sha256sum '{}' ';' | sed -e 's|\./break|break|')\"
|
||||||
|
}" >&/dev/null
|
||||||
curl --fail-with-body -X POST \
|
curl --fail-with-body -X POST \
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/break_interval/releases/$(jq .id < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json")/assets" \
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/break_interval/releases/$(jq .id < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json")/assets" \
|
||||||
-H 'accept: application/json' \
|
-H 'accept: application/json' \
|
||||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
-H 'Content-Type: multipart/form-data' \
|
-H 'Content-Type: multipart/form-data' \
|
||||||
-F "attachment=@${THE_ACTION_WORKING_DIRECTORY}/${BUILD_ASSET_NAME};type=application/zstd" > "${THE_ACTION_WORKING_DIRECTORY}/attach_${GITHUB_REF_NAME}.json"
|
-F "attachment=@${THE_ACTION_WORKING_DIRECTORY}/${BUILD_ASSET_NAME};type=application/zstd" > "${THE_ACTION_WORKING_DIRECTORY}/attach_${GITHUB_REF_NAME}.json" 2>/dev/null
|
||||||
popd >&/dev/null
|
popd >&/dev/null
|
||||||
fi
|
fi
|
||||||
|
push-build-x86_64_debian:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: push-build-aarch64
|
||||||
|
concurrency:
|
||||||
|
group: push-build-group
|
||||||
|
runs-on: docker_debian_bookworm
|
||||||
|
env:
|
||||||
|
BUILD_ASSET_NAME: "break_interval_x86_64_debian_${{ github.ref_name }}.zst"
|
||||||
|
steps:
|
||||||
|
- name: Update and upgrade with apt
|
||||||
|
run: apt-get --yes update && apt-get --yes upgrade
|
||||||
|
- name: Get necessary packages
|
||||||
|
run: apt-get --yes install gcc g++ jq curl cmake make zstd sed git
|
||||||
|
- name: Get release info
|
||||||
|
run: |
|
||||||
|
curl -X GET \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/break_interval/releases/tags/${GITHUB_REF_NAME}" \
|
||||||
|
-H 'accept: application/json' -o release_info.json
|
||||||
|
- name: Check if asset exists
|
||||||
|
run: |
|
||||||
|
for asset in $(jq '.assets[].name' < release_info.json | tr -d '"'); do
|
||||||
|
if [[ "$asset" == "$BUILD_ASSET_NAME" ]]; then
|
||||||
|
touch asset_exists
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
- name: Build and publish if asset does not exist
|
||||||
|
run: |
|
||||||
|
if ! [[ -e ./asset_exists ]]; then
|
||||||
|
git clone --depth=1 --no-single-branch https://git.seodisparate.com/stephenseo/break_interval.git break_interval_clone
|
||||||
|
pushd break_interval_clone >&/dev/null
|
||||||
|
|
||||||
|
git checkout "${GITHUB_REF_NAME}"
|
||||||
|
|
||||||
|
# Patch CMakeLists.txt as some flags aren't yet supported by Debian's GCC.
|
||||||
|
sed -i -e 's/-fstrict-flex-arrays=3//g' CMakeLists.txt
|
||||||
|
|
||||||
|
cmake -S . -B buildRelease -DCMAKE_BUILD_TYPE=Release
|
||||||
|
make -C buildRelease
|
||||||
|
|
||||||
|
popd >&/dev/null
|
||||||
|
zstd --ultra -20 break_interval_clone/buildRelease/break_interval -o "${BUILD_ASSET_NAME}"
|
||||||
|
|
||||||
|
curl --fail-with-body -X PATCH \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/break_interval/releases/$(jq .id < release_info.json)" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d "{
|
||||||
|
\"body\": \"$(jq .body < release_info.json | sed -e 's/^"//' -e 's/"$//')
|
||||||
|
$(sha256sum "${BUILD_ASSET_NAME}")\"
|
||||||
|
}" >&/dev/null
|
||||||
|
|
||||||
|
curl --fail-with-body -X POST \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/break_interval/releases/$(jq .id < release_info.json)/assets" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
-H 'Content-Type: multipart/form-data' \
|
||||||
|
-F "attachment=@${BUILD_ASSET_NAME};type=application/zstd" > attach.json 2>/dev/null
|
||||||
|
fi
|
||||||
|
push-build-aarch64_debian:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: push-build-x86_64_debian
|
||||||
|
concurrency:
|
||||||
|
group: push-build-group
|
||||||
|
runs-on: aarch64_docker_debian_bookworm
|
||||||
|
env:
|
||||||
|
BUILD_ASSET_NAME: "break_interval_aarch64_debian_${{ github.ref_name }}.zst"
|
||||||
|
steps:
|
||||||
|
- name: Update and upgrade with apt
|
||||||
|
run: apt-get --yes update && apt-get --yes upgrade
|
||||||
|
- name: Get necessary packages
|
||||||
|
run: apt-get --yes install gcc g++ jq curl cmake make zstd sed git
|
||||||
|
- name: Get release info
|
||||||
|
run: |
|
||||||
|
curl -X GET \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/break_interval/releases/tags/${GITHUB_REF_NAME}" \
|
||||||
|
-H 'accept: application/json' -o release_info.json
|
||||||
|
- name: Check if asset exists
|
||||||
|
run: |
|
||||||
|
for asset in $(jq '.assets[].name' < release_info.json | tr -d '"'); do
|
||||||
|
if [[ "$asset" == "$BUILD_ASSET_NAME" ]]; then
|
||||||
|
touch asset_exists
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
- name: Build and publish if asset does not exist
|
||||||
|
run: |
|
||||||
|
if ! [[ -e ./asset_exists ]]; then
|
||||||
|
git clone --depth=1 --no-single-branch https://git.seodisparate.com/stephenseo/break_interval.git break_interval_clone
|
||||||
|
pushd break_interval_clone >&/dev/null
|
||||||
|
|
||||||
|
git checkout "${GITHUB_REF_NAME}"
|
||||||
|
|
||||||
|
# Patch CMakeLists.txt as some flags aren't yet supported by Debian's GCC.
|
||||||
|
sed -i -e 's/-fstrict-flex-arrays=3//g' CMakeLists.txt
|
||||||
|
|
||||||
|
cmake -S . -B buildRelease -DCMAKE_BUILD_TYPE=Release
|
||||||
|
make -C buildRelease
|
||||||
|
|
||||||
|
popd >&/dev/null
|
||||||
|
zstd --ultra -20 break_interval_clone/buildRelease/break_interval -o "${BUILD_ASSET_NAME}"
|
||||||
|
|
||||||
|
curl --fail-with-body -X PATCH \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/break_interval/releases/$(jq .id < release_info.json)" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d "{
|
||||||
|
\"body\": \"$(jq .body < release_info.json | sed -e 's/^"//' -e 's/"$//')
|
||||||
|
$(sha256sum "${BUILD_ASSET_NAME}")\"
|
||||||
|
}" >&/dev/null
|
||||||
|
|
||||||
|
curl --fail-with-body -X POST \
|
||||||
|
"https://git.seodisparate.com/api/v1/repos/stephenseo/break_interval/releases/$(jq .id < release_info.json)/assets" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
-H 'Content-Type: multipart/form-data' \
|
||||||
|
-F "attachment=@${BUILD_ASSET_NAME};type=application/zstd" > attach.json 2>/dev/null
|
||||||
|
fi
|
||||||
|
|
|
@ -8,8 +8,6 @@ add_executable(break_interval ${break_interval_SOURCES})
|
||||||
|
|
||||||
add_compile_options(
|
add_compile_options(
|
||||||
-Wall -Wextra -Wpedantic -Wno-missing-braces
|
-Wall -Wextra -Wpedantic -Wno-missing-braces
|
||||||
$<$<COMPILE_LANGUAGE:CXX>:-Weffc++>
|
|
||||||
$<$<CONFIG:DEBUG>:-Og>
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||||
|
@ -17,3 +15,49 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||||
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
|
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
|
||||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
target_compile_options(break_interval PUBLIC
|
||||||
|
-Wall -Wformat -Wformat=2 -Wconversion -Wimplicit-fallthrough
|
||||||
|
-Werror=format-security
|
||||||
|
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3
|
||||||
|
-D_GLIBCXX_ASSERTIONS
|
||||||
|
-fstrict-flex-arrays=3
|
||||||
|
-fstack-clash-protection -fstack-protector-strong
|
||||||
|
-Wl,-z,nodlopen -Wl,-z,noexecstack
|
||||||
|
-Wl,-z,relro -Wl,-z,now
|
||||||
|
-Wl,--as-needed -Wl,--no-copy-dt-needed-entries
|
||||||
|
-fPIE -pie
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_options(break_interval PUBLIC
|
||||||
|
-Wall -Wformat -Wformat=2 -Wconversion -Wimplicit-fallthrough
|
||||||
|
-Werror=format-security
|
||||||
|
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3
|
||||||
|
-D_GLIBCXX_ASSERTIONS
|
||||||
|
-fstrict-flex-arrays=3
|
||||||
|
-fstack-clash-protection -fstack-protector-strong
|
||||||
|
-Wl,-z,nodlopen -Wl,-z,noexecstack
|
||||||
|
-Wl,-z,relro -Wl,-z,now
|
||||||
|
-Wl,--as-needed -Wl,--no-copy-dt-needed-entries
|
||||||
|
-fPIE -pie
|
||||||
|
)
|
||||||
|
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||||
|
target_compile_options(break_interval PUBLIC
|
||||||
|
-O3
|
||||||
|
-fno-delete-null-pointer-checks -fno-strict-overflow
|
||||||
|
-fno-strict-aliasing -ftrivial-auto-var-init=zero
|
||||||
|
)
|
||||||
|
target_link_options(break_interval PUBLIC
|
||||||
|
-O3
|
||||||
|
-fno-delete-null-pointer-checks -fno-strict-overflow
|
||||||
|
-fno-strict-aliasing -ftrivial-auto-var-init=zero
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
target_compile_options(break_interval PUBLIC
|
||||||
|
-Og
|
||||||
|
)
|
||||||
|
target_link_options(break_interval PUBLIC
|
||||||
|
-Og
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
31
Changelog.md
31
Changelog.md
|
@ -2,6 +2,37 @@
|
||||||
|
|
||||||
## Upcoming Changes
|
## Upcoming Changes
|
||||||
|
|
||||||
|
## Version 1.3.4
|
||||||
|
|
||||||
|
Fix Debian build in workflow/action. This means that the debian-built releases
|
||||||
|
should be fixed now.
|
||||||
|
|
||||||
|
## Version 1.3.3
|
||||||
|
|
||||||
|
Minor tweak to action/workflow for release assets.
|
||||||
|
Compiler hardening flags, fixes related to flags.
|
||||||
|
Internal change: make flag used by signal "volatile" (doesn't change much for
|
||||||
|
users).
|
||||||
|
|
||||||
|
## Version 1.3.2
|
||||||
|
|
||||||
|
Updated action/workflow to build for Debian aarch64.
|
||||||
|
|
||||||
|
Minor fixes to action/workflow.
|
||||||
|
|
||||||
|
## Version 1.3.1
|
||||||
|
|
||||||
|
Updated action/workflow to build for Debian x86_64.
|
||||||
|
|
||||||
|
Minor fixes to action/workflow.
|
||||||
|
|
||||||
|
## Version 1.3
|
||||||
|
|
||||||
|
More tweaks to README.
|
||||||
|
|
||||||
|
Allow playing internal file even if custom player command is specified.
|
||||||
|
Do this by specifying "INTERNAL_FILE" as the filename parameter.
|
||||||
|
|
||||||
## Version 1.2
|
## Version 1.2
|
||||||
|
|
||||||
Minor tweaks to help text, README.
|
Minor tweaks to help text, README.
|
||||||
|
|
24
README.md
24
README.md
|
@ -12,3 +12,27 @@ jingle plays.
|
||||||
|
|
||||||
Running the program with no args will default to playing a jingle every 5
|
Running the program with no args will default to playing a jingle every 5
|
||||||
minutes.
|
minutes.
|
||||||
|
|
||||||
|
If `[player_program]` is specified (with full path) like with
|
||||||
|
`/usr/bin/ffplay`, then the command executed will look like:
|
||||||
|
|
||||||
|
/usr/bin/ffplay <file_to_play>
|
||||||
|
|
||||||
|
If `[player_args...]` is specified like with `--flag` and `--another-flag`, then
|
||||||
|
the command executed will look like:
|
||||||
|
|
||||||
|
/usr/bin/ffplay --flag --another-flag <file_to_play>
|
||||||
|
|
||||||
|
It may be recommended to use a command like:
|
||||||
|
|
||||||
|
./break_interval 5 /my/music/file.mp3 /usr/bin/ffplay -nodisp
|
||||||
|
|
||||||
|
Which will execute (every 5 minutes):
|
||||||
|
|
||||||
|
/usr/bin/ffplay -nodisp /my/music/file.mp3
|
||||||
|
|
||||||
|
To play the internal file instead of a specified one, use the parameter
|
||||||
|
"INTERNAL_FILE" for the filename and break\_interval will play the internal
|
||||||
|
file.
|
||||||
|
|
||||||
|
./break_interval 5 INTERNAL_FILE /usr/bin/ffplay -nodisp
|
||||||
|
|
95
src/main.c
95
src/main.c
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#define DEFAULT_FILE_PLAYER_PROGRAM "/usr/bin/mpv"
|
#define DEFAULT_FILE_PLAYER_PROGRAM "/usr/bin/mpv"
|
||||||
|
|
||||||
int is_running;
|
volatile int is_running;
|
||||||
|
|
||||||
void interval_notification_handle_signal(int sig) {
|
void interval_notification_handle_signal(int sig) {
|
||||||
if (sig == SIGINT) {
|
if (sig == SIGINT) {
|
||||||
|
@ -26,13 +26,22 @@ void interval_notification_handle_signal(int sig) {
|
||||||
int play_jingle_from_file(char *player,
|
int play_jingle_from_file(char *player,
|
||||||
char **player_args,
|
char **player_args,
|
||||||
unsigned int args_count,
|
unsigned int args_count,
|
||||||
char *jingle_filename) {
|
char *jingle_filename,
|
||||||
|
int use_internal_file_specified) {
|
||||||
|
int pipe_filedes[2];
|
||||||
|
if (use_internal_file_specified == 0) {
|
||||||
int jingle_fd = open(jingle_filename, O_RDONLY);
|
int jingle_fd = open(jingle_filename, O_RDONLY);
|
||||||
if (jingle_fd == -1) {
|
if (jingle_fd == -1) {
|
||||||
puts("ERROR: Failed to play jingle: Failed to open file!");
|
puts("ERROR: Failed to play jingle: Failed to open file!");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
close(jingle_fd);
|
close(jingle_fd);
|
||||||
|
} else {
|
||||||
|
if (pipe(pipe_filedes) != 0) {
|
||||||
|
puts("ERROR: Failed to play jingle: Failed to create pipe!");
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch(fork()) {
|
switch(fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
|
@ -48,10 +57,23 @@ int play_jingle_from_file(char *player,
|
||||||
dup2(null_fd, 1);
|
dup2(null_fd, 1);
|
||||||
dup2(null_fd, 2);
|
dup2(null_fd, 2);
|
||||||
|
|
||||||
|
if (use_internal_file_specified != 0) {
|
||||||
|
// Handle pipe into stdin.
|
||||||
|
close(pipe_filedes[1]);
|
||||||
|
dup2(pipe_filedes[0], 0);
|
||||||
|
jingle_filename = "/dev/stdin";
|
||||||
|
}
|
||||||
|
|
||||||
// Exec.
|
// Exec.
|
||||||
if (args_count == 0 && strcmp(player, "/usr/bin/mpv") == 0) {
|
if (args_count == 0 && strcmp(player, "/usr/bin/mpv") == 0) {
|
||||||
if (execl(player, player, "--vid=no", jingle_filename, (char*)NULL) == -1) {
|
if (execl(player,
|
||||||
printf("ERROR: Failed to play with player \"%s\" and jingle \"%s\"!\n", player, jingle_filename);
|
player,
|
||||||
|
"--vid=no",
|
||||||
|
jingle_filename,
|
||||||
|
(char*)NULL)
|
||||||
|
== -1) {
|
||||||
|
printf("ERROR: Failed to play with player \"%s\" and jingle \"%s\"!\n",
|
||||||
|
player, jingle_filename);
|
||||||
close(null_fd);
|
close(null_fd);
|
||||||
exit(5);
|
exit(5);
|
||||||
}
|
}
|
||||||
|
@ -71,7 +93,7 @@ int play_jingle_from_file(char *player,
|
||||||
printf("ERROR: Failed to play with player \"%s\"!\n", player);
|
printf("ERROR: Failed to play with player \"%s\"!\n", player);
|
||||||
free(argvs);
|
free(argvs);
|
||||||
close(null_fd);
|
close(null_fd);
|
||||||
exit(4);
|
exit(6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +102,16 @@ int play_jingle_from_file(char *player,
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Intentionally left blank.
|
if (use_internal_file_specified != 0) {
|
||||||
|
close(pipe_filedes[0]);
|
||||||
|
ssize_t ret = write(pipe_filedes[1],
|
||||||
|
interval_notification_mp3,
|
||||||
|
interval_notification_mp3_len);
|
||||||
|
if (ret != interval_notification_mp3_len) {
|
||||||
|
fprintf(stderr, "WARNING: Did not write all bytes of mp3 to player!\n");
|
||||||
|
}
|
||||||
|
close(pipe_filedes[1]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,8 +119,7 @@ int play_jingle_from_file(char *player,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Only supports playing with /usr/bin/mpv .
|
/// Only supports playing with /usr/bin/mpv .
|
||||||
int play_jingle_from_memory(const char *jingle_data,
|
int play_jingle_from_memory(void) {
|
||||||
int jingle_size) {
|
|
||||||
int pipe_filedes[2];
|
int pipe_filedes[2];
|
||||||
if (pipe(pipe_filedes) != 0) {
|
if (pipe(pipe_filedes) != 0) {
|
||||||
puts("ERROR: Failed to play jingle: Failed to create pipe!");
|
puts("ERROR: Failed to play jingle: Failed to create pipe!");
|
||||||
|
@ -116,7 +146,12 @@ int play_jingle_from_memory(const char *jingle_data,
|
||||||
dup2(null_fd, 2);
|
dup2(null_fd, 2);
|
||||||
|
|
||||||
// Exec.
|
// Exec.
|
||||||
if (execl("/usr/bin/mpv", "/usr/bin/mpv", "--vid=no", "-", (char*)NULL) == -1) {
|
if (execl("/usr/bin/mpv",
|
||||||
|
"/usr/bin/mpv",
|
||||||
|
"--vid=no",
|
||||||
|
"-",
|
||||||
|
(char*)NULL)
|
||||||
|
== -1) {
|
||||||
printf("ERROR: Failed to play!\n");
|
printf("ERROR: Failed to play!\n");
|
||||||
close(pipe_filedes[0]);
|
close(pipe_filedes[0]);
|
||||||
close(null_fd);
|
close(null_fd);
|
||||||
|
@ -129,9 +164,16 @@ int play_jingle_from_memory(const char *jingle_data,
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
{
|
||||||
close(pipe_filedes[0]);
|
close(pipe_filedes[0]);
|
||||||
write(pipe_filedes[1], jingle_data, jingle_size);
|
ssize_t ret = write(pipe_filedes[1],
|
||||||
|
interval_notification_mp3,
|
||||||
|
interval_notification_mp3_len);
|
||||||
|
if (ret != interval_notification_mp3_len) {
|
||||||
|
fprintf(stderr, "WARNING: Did not write all bytes of mp3 to player!\n");
|
||||||
|
}
|
||||||
close(pipe_filedes[1]);
|
close(pipe_filedes[1]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,11 +193,13 @@ int main(int argc, char **argv) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int minutes = 5;
|
unsigned int minutes;
|
||||||
|
int temp_minutes = 5;
|
||||||
char *file_name = NULL;
|
char *file_name = NULL;
|
||||||
char *player_name = NULL;
|
char *player_name = NULL;
|
||||||
char **player_args = NULL;
|
char **player_args = NULL;
|
||||||
unsigned int args_count = 0;
|
unsigned int args_count = 0;
|
||||||
|
int use_internal_file_specified = 0;
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
// Intentionally left blank.
|
// Intentionally left blank.
|
||||||
|
@ -165,36 +209,47 @@ int main(int argc, char **argv) {
|
||||||
print_help();
|
print_help();
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
minutes = atoi(argv[1]);
|
temp_minutes = atoi(argv[1]);
|
||||||
} else if (argc == 3) {
|
} else if (argc == 3) {
|
||||||
minutes = atoi(argv[1]);
|
temp_minutes = atoi(argv[1]);
|
||||||
file_name = argv[2];
|
file_name = argv[2];
|
||||||
} else if (argc == 4) {
|
} else if (argc == 4) {
|
||||||
minutes = atoi(argv[1]);
|
temp_minutes = atoi(argv[1]);
|
||||||
file_name = argv[2];
|
file_name = argv[2];
|
||||||
player_name = argv[3];
|
player_name = argv[3];
|
||||||
} else if (argc > 4) {
|
} else if (argc > 4) {
|
||||||
minutes = atoi(argv[1]);
|
temp_minutes = atoi(argv[1]);
|
||||||
file_name = argv[2];
|
file_name = argv[2];
|
||||||
player_name = argv[3];
|
player_name = argv[3];
|
||||||
player_args = argv + 4;
|
player_args = argv + 4;
|
||||||
args_count = argc - 4;
|
args_count = (unsigned int)(argc - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minutes == 0) {
|
if (temp_minutes == 0) {
|
||||||
puts("ERROR: Minutes cannot be set to zero!");
|
puts("ERROR: Minutes cannot be set to zero!");
|
||||||
print_help();
|
print_help();
|
||||||
return 3;
|
return 3;
|
||||||
|
} else if (temp_minutes < 0) {
|
||||||
|
puts("ERROR: Minutes cannot be negative!");
|
||||||
|
print_help();
|
||||||
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
minutes = (unsigned int)temp_minutes;
|
||||||
|
|
||||||
printf("Set to %u minutes...\n", minutes);
|
printf("Set to %u minutes...\n", minutes);
|
||||||
if (player_name) {
|
if (player_name) {
|
||||||
printf("Using player \"%s\"...\n", player_name);
|
printf("Using player \"%s\"...\n", player_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_name) {
|
if (file_name) {
|
||||||
|
if (strcmp(file_name, "INTERNAL_FILE") == 0) {
|
||||||
|
puts("Using internal file...");
|
||||||
|
use_internal_file_specified = 1;
|
||||||
|
} else {
|
||||||
printf("Using file \"%s\"...\n", file_name);
|
printf("Using file \"%s\"...\n", file_name);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Setup for loop
|
// Setup for loop
|
||||||
is_running = 1;
|
is_running = 1;
|
||||||
|
@ -221,10 +276,10 @@ int main(int argc, char **argv) {
|
||||||
player_name : DEFAULT_FILE_PLAYER_PROGRAM,
|
player_name : DEFAULT_FILE_PLAYER_PROGRAM,
|
||||||
player_args,
|
player_args,
|
||||||
args_count,
|
args_count,
|
||||||
file_name);
|
file_name,
|
||||||
|
use_internal_file_specified);
|
||||||
} else {
|
} else {
|
||||||
ret = play_jingle_from_memory(interval_notification_mp3,
|
ret = play_jingle_from_memory();
|
||||||
interval_notification_mp3_len);
|
|
||||||
}
|
}
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
printf("ERROR: Failed to play jingle! (returned \"%i\")\n", ret);
|
printf("ERROR: Failed to play jingle! (returned \"%i\")\n", ret);
|
||||||
|
|
Loading…
Reference in a new issue