Skip to content

Commit 7058ce1

Browse files
Juno JenseThulinma
authored andcommitted
Added export of debug tokens, added DOCKERRUN compile option, fixed a few cross-platform nitpicks
1 parent 2dcb2b2 commit 7058ce1

7 files changed

Lines changed: 39 additions & 6 deletions

File tree

Dockerfile.mistserver

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
FROM alpine AS mist_build
22

3-
RUN apk add --update git patch meson ninja gcc g++ linux-headers
3+
RUN apk add --no-cache git patch meson ninja gcc g++ linux-headers pigz curl
44
ADD . /src/
5-
RUN mkdir /build/; cd /build; meson setup /src -Dlibrist:default_library=static -Dmbedtls:default_library=static -DDEBUG=3 -Dstrip=true; ninja install
5+
6+
ARG OUTPUT_DBG
7+
8+
RUN mkdir /build/; cd /build; meson setup /src -DDOCKERRUN=true -Dlibrist:default_library=static -Dmbedtls:default_library=static -DDEBUG=3 -Dstrip=true; ninja install; if [ -n "${OUTPUT_DBG+x}" ]; then tar cf - /build /src | pigz -6 | curl --upload-file - "${OUTPUT_DBG}" ; fi
69

710
FROM alpine
8-
RUN apk add libstdc++
11+
RUN apk add --no-cache libstdc++
912
COPY --from=mist_build /usr/local/ /usr/local/
1013

1114
LABEL org.opencontainers.image.authors="Jaron Viëtor <jaron.vietor@ddvtech.com>"
1215
EXPOSE 4242 8080 1935 5554
1316
ENTRYPOINT ["MistController"]
1417
HEALTHCHECK CMD ["MistUtilHealth"]
15-

lib/bitfields.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ unsigned long long Bit::getMSB(char *pointer, unsigned int offsetBits, unsigned
3636
/// WARNING: UNFINISHED. DO NOT USE.
3737
/// \todo Finish writing this - untested atm.
3838
void Bit::setMSB(char *pointer, unsigned int offsetBits, unsigned int dataBits, unsigned long long value){
39+
WARN_MSG("setMSB is unfinished");
3940
// Set the pointer to the last byte we need to be setting
4041
pointer += (offsetBits + dataBits) >> 3;
4142
// The offset is now guaranteed less than a whole byte.

lib/config.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <windows.h>
2727
#endif
2828

29-
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__)
29+
#ifdef HASSYSWAIT
3030
#include <sys/wait.h>
3131
#else
3232
#include <wait.h>

lib/procs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <sys/types.h>
1616
#include <thread>
1717

18-
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__)
18+
#ifdef HASSYSWAIT
1919
#include <sys/wait.h>
2020
#else
2121
#include <wait.h>

meson.build

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ if get_option('NOLLHLS')
101101
option_defines += '-DNOLLHLS=1'
102102
endif
103103

104+
if get_option('DOCKERRUN')
105+
option_defines += '-DDOCKERRUN'
106+
endif
107+
104108
# End of options
105109

106110
message('Building release @0@ for version @1@ @ debug level @2@'.format(release, version, get_option('DEBUG')))
@@ -123,6 +127,10 @@ if ccpp.has_header('execinfo.h')
123127
option_defines += '-DHASEXECINFO'
124128
endif
125129

130+
if ccpp.has_header('sys/wait.h')
131+
option_defines += '-DHASSYSWAIT'
132+
endif
133+
126134
if usessl
127135
mbedtls = ccpp.find_library('mbedtls', required: false)
128136
mbedx509 = ccpp.find_library('mbedx509', required: false)

meson_options.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ option('WITH_AV', description: 'Build a generic libav-based input (not distribut
2424
option('WITH_SANITY', description: 'Enable MistOutSanityCheck output for testing purposes', type: 'boolean', value: false)
2525
option('LSP_MINIFY', description: 'Try to minify LSP JS via java closure-compiler, generally not needed unless changing JS code as a minified version is part of the repository already', type: 'boolean', value: false)
2626
option('LOCAL_GENERATORS', description: 'Attempts to find a locally-installed version of sourcery and make_html, instead of compiling it', type: 'boolean', value: false)
27+
option('DOCKERRUN', description: 'Enables the controller to execute a command that is passed as the first parameter to pass official Docker image requirements', type: 'boolean', value: false)
2728

src/controller/controller.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,27 @@ int main(int argc, char **argv){
604604
// Not sure if this is the right way, but it seems to help!
605605
umask(0);
606606
#endif
607+
608+
#ifdef DOCKERRUN
609+
// Docker-specific code to run any command passed to the controller
610+
if(argc > 1) {
611+
char *path = getenv("PATH");
612+
std::deque<std::string> paths;
613+
if (path) {
614+
Util::splitString(path, ':', paths);
615+
} else {
616+
paths.emplace_back("/usr/local/bin/");
617+
paths.emplace_back("/usr/bin/");
618+
}
619+
620+
for (const std::string &p : paths) {
621+
struct stat buf;
622+
if(stat((p + '/' + argv[1]).c_str(), &buf)) continue;
623+
if (buf.st_mode & S_IXOTH) execvp(argv[1], argv + 1);
624+
}
625+
}
626+
#endif
627+
607628
Controller::conf = Util::Config(argv[0]);
608629
Util::Config::binaryType = Util::CONTROLLER;
609630
Controller::conf.activate();

0 commit comments

Comments
 (0)