Skip to content

Commit

Permalink
chore: Fix rpm build; add a CI check for it.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Jan 26, 2024
1 parent 8328449 commit eeaa039
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
analysis:
strategy:
matrix:
tool: [autotools, clang-tidy, compcert, cppcheck, doxygen, goblint, infer, misra, tcc, tokstyle]
tool: [autotools, clang-tidy, compcert, cppcheck, doxygen, goblint, infer, misra, rpm, tcc, tokstyle]
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
Expand Down
47 changes: 47 additions & 0 deletions other/docker/rpm/rpm.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM toxchat/c-toxcore:sources AS sources
FROM fedora:39

RUN ["dnf", "install", "-y", \
"cmake", \
"g++", \
"gcc", \
"git", \
"libconfig-devel", \
"libsodium-devel", \
"libvpx-devel", \
"make", \
"opus-devel", \
"rpmdevtools", \
"rpmlint", \
"systemd-units"]

ARG PROJECT_VERSION=master
ARG PROJECT_COMMIT_ID=master
ARG PROJECT_COMMIT_ID_SHORT=master

COPY --from=sources /src/ /work/c-toxcore-${PROJECT_COMMIT_ID}
WORKDIR /work/c-toxcore-${PROJECT_COMMIT_ID}/other/rpm

RUN make toxcore.spec \
PROJECT_VERSION="$PROJECT_VERSION" \
PROJECT_COMMIT_ID="$PROJECT_COMMIT_ID" \
PROJECT_COMMIT_ID_SHORT="$PROJECT_COMMIT_ID_SHORT" \
PROJECT_GIT_ROOT="/work/c-toxcore-$PROJECT_COMMIT_ID_SHORT"

WORKDIR /work
RUN tar zcf "c-toxcore-${PROJECT_COMMIT_ID_SHORT}.tar.gz" "c-toxcore-${PROJECT_COMMIT_ID}" \
&& mv "c-toxcore-${PROJECT_COMMIT_ID_SHORT}.tar.gz" "c-toxcore-${PROJECT_COMMIT_ID}/other/rpm"
WORKDIR /work/c-toxcore-${PROJECT_COMMIT_ID}/other/rpm
RUN make srpm \
PROJECT_VERSION="$PROJECT_VERSION" \
PROJECT_COMMIT_ID="$PROJECT_COMMIT_ID" \
PROJECT_COMMIT_ID_SHORT="$PROJECT_COMMIT_ID_SHORT" \
PROJECT_GIT_ROOT="$PROJECT_GIT_ROOT"

# Build the binary rpms.
RUN rpmbuild --rebuild "toxcore-${PROJECT_VERSION}-1.fc39.src.rpm"

# Install them and try running the bootstrap daemon.
RUN rpm -i /root/rpmbuild/RPMS/x86_64/*.rpm
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN script tox-bootstrapd --help | grep Usage
13 changes: 13 additions & 0 deletions other/docker/rpm/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

set -eux
PROJECT_VERSION="$(git describe | sed -e 's/^v//' -e 's/-/_/g')"
PROJECT_COMMIT_ID="$(git rev-parse HEAD)"
PROJECT_COMMIT_ID_SHORT="$(git rev-parse --short HEAD)"

BUILD=rpm
other/docker/sources/build
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" . \
--build-arg="PROJECT_VERSION=$PROJECT_VERSION" \
--build-arg="PROJECT_COMMIT_ID=$PROJECT_COMMIT_ID" \
--build-arg="PROJECT_COMMIT_ID_SHORT=$PROJECT_COMMIT_ID_SHORT"
19 changes: 11 additions & 8 deletions other/rpm/toxcore.spec.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%define full_name c-@PROJECT_NAME@
%define commit 0
%if "${commit}" != "0"
%define shortcommit %(c=%{commit}; echo ${c:0:7})
%define shortcommit %(c=%{commit}; echo ${c:0:9})
%endif

Name: @PROJECT_NAME@
Expand All @@ -18,10 +18,12 @@ Source0: https://github.com/TokTok/%{full_name}/archive/%{commit}/%{full_
%endif

BuildRequires: cmake
BuildRequires: g++
BuildRequires: gcc
BuildRequires: libconfig-devel
BuildRequires: libsodium-devel
BuildRequires: libvpx-devel
BuildRequires: opus-devel
BuildRequires: libsodium-devel
BuildRequires: libconfig-devel
BuildRequires: systemd-units

%description
Expand Down Expand Up @@ -63,18 +65,18 @@ Tox DHT bootstrap daemon.

%build
%cmake
%{__make} %{?_smp_mflags}
%{__make} -C redhat-linux-build %{?_smp_mflags}

%install
%make_install
%make_install -C redhat-linux-build
mkdir -p %{buildroot}%{_unitdir}
install -m 0644 other/rpm/tox-bootstrapd.service %{buildroot}%{_unitdir}/tox-bootstrapd.service
install -d "%{buildroot}%{_sharedstatedir}/tox-bootstrapd"
mkdir -p %{buildroot}%{_sysconfdir}
install -m 0644 other/bootstrap_daemon/tox-bootstrapd.conf %{buildroot}%{_sysconfdir}/tox-bootstrapd.conf

%check
%{__make} %{?_smp_mflags} test
%{__make} -C redhat-linux-build %{?_smp_mflags} test

%pre -n tox-bootstrapd
getent group tox-bootstrapd >/dev/null || groupadd -r tox-bootstrapd
Expand All @@ -97,7 +99,7 @@ getent passwd tox-bootstrapd >/dev/null || \

%files
%defattr(-, root, root)
%doc LICENSE.md README.md CHANGELOG.md
%doc LICENSE README.md CHANGELOG.md
%{_libdir}/libtoxcore.so*

%files devel
Expand All @@ -111,9 +113,10 @@ getent passwd tox-bootstrapd >/dev/null || \

%files -n tox-bootstrapd
%defattr(-, root, root)
%{_bindir}/DHT_bootstrap
%{_bindir}/tox-bootstrapd
%{_unitdir}/tox-bootstrapd.service
%{_sharedstatedir}/tox-bootstrapd
%{_datadir}/bash-completion/completions/tox-bootstrapd
%attr(-,tox-bootstrapd,tox-bootstrapd) %{_sharedstatedir}/tox-bootstrapd/
%config(noreplace) %{_sysconfdir}/tox-bootstrapd.conf

Expand Down
2 changes: 1 addition & 1 deletion toxcore/LAN_discovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static Broadcast_Info *fetch_broadcast_info(const Network *ns)
}

/* Configure ifconf for the ioctl call. */
struct ifreq i_faces[MAX_INTERFACES] = {{0}};
struct ifreq i_faces[MAX_INTERFACES] = {{{0}}};

struct ifconf ifc;
ifc.ifc_buf = (char *)i_faces;
Expand Down
2 changes: 1 addition & 1 deletion toxcore/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ Networking_Core *new_networking_ex(

#ifndef ESP_PLATFORM
/* multicast local nodes */
struct ipv6_mreq mreq = {{0}};
struct ipv6_mreq mreq = {{{{0}}}};
mreq.ipv6mr_multiaddr.s6_addr[ 0] = 0xFF;
mreq.ipv6mr_multiaddr.s6_addr[ 1] = 0x02;
mreq.ipv6mr_multiaddr.s6_addr[15] = 0x01;
Expand Down

0 comments on commit eeaa039

Please sign in to comment.