Skip to content

Commit 045eb6d

Browse files
committed
Set-up packaging for Fedora 31
1 parent 6e4f80e commit 045eb6d

File tree

4 files changed

+226
-1
lines changed

4 files changed

+226
-1
lines changed

.github/workflows/ci.yml

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,54 @@ jobs:
116116
name: debian-latest
117117
path: release
118118

119+
build-f31:
120+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
121+
122+
name: Build Fedora 31 package
123+
runs-on: ubuntu-latest
124+
needs: [lint, test]
125+
container: fedora:31
126+
127+
steps:
128+
- name: Checkout code
129+
uses: actions/checkout@v2
130+
131+
- name: Install build dependencies
132+
run: |
133+
dnf distro-sync -y
134+
dnf install -y rpmdevtools rpm-sign 'dnf-command(builddep)'
135+
dnf builddep -y pkg/fedora/surface-control.spec
136+
137+
- name: Build package
138+
run: |
139+
cd pkg/fedora
140+
# Build the .rpm packages
141+
./makerpm
142+
143+
- name: Sign packages
144+
env:
145+
GPG_KEY_ID: 56C464BAAC421453
146+
GPG_KEY: ${{ secrets.SURFACE_GPG_KEY }}
147+
run: |
148+
cd pkg/fedora/out/x86_64
149+
150+
# import GPG key
151+
echo "$GPG_KEY" | base64 -d | gpg --import --no-tty --batch --yes
152+
153+
# sign package
154+
rpm --resign *.rpm --define "_gpg_name $GPG_KEY_ID"
155+
156+
- name: Upload artifacts
157+
uses: actions/upload-artifact@v1
158+
with:
159+
name: fedora-31-latest
160+
path: pkg/fedora/out/x86_64
161+
119162
release:
120163
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
121164

122165
name: Publish release
123-
needs: [build-bin, build-deb]
166+
needs: [build-bin, build-deb, build-f31]
124167
runs-on: ubuntu-latest
125168

126169
steps:
@@ -134,6 +177,11 @@ jobs:
134177
with:
135178
name: debian-latest
136179

180+
- name: Download Fedora 31 artifacts
181+
uses: actions/download-artifact@v1
182+
with:
183+
name: fedora-31-latest
184+
137185
- name: Upload assets
138186
uses: svenstaro/upload-release-action@v1-release
139187
with:

pkg/fedora/makerpm

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/bin/sh
2+
3+
# Default to using the first specfile in the current directory
4+
SPEC="*.spec"
5+
OPTS="-ba"
6+
7+
SIGN=0
8+
KEY=""
9+
10+
BUILD=".build"
11+
RPMS="out"
12+
13+
usage() {
14+
echo "Usage: $0 [OPTION]..."
15+
echo "Wrapper for rpmbuild that is easier to use."
16+
echo
17+
echo "Options:"
18+
echo " -h This help message"
19+
echo " -f The specfile to build from"
20+
echo " -c Clean the build artifacts"
21+
echo " -s Sign the produced RPM packages"
22+
echo " -k The GPG key to use for signing"
23+
exit
24+
}
25+
26+
clean() {
27+
rm -rf $BUILD
28+
rm -rf $RPMS
29+
exit
30+
}
31+
32+
while getopts ":hcsf:k:" args; do
33+
case "$args" in
34+
f)
35+
SPEC=$OPTARG
36+
;;
37+
s)
38+
SIGN=1
39+
;;
40+
k)
41+
KEY=$OPTARG
42+
;;
43+
c)
44+
clean
45+
;;
46+
h)
47+
usage
48+
;;
49+
esac
50+
done
51+
shift $((OPTIND-1))
52+
53+
if [ ! "$@" = "" ]; then
54+
OPTS="$@"
55+
fi
56+
57+
# Check if the specfile exists
58+
if [ "$(ls -f $SPEC | wc -l)" = "0" ]; then
59+
echo "ERROR: No specfile found. Specify it with the -s option."
60+
exit -2
61+
fi
62+
63+
# Check if there are too many specfiles
64+
if [ ! "$(ls -f $SPEC | wc -l)" = "1" ]; then
65+
echo "ERROR: Ambiguous matches for specfile. Please specify a single" \
66+
"file through the -s option."
67+
exit -7
68+
fi
69+
70+
# Get the directory of the specfile
71+
SPEC=$(ls -f $SPEC)
72+
DIR=$(readlink -f $(dirname $SPEC))
73+
74+
if [ ! -d "$DIR/$BUILD" ]; then
75+
mkdir "$DIR/$BUILD"
76+
fi
77+
78+
FILES=$(find $DIR -maxdepth 1);
79+
for file in $FILES; do
80+
[ "$file" = "$DIR" ] && continue
81+
[ "$file" = "$DIR/$BUILD" ] && continue
82+
[ "$file" = "$DIR/$RPMS" ] && continue
83+
84+
# this three-step process is required to properly handle symlinks to source root
85+
mkdir -p "/tmp/makerpm/$(dirname "$file")"
86+
cp -rH "$file" "/tmp/makerpm/$file"
87+
mv "/tmp/makerpm/$file" "$DIR/$BUILD"
88+
done
89+
90+
spectool \
91+
--define "_sourcedir $DIR/$BUILD" \
92+
--define "_builddir $DIR/$BUILD" \
93+
--define "_srcrpmdir $DIR/$RPMS" \
94+
--define "_rpmdir $DIR/$RPMS" \
95+
--define "_specdir $DIR" \
96+
--get-files --all \
97+
--directory $DIR/$BUILD $SPEC
98+
99+
echo
100+
101+
rpmbuild \
102+
--define "_sourcedir $DIR/$BUILD" \
103+
--define "_builddir $DIR/$BUILD" \
104+
--define "_srcrpmdir $DIR/$RPMS" \
105+
--define "_rpmdir $DIR/$RPMS" \
106+
--define "_specdir $DIR" \
107+
$OPTS $SPEC
108+
109+
if [ ! "$SIGN" = "1" ]; then
110+
exit
111+
fi
112+
113+
for file in $(find out/ -name '*.rpm'); do
114+
echo "Signing $file"
115+
if [ "$KEY" = "" ]; then
116+
rpm --resign $file 2>&1 > /dev/null
117+
else
118+
rpm --resign $file --define "_gpg_name $KEY" 2>&1 > /dev/null
119+
fi
120+
done
121+

pkg/fedora/surface-control

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../

pkg/fedora/surface-control.spec

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
Name: surface-control
2+
Version: 0.2.5
3+
Release: 1%{?dist}
4+
Summary: Control various aspects of Microsoft Surface devices from the shell
5+
6+
License: MIT
7+
URL: https://github.com/linux-surface/surface-control
8+
9+
Requires: dbus libgcc
10+
BuildRequires: rust cargo
11+
12+
%global debug_package %{nil}
13+
14+
%description
15+
Control various aspects of Microsoft Surface devices on Linux from the shell.
16+
Aims to provide a unified front-end to the various sysfs-attributes and special
17+
devices.
18+
19+
%prep
20+
21+
%build
22+
cd surface-control
23+
24+
export CARGO_TARGET_DIR="$PWD/target"
25+
export CARGO_INCREMENTAL=0
26+
27+
cargo build --release --locked
28+
strip --strip-all "target/release/surface"
29+
30+
%install
31+
rm -rf %{buildroot}
32+
install -D -m755 "surface-control/target/release/surface" "%{buildroot}/usr/bin/surface"
33+
install -D -m644 "surface-control/target/surface.bash" "%{buildroot}/usr/share/bash-completion/completions/surface"
34+
install -D -m644 "surface-control/target/_surface" "%{buildroot}/usr/share/zsh/site-functions/_surface"
35+
install -D -m644 "surface-control/target/surface.fish" "%{buildroot}/usr/share/fish/completions/surface.fish"
36+
37+
%files
38+
%license surface-control/LICENSE
39+
/usr/bin/surface
40+
/usr/share/bash-completion/completions/surface
41+
/usr/share/zsh/site-functions/_surface
42+
/usr/share/fish/completions/surface.fish
43+
44+
%changelog
45+
* Sun Dec 01 2019 Dorian Stoll <[email protected]>
46+
- Update to version 0.2.5
47+
48+
* Fri Sep 27 2019 Dorian Stoll <[email protected]>
49+
- Update packaging
50+
51+
* Sat Sep 14 2019 Dorian Stoll <[email protected]>
52+
- Update to 0.2.4
53+
54+
* Fri May 17 2019 Dorian Stoll <[email protected]>
55+
- Initial version

0 commit comments

Comments
 (0)