Skip to content

Commit e199764

Browse files
authored
Merge pull request #113 from EmixamPP/selinux
Remove required SELinux fix
2 parents 6ca2a12 + 65da1bb commit e199764

7 files changed

Lines changed: 171 additions & 74 deletions

File tree

.github/comment/failed_build.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- build comment -->
2+
![badge](https://img.shields.io/badge/CI-failed-red)
3+
4+
Build or lint failed. Check the logs below.
5+
6+
| | |
7+
| ------ | -------------------------------- |
8+
| Commit | {{ .commit }} |
9+
| Logs | {{ .logs | mdlink "View Logs" }} |
10+
11+
This comment is updated automatically.

.github/comment/success_build.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!-- build comment -->
2+
![Badge](https://img.shields.io/badge/CI-passed-green)
3+
4+
You can find a link to the downloadable tarball below.
5+
6+
| | |
7+
| ---------- | --------------------------------------------- |
8+
| Commit | {{ .commit }} |
9+
| Logs | {{ .logs | mdlink "View Logs" }} |
10+
| Download | {{ .download | mdlink "Download Tarball" }} |
11+
| Expiration | {{ .expire | date "02 Jan 2006 15:04 CEST" }} |
12+
13+
To install it, execute `sudo tar -C / --no-same-owner -h -xzf linux-enable-ir-emitter.tar.gz`.
14+
15+
This comment is updated automatically.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build, Lint and Pack
1+
name: Build, Lint, Pack
22

33
on:
44
workflow_dispatch:
@@ -45,7 +45,7 @@ jobs:
4545
run: |
4646
DESTDIR=install_dir meson install -C build
4747
tar -czvf build/linux-enable-ir-emitter.tar.gz -C build/install_dir .
48-
48+
4949
- name: Upload tarball
5050
uses: actions/upload-artifact@v3
5151
with:

.github/workflows/pr-comment.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Pull Request Comment
2+
3+
on:
4+
workflow_run:
5+
types:
6+
- completed
7+
workflows:
8+
- Pull Request
9+
10+
jobs:
11+
comment:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Get tarball link and pull request info
17+
env:
18+
GITHUB_TOKEN: ${{ github.token }}
19+
WORKFLOW_RUN_EVENT_OBJ: ${{ toJSON(github.event.workflow_run) }}
20+
OWNER: ${{ github.repository_owner }}
21+
REPO: ${{ github.event.repository.name }}
22+
run: |
23+
PREVIOUS_JOB_ID=$(jq -r '.id' <<< "$WORKFLOW_RUN_EVENT_OBJ")
24+
echo "Previous Job ID: $PREVIOUS_JOB_ID"
25+
echo "PREVIOUS_JOB_ID=$PREVIOUS_JOB_ID" >> "$GITHUB_ENV"
26+
27+
SUITE_ID=$(jq -r '.check_suite_id' <<< "$WORKFLOW_RUN_EVENT_OBJ")
28+
echo "Previous Suite ID: $SUITE_ID"
29+
echo "SUITE_ID=$SUITE_ID" >> "$GITHUB_ENV"
30+
31+
ARTIFACT_ID=$(gh api "/repos/$OWNER/$REPO/actions/artifacts" \
32+
--jq ".artifacts.[] |
33+
select(.workflow_run.id==${PREVIOUS_JOB_ID}) |
34+
select(.expired==false) |
35+
.id")
36+
37+
echo "Artifact ID: $ARTIFACT_ID"
38+
echo "ARTIFACT_ID=$ARTIFACT_ID" >> "$GITHUB_ENV"
39+
40+
ARTIFACT_EXPIRE_DATE=$(gh api "/repos/$OWNER/$REPO/actions/artifacts" \
41+
--jq ".artifacts.[] |
42+
select(.workflow_run.id==${PREVIOUS_JOB_ID}) |
43+
select(.expired==false) |
44+
.expires_at")
45+
46+
echo "Artifact Expire Date: $ARTIFACT_EXPIRE_DATE"
47+
echo "ARTIFACT_EXPIRE_DATE=$ARTIFACT_EXPIRE_DATE" >> "$GITHUB_ENV"
48+
49+
PR_NUMBER=$(jq -r '.pull_requests[0].number' \
50+
<<< "$WORKFLOW_RUN_EVENT_OBJ")
51+
52+
echo "Pull request Number: $PR_NUMBER"
53+
echo "PR_NUMBER=$PR_NUMBER" >> "$GITHUB_ENV"
54+
55+
HEAD_SHA=$(jq -r '.pull_requests[0].head.sha' \
56+
<<< "$WORKFLOW_RUN_EVENT_OBJ")
57+
58+
echo "Head SHA: $HEAD_SHA"
59+
echo "HEAD_SHA=$HEAD_SHA" >> "$GITHUB_ENV"
60+
61+
- name: Find comment
62+
uses: peter-evans/find-comment@v2.4.0
63+
id: find-comment
64+
with:
65+
issue-number: ${{ env.PR_NUMBER }}
66+
comment-author: 'github-actions[bot]'
67+
body-includes: '<!-- build comment -->'
68+
69+
- name: Create message
70+
id: message
71+
uses: chuhlomin/render-template@v1.7
72+
env:
73+
JOB_PATH: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ env.PREVIOUS_JOB_ID }}"
74+
ARTIFACT_URL: "https://nightly.link/${{ github.repository }}/suites/${{ env.SUITE_ID }}/artifacts/${{ env.ARTIFACT_ID }}"
75+
ARTIFACT_EXPIRE_DATE: "${{ env.ARTIFACT_EXPIRE_DATE }}"
76+
HEAD_SHA: "${{ env.HEAD_SHA }}"
77+
with:
78+
template: ${{ github.event.workflow_run.conclusion =='success' && './.github/comment/success_build.md' || './.github/comment/failed_build.md'}}
79+
timezone: Europe/Brussels
80+
vars: |
81+
commit: ${{ env.HEAD_SHA }}
82+
logs: ${{ env.JOB_PATH }}
83+
download: ${{ env.ARTIFACT_URL }}
84+
expire: ${{ env.ARTIFACT_EXPIRE_DATE }}
85+
86+
- name: Update Comment
87+
uses: peter-evans/create-or-update-comment@v3.0.2
88+
with:
89+
issue-number: ${{ env.PR_NUMBER }}
90+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
91+
edit-mode: replace
92+
body: ${{ steps.message.outputs.result }}

.github/workflows/pr.yml

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,8 @@
1-
name: Pull request
1+
name: Pull Request
22

3-
on:
3+
on:
44
pull_request:
5-
5+
66
jobs:
77
ci:
8-
uses: ./.github/workflows/main.yml
9-
10-
comment-tarball:
11-
runs-on: ubuntu-latest
12-
needs: ci
13-
steps:
14-
- name: Send tarball link
15-
uses: actions/github-script@v4
16-
with:
17-
github-token: ${{ secrets.GITHUB_TOKEN }}
18-
script: |
19-
const tarballLink = $(curl --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
20-
--header "Accept: application/vnd.github.v3+json" \
21-
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" | \
22-
jq -r '.artifacts[0].archive_download_url')
23-
24-
const downloadMsg = `The tarball is available for download [here](${tarballLink}).`
25-
const installMsg = 'To install it, execute \`sudo tar -C / --no-same-owner -h -xzf linux-enable-ir-emitter.tar.gz\`.'
26-
27-
github.issues.createComment({
28-
issue_number: context.issue.number,
29-
owner: context.repo.owner,
30-
repo: context.repo.repo,
31-
body: `${downloadMsg}\n${installMsg}`
32-
});
8+
uses: ./.github/workflows/ci.yml

README.md

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,15 @@ Download the latest `linux-enable-ir-emitter-x.x.x.tar.gz` archive [here](https:
1717
sudo tar -C / --no-same-owner -h -xzf linux-enable-ir-emitter-*.tar.gz
1818
```
1919

20-
If you are under Fedora or any system with SELinux, also execute:
21-
```
22-
semanage fcontext -a -t bin_t /usr/lib/linux-enable-ir-emitter/bin/execute-driver
23-
semanage fcontext -a -t bin_t /usr/lib/linux-enable-ir-emitter/bin/driver-generator
24-
restorecon -v /usr/lib64/linux-enable-ir-emitter/bin/*
25-
```
26-
2720
It can be uninstalled by executing:
2821
```
29-
sudo rm -r /usr/lib64/linux-enable-ir-emitter
30-
sudo rm -r /etc/linux-enable-ir-emitter
31-
sudo rm /usr/bin/linux-enable-ir-emitter
32-
sudo rm /usr/lib/systemd/system/linux-enable-ir-emitter.service
33-
sudo rm -f /etc/udev/rules.d/99-linux-enable-ir-emitter.rules
34-
sudo rm /usr/share/bash-completition/completitions/linux-enable-ir-emitter
22+
sudo rm -rf /usr/lib64/linux-enable-ir-emitter \
23+
/etc/linux-enable-ir-emitter \
24+
/usr/bin/liblinux-enable-ir-emitter \
25+
/usr/bin/linux-enable-ir-emitter \
26+
/usr/lib/systemd/system/linux-enable-ir-emitter.service \
27+
/etc/udev/rules.d/99-linux-enable-ir-emitter.rules \
28+
/usr/share/bash-completition/completitions/linux-enable-ir-emitter
3529
```
3630

3731
### Manual build :
@@ -64,13 +58,6 @@ Install linux-enable-ir-emitter:
6458
sudo meson install -C build
6559
```
6660

67-
If you are under Fedora or any system with SELinux, also execute:
68-
```
69-
semanage fcontext -a -t bin_t /usr/lib/linux-enable-ir-emitter/bin/execute-driver
70-
semanage fcontext -a -t bin_t /usr/lib/linux-enable-ir-emitter/bin/driver-generator
71-
restorecon -v /usr/lib64/linux-enable-ir-emitter/bin/*
72-
```
73-
7461
You can uninstall the software by executing `sudo ninja uninstall -C build`.
7562

7663
## How to enable your infrared emitter ?

meson.build

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ project(
1313

1414
opencv_dep = dependency('opencv4', static: true)
1515

16-
lib_dir = get_option('libdir') / meson.project_name()
17-
lib_bin_dir = lib_dir / 'bin'
18-
sysconf_dir = get_option('sysconfdir')
19-
autocomplete_dir = get_option('datadir') / 'bash-completion/completions'
20-
boot_service = get_option('boot_service')
21-
systemd_dir = 'lib/systemd/system'
22-
openrc_dir = '/etc/init.d'
16+
################
17+
# Lib executable
18+
################
19+
lib_bin_dir = get_option('bindir') / 'lib' + meson.project_name()
2320

2421
executable(
2522
'driver-generator',
@@ -44,6 +41,11 @@ executable(
4441
install_dir: lib_bin_dir,
4542
)
4643

44+
#####
45+
# Lib
46+
#####
47+
lib_dir = get_option('libdir') / meson.project_name()
48+
4749
configure_version_data = configuration_data({'version': meson.project_version()})
4850
configure_file(
4951
input : 'sources/linux-enable-ir-emitter.py',
@@ -54,14 +56,10 @@ configure_file(
5456
install_mode: 'rwxr-xr-x',
5557
)
5658

57-
install_symlink(
58-
meson.project_name(),
59-
pointing_to: '../' / lib_dir / 'linux-enable-ir-emitter.py',
60-
install_dir: get_option('bindir'),
61-
)
59+
boot_service = get_option('boot_service')
6260

6361
configure_paths_data = configuration_data({
64-
'SAVE_DRIVER_FOLDER_PATH': sysconf_dir / meson.project_name(),
62+
'SAVE_DRIVER_FOLDER_PATH': get_option('sysconfdir') / meson.project_name(),
6563
'BIN_EXECUTE_DRIVER_PATH': '/usr' / lib_bin_dir / 'execute-driver',
6664
'BIN_DRIVER_GENERATOR_PATH': '/usr' / lib_bin_dir / 'driver-generator',
6765
'UDEV_RULE_PATH': '/etc/udev/rules.d/99-linux-enable-ir-emitter.rules',
@@ -80,6 +78,12 @@ configure_file(
8078
install_dir : lib_dir,
8179
)
8280

81+
install_data(
82+
'sources/boot_service/__init__.py',
83+
'sources/boot_service/base_boot_service.py',
84+
install_dir : lib_dir / 'boot_service',
85+
)
86+
8387
install_data(
8488
'LICENSE',
8589
'README.md',
@@ -95,17 +99,18 @@ install_data(
9599
install_dir : lib_dir / 'command',
96100
)
97101

98-
install_subdir(
102+
############
103+
# Executable
104+
############
105+
install_symlink(
99106
meson.project_name(),
100-
install_dir: sysconf_dir,
101-
)
102-
103-
install_data(
104-
'sources/boot_service/__init__.py',
105-
'sources/boot_service/base_boot_service.py',
106-
install_dir : lib_dir / 'boot_service',
107+
pointing_to: '../' / lib_dir / 'linux-enable-ir-emitter.py',
108+
install_dir: get_option('bindir'),
107109
)
108110

111+
##############
112+
# Boot service
113+
##############
109114
if boot_service == 'systemd'
110115
install_data(
111116
'sources/boot_service/systemd/__init__.py',
@@ -114,7 +119,7 @@ if boot_service == 'systemd'
114119
)
115120
install_data(
116121
'sources/boot_service/systemd/linux-enable-ir-emitter.service',
117-
install_dir : systemd_dir,
122+
install_dir : 'lib/systemd/system',
118123
)
119124
elif boot_service == 'openrc'
120125
install_data(
@@ -124,11 +129,22 @@ elif boot_service == 'openrc'
124129
)
125130
install_data(
126131
'sources/boot_service/openrc/linux-enable-ir-emitter',
127-
install_dir : openrc_dir,
132+
install_dir : '/etc/init.d',
128133
)
129134
endif
130135

136+
######
137+
# Conf
138+
######
139+
install_subdir(
140+
meson.project_name(),
141+
install_dir: get_option('sysconfdir'),
142+
)
143+
144+
##################
145+
# Shell completion
146+
##################
131147
install_data(
132148
'sources/autocomplete/linux-enable-ir-emitter',
133-
install_dir : autocomplete_dir,
149+
install_dir : get_option('datadir') / 'bash-completion/completions',
134150
)

0 commit comments

Comments
 (0)