Revamp image to build dependencies as part of stages (#83)

Fixes #17.

Stage 2 is fairly minimal, stage 3 builds/installs OpenCV and WPILib et al, and stage 4
builds/installs the FRCVision webdash and adds the vision examples.

Other changes:
- OpenCV compiled with ffmpeg, OpenBLAS, and libgtk (fixes #79, fixes #80)
- OpenBLAS added to image (fixes #65)
- C++ Makefile is more easily extensible (fixes #71)
- Sources for everything are bundled into image into /usr/src
- README updated (fixes #16)
- pkg-config files for wpilibc et al are now installed and C++ Makefile uses them (if compiled local to Pi)
- Both dynamic and static libs are included in image

The only downside of all these changes (particularly the ffmpeg, OpenBLAS, and libgtk inclusion)
is the image size is now over 3GB (800MB compressed). The previous image didn't quite fit on a
2GB card however.
This commit is contained in:
Peter Johnson
2019-02-02 23:37:18 -08:00
committed by GitHub
parent 02d5c468a2
commit c85fd9f33c
75 changed files with 775 additions and 721 deletions
+9
View File
@@ -0,0 +1,9 @@
.PHONY: all clean
all: setuidgids
clean:
rm -f setuidgids
setuidgids: src/setuidgids.c
${CC} -O -Wall -D_GNU_SOURCE -o $@ $^
+47
View File
@@ -0,0 +1,47 @@
#include <sys/types.h>
#include <pwd.h>
#include <unistd.h>
#include <grp.h>
#include <stdio.h>
#include <stdlib.h>
static int prot_gid(gid_t gid)
{
if (setgroups(1,&gid) == -1) return -1;
return setgid(gid); /* _should_ be redundant, but on some systems it isn't */
}
const char *account;
struct passwd *pw;
int main(int argc, char **argv, char **envp)
{
account = *++argv;
if (!account || !*++argv) {
fprintf(stderr, "setuidgids: usage: setuidgids account child");
exit(EXIT_FAILURE);
}
pw = getpwnam(account);
if (!pw) {
fprintf(stderr, "setuidgids: FATAL: unknown account %s", account);
return EXIT_FAILURE;
}
if (prot_gid(pw->pw_gid) == -1) {
fprintf(stderr, "setuidgids: FATAL: unable to setgid\n");
return EXIT_FAILURE;
}
if (initgroups(pw->pw_name, pw->pw_gid) == -1) {
fprintf(stderr, "setuidgids: FATAL: unable to initgroups\n");
return EXIT_FAILURE;
}
if (setuid(pw->pw_uid) == -1) {
fprintf(stderr, "setuidgids: FATAL: unable to setuid\n");
return EXIT_FAILURE;
}
execvpe(*argv,argv,envp);
fprintf(stderr, "setuidgids: FATAL: unable to run %s\n", *argv);
return EXIT_FAILURE;
}