Skip to content

Commit 3c92253

Browse files
committed
Update for bookworm (WIP)
1 parent a1f94ad commit 3c92253

File tree

30 files changed

+137
-374
lines changed

30 files changed

+137
-374
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG BASE_IMAGE=debian:bullseye
1+
ARG BASE_IMAGE=debian:bookworm
22
FROM ${BASE_IMAGE}
33

44
ENV DEBIAN_FRONTEND noninteractive
@@ -10,7 +10,7 @@ RUN apt-get -y update && \
1010
libarchive-tools libcap2-bin rsync grep udev xz-utils curl xxd file kmod bc\
1111
binfmt-support ca-certificates qemu-utils kpartx fdisk gpg pigz\
1212
crossbuild-essential-arm64 \
13-
build-essential cmake python3 python3-distutils python3-jinja2 ant sudo openjdk-17-jdk \
13+
build-essential cmake ninja-build protobuf-compiler python3 python3-distutils python3-jinja2 ant sudo openjdk-17-jdk \
1414
&& rm -rf /var/lib/apt/lists/*
1515

1616
COPY . /pi-gen/

build-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fi
9595
# Modify original build-options to allow config file to be mounted in the docker container
9696
BUILD_OPTS="$(echo "${BUILD_OPTS:-}" | sed -E 's@\-c\s?([^ ]+)@-c /config@')"
9797

98-
${DOCKER} build --build-arg BASE_IMAGE=debian:bullseye -t pi-gen "${DIR}"
98+
${DOCKER} build --build-arg BASE_IMAGE=debian:bookworm -t pi-gen "${DIR}"
9999

100100
if [ "${CONTAINER_EXISTS}" != "" ]; then
101101
DOCKER_CMDLINE_NAME="${CONTAINER_NAME}_cont"

deps/tools/configServer/src/Application.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
#include <string_view>
1212

1313
#include <wpi/Signal.h>
14-
15-
namespace wpi {
16-
class json;
17-
} // namespace wpi
14+
#include <wpi/json_fwd.h>
1815

1916
class UploadHelper;
2017

deps/tools/configServer/src/NetworkSettings.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <unistd.h>
88

9+
#include <bit>
910
#include <string>
1011
#include <vector>
1112

@@ -56,8 +57,8 @@ bool NetmaskToCidr(std::string_view netmask, unsigned int* cidr) {
5657
in_addr addr;
5758
if (wpi::uv::NameToAddr(netmask, &addr) != 0) return false;
5859
uint32_t hostAddr = ntohl(addr.s_addr);
59-
auto leadingOnes = wpi::countLeadingOnes(hostAddr);
60-
auto trailingZeros = wpi::countTrailingZeros(hostAddr);
60+
auto leadingOnes = std::countl_one(hostAddr);
61+
auto trailingZeros = std::countr_zero(hostAddr);
6162
if (leadingOnes + trailingZeros != 32) return false;
6263
*cidr = leadingOnes;
6364
return true;
@@ -123,19 +124,19 @@ static std::string BuildDhcpcdSetting(
123124
break;
124125
case NetworkSettings::kStatic:
125126
fmt::print(os, "interface {}\n", iface);
126-
fmt::print(os, "static ip_address={}/{}\n", addressOut, cidr);
127+
fmt::print(os, "static ip_address={}/{}\n", addressOut.str(), cidr);
127128
if (!gatewayOut.empty())
128-
fmt::print(os, "static routers={}\n", gatewayOut);
129+
fmt::print(os, "static routers={}\n", gatewayOut.str());
129130
if (!dnsOut.empty())
130-
fmt::print(os, "static domain_name_servers={}\n", dnsOut);
131+
fmt::print(os, "static domain_name_servers={}\n", dnsOut.str());
131132
break;
132133
case NetworkSettings::kDhcpStatic:
133134
fmt::print(os, "profile static_{}\n", iface);
134-
fmt::print(os, "static ip_address={}/{}\n", addressOut, cidr);
135+
fmt::print(os, "static ip_address={}/{}\n", addressOut.str(), cidr);
135136
if (!gatewayOut.empty())
136-
fmt::print(os, "static routers={}\n", gatewayOut);
137+
fmt::print(os, "static routers={}\n", gatewayOut.str());
137138
if (!dnsOut.empty())
138-
fmt::print(os, "static domain_name_servers={}\n", dnsOut);
139+
fmt::print(os, "static domain_name_servers={}\n", dnsOut.str());
139140
fmt::print(os, "interface {}\n", iface);
140141
fmt::print(os, "fallback static_{}\n", iface);
141142
break;

deps/tools/configServer/src/NetworkSettings.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@
1010
#include <string_view>
1111

1212
#include <wpi/Signal.h>
13+
#include <wpi/json_fwd.h>
1314
#include <wpinet/uv/Loop.h>
1415

15-
namespace wpi {
16-
class json;
17-
} // namespace wpi
18-
1916
class NetworkSettings {
2017
struct private_init {};
2118

deps/tools/configServer/src/RomiStatus.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <string_view>
1515

1616
#include <fmt/format.h>
17+
#include <wpi/MemoryBuffer.h>
1718
#include <wpi/SmallString.h>
1819
#include <wpi/fmt/raw_ostream.h>
1920
#include <wpi/fs.h>
@@ -237,17 +238,18 @@ wpi::json RomiStatus::ReadRomiConfigFile(
237238
std::function<void(std::string_view)> onFail) {
238239
// Read config file
239240
std::error_code ec;
240-
wpi::raw_fd_istream is(ROMI_JSON, ec);
241+
std::unique_ptr<wpi::MemoryBuffer> fileBuffer =
242+
wpi::MemoryBuffer::GetFile(ROMI_JSON, ec);
241243

242-
if (ec) {
244+
if (fileBuffer == nullptr || ec) {
243245
onFail("Could not read romi config file");
244246
fmt::print(stderr, "could not read {}\n", ROMI_JSON);
245247
return wpi::json();
246248
}
247249

248250
wpi::json j;
249251
try {
250-
j = wpi::json::parse(is);
252+
j = wpi::json::parse(fileBuffer->GetCharBuffer());
251253
} catch(const wpi::json::parse_error& e) {
252254
onFail("Parse error in config file");
253255
fmt::print(stderr, "Parse error in {}: byte {}: {}\n", ROMI_JSON, e.byte,

deps/tools/configServer/src/RomiStatus.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@
1212

1313
#include <cscore.h>
1414
#include <wpi/Signal.h>
15+
#include <wpi/json_fwd.h>
1516
#include <wpinet/uv/Loop.h>
1617

17-
namespace wpi {
18-
class json;
19-
20-
namespace uv {
18+
namespace wpi::uv {
2119
class Buffer;
22-
} // namespace uv
23-
} // namespace wpi
20+
} // namespace wpi::uv
2421

2522
class RomiStatus {
2623
struct private_init {};

deps/tools/configServer/src/SystemStatus.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@
88
#include <memory>
99

1010
#include <wpi/Signal.h>
11+
#include <wpi/json_fwd.h>
1112

1213
#include "DataHistory.h"
1314

14-
namespace wpi {
15-
class json;
16-
} // namespace wpi
17-
1815
class SystemStatus {
1916
struct private_init {};
2017

deps/tools/configServer/src/VisionSettings.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "VisionSettings.h"
66

77
#include <fmt/format.h>
8+
#include <wpi/MemoryBuffer.h>
89
#include <wpi/fs.h>
910
#include <wpi/json.h>
1011
#include <wpi/raw_istream.h>
@@ -41,15 +42,17 @@ void VisionSettings::UpdateStatus() { status(GetStatusJson()); }
4142

4243
wpi::json VisionSettings::GetStatusJson() {
4344
std::error_code ec;
44-
wpi::raw_fd_istream is(FRC_JSON, ec);
45-
if (ec) {
45+
std::unique_ptr<wpi::MemoryBuffer> fileBuffer =
46+
wpi::MemoryBuffer::GetFile(FRC_JSON, ec);
47+
48+
if (fileBuffer == nullptr || ec) {
4649
fmt::print(stderr, "could not read {}\n", FRC_JSON);
4750
return wpi::json();
4851
}
4952

5053
try {
5154
wpi::json j = {{"type", "visionSettings"},
52-
{"settings", wpi::json::parse(is)}};
55+
{"settings", wpi::json::parse(fileBuffer->GetCharBuffer())}};
5356
return j;
5457
} catch (wpi::json::exception& e) {
5558
fmt::print(stderr, "could not parse {}\n", FRC_JSON);

deps/tools/configServer/src/VisionSettings.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
#include <string_view>
1111

1212
#include <wpi/Signal.h>
13-
14-
namespace wpi {
15-
class json;
16-
} // namespace wpi
13+
#include <wpi/json_fwd.h>
1714

1815
class VisionSettings {
1916
struct private_init {};

0 commit comments

Comments
 (0)