mirror of https://gitlab.com/nakst/essence
compare downloaded files against checksum
This commit is contained in:
parent
f3350f0604
commit
2ff51cd560
|
@ -49,6 +49,7 @@ The following commands are available in the interactive prompt:
|
|||
- `a2l <symbols file>` Run the a2l utility. See the "a2l" section.
|
||||
- `build-port` Build a single port. A list of availble ports are listed.
|
||||
- `get-source <folder name> <url>` The file at the URL is downloaded and cached in `bin/cache`. The download is skipped if the file was already cached. It is then extracted and untar'd. The folder of the given name is then moved to `bin/source`.
|
||||
- `get-source-checked <sha256> <folder name> <url>` Same as `get-source` except the downloaded file has its SHA-256 checksum compared against the given value.
|
||||
- `make-crash-report` Copies various system files and logs into a `.tar.gz` which can be used to report a crash.
|
||||
- `setup-pre-built-toolchain` Setup the pre-built toolchain for use by the build system. You can download and prepare it by running `./start.sh get-source prefix https://github.com/nakst/build-gcc/releases/download/gcc-11.1.0/gcc-x86_64-essence.tar.xz` followed by `./start.sh setup-pre-built-toolchain`.
|
||||
- `run-tests` Run the API tests. `desktop/api_tests.ini` must be added to `bin/extra_applications.ini`, and `Emulator.SerialToFile` must be enabled.
|
||||
|
|
|
@ -51,6 +51,7 @@ This file contains a list and description of the files and folders in the source
|
|||
- `crt1.c` Implementation of `_start` for executables running under the POSIX subsystem. Calls into the C standard library which will call `main`.
|
||||
- `crtglue.c` Redirection of POSIX system calls into `posix.cpp`.
|
||||
- `api.cpp` The main file of the desktop, including initialisation, work queues, user tasks, instances, undo stack management, command management, mount point management, and message processing.
|
||||
- `api_tests.cpp` Tests for the API. Called by the build system command `run-tests`.
|
||||
- `desktop.cpp` The desktop environment, including container windows, the task bar, the wallpaper, device management, and global initilisation.
|
||||
- `gui.cpp` The user interface. Contains core functionality and various elements. More complicated elements are split off into their own files.
|
||||
- `inspector.cpp` The debug inspector for the user interface.
|
||||
|
|
|
@ -3,7 +3,7 @@ set -e
|
|||
SYSROOT=`realpath root`
|
||||
VERSION=2.6.9
|
||||
|
||||
bin/build get-source bochs-$VERSION https://netix.dl.sourceforge.net/project/bochs/bochs/$VERSION/bochs-$VERSION.tar.gz
|
||||
bin/build get-source-checked ee5b677fd9b1b9f484b5aeb4614f43df21993088c0c0571187f93acb0866e98c bochs-$VERSION https://netix.dl.sourceforge.net/project/bochs/bochs/$VERSION/bochs-$VERSION.tar.gz
|
||||
cd bin/source
|
||||
|
||||
cp ../../ports/bochs/config.cc .
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
set -e
|
||||
SYSROOT=`realpath root`
|
||||
VERSION=1.33.1
|
||||
bin/build get-source busybox-$VERSION https://www.busybox.net/downloads/busybox-$VERSION.tar.bz2
|
||||
bin/build get-source-checked 12cec6bd2b16d8a9446dd16130f2b92982f1819f6e1c5f5887b6db03f5660d28 busybox-$VERSION https://www.busybox.net/downloads/busybox-$VERSION.tar.bz2
|
||||
cd bin/source
|
||||
cp ../../ports/busybox/config .config
|
||||
sed -i "51 i CONFIG_SYSROOT=\"$SYSROOT\"" .config
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
set -e
|
||||
SYSROOT=`realpath root`
|
||||
VERSION=4.3.1
|
||||
bin/build get-source ffmpeg-$VERSION https://ffmpeg.org/releases/ffmpeg-$VERSION.tar.xz
|
||||
bin/build get-source-checked ad009240d46e307b4e03a213a0f49c11b650e445b1f8be0dda2a9212b34d2ffb ffmpeg-$VERSION https://ffmpeg.org/releases/ffmpeg-$VERSION.tar.xz
|
||||
mkdir bin/build-ffmpeg
|
||||
cd bin/build-ffmpeg
|
||||
../source/configure --disable-all --cc=x86_64-essence-gcc --cxx=x86_64-essence-g++ --enable-cross-compile --enable-avcodec --enable-avformat --enable-swscale --enable-decoder=h264 --enable-parser=h264 --enable-decoder=aac --enable-parser=aac --enable-demuxer=mov --enable-protocol=file --disable-pthreads --prefix=/Applications/POSIX
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
if [ ! -d "bin/freetype" ]; then
|
||||
echo "Downloading FreeType..."
|
||||
|
||||
if [ ! -f "bin/cache/freetype-2.9.tar" ]; then
|
||||
curl https://mirrors.up.pt/pub/nongnu/freetype/freetype-2.9.tar.gz > bin/cache/freetype-2.9.tar.gz 2> bin/Logs/freetype_dl.txt
|
||||
gunzip bin/cache/freetype-2.9.tar.gz
|
||||
fi
|
||||
|
||||
tar -xf bin/cache/freetype-2.9.tar
|
||||
mv freetype-2.9 bin/freetype
|
||||
bin/build get-source-checked bf380e4d7c4f3b5b1c1a7b2bf3abb967bda5e9ab480d0df656e0e08c5019c5e6 freetype-2.9 https://download.savannah.gnu.org/releases/freetype/freetype-2.9.tar.gz
|
||||
mv bin/source bin/freetype
|
||||
|
||||
cp ports/freetype/patch-ftoption.h bin/freetype/include/freetype/config/ftoption.h
|
||||
cp ports/freetype/patch-ftstdlib.h bin/freetype/include/freetype/config/ftstdlib.h
|
||||
|
|
|
@ -9,15 +9,15 @@ MPFR_VERSION=4.1.0
|
|||
MPC_VERSION=1.2.1
|
||||
|
||||
rm -rf bin/gcc-src bin/binutils-src bin/mpc-src bin/gmp-src bin/mpfr-src
|
||||
bin/build get-source binutils-$BINUTILS_VERSION ftp://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS_VERSION.tar.xz
|
||||
bin/build get-source-checked e81d9edf373f193af428a0f256674aea62a9d74dfe93f65192d4eae030b0f3b0 binutils-$BINUTILS_VERSION ftp://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS_VERSION.tar.xz
|
||||
mv bin/source bin/binutils-src
|
||||
bin/build get-source gcc-$GCC_VERSION ftp://ftp.gnu.org/gnu/gcc/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.xz
|
||||
bin/build get-source-checked 4c4a6fb8a8396059241c2e674b85b351c26a5d678274007f076957afa1cc9ddf gcc-$GCC_VERSION ftp://ftp.gnu.org/gnu/gcc/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.xz
|
||||
mv bin/source bin/gcc-src
|
||||
bin/build get-source gmp-$GMP_VERSION ftp://ftp.gnu.org/gnu/gmp/gmp-$GMP_VERSION.tar.xz
|
||||
bin/build get-source-checked fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2 gmp-$GMP_VERSION ftp://ftp.gnu.org/gnu/gmp/gmp-$GMP_VERSION.tar.xz
|
||||
mv bin/source bin/gmp-src
|
||||
bin/build get-source mpfr-$MPFR_VERSION ftp://ftp.gnu.org/gnu/mpfr/mpfr-$MPFR_VERSION.tar.xz
|
||||
bin/build get-source-checked 0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f mpfr-$MPFR_VERSION ftp://ftp.gnu.org/gnu/mpfr/mpfr-$MPFR_VERSION.tar.xz
|
||||
mv bin/source bin/mpfr-src
|
||||
bin/build get-source mpc-$MPC_VERSION ftp://ftp.gnu.org/gnu/mpc/mpc-$MPC_VERSION.tar.gz
|
||||
bin/build get-source-checked 17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459 mpc-$MPC_VERSION ftp://ftp.gnu.org/gnu/mpc/mpc-$MPC_VERSION.tar.gz
|
||||
mv bin/source bin/mpc-src
|
||||
|
||||
cp ports/gcc/changes/binutils_bfd_config.bfd bin/binutils-src/bfd/config.bfd
|
||||
|
|
|
@ -56,13 +56,8 @@ CFLAGS="-DHAVE_CONFIG_H -I. -I.. -ffreestanding -fno-rtti -g -O3 -DHB_TINY -fno-
|
|||
if [ ! -d "bin/harfbuzz" ]; then
|
||||
echo "Downloading Harfbuzz..."
|
||||
|
||||
if [ ! -f "bin/cache/harfbuzz-2.6.4.tar" ]; then
|
||||
curl https://www.freedesktop.org/software/harfbuzz/release/harfbuzz-2.6.4.tar.xz > bin/cache/harfbuzz-2.6.4.tar.xz 2> bin/Logs/harfbuzz_dl.txt
|
||||
xz -d bin/cache/harfbuzz-2.6.4.tar.xz
|
||||
fi
|
||||
|
||||
tar -xf bin/cache/harfbuzz-2.6.4.tar
|
||||
mv harfbuzz-2.6.4 bin/harfbuzz
|
||||
bin/build get-source-checked 9413b8d96132d699687ef914ebb8c50440efc87b3f775d25856d7ec347c03c12 harfbuzz-2.6.4 https://www.freedesktop.org/software/harfbuzz/release/harfbuzz-2.6.4.tar.xz
|
||||
mv bin/source bin/harfbuzz
|
||||
|
||||
cd bin/harfbuzz
|
||||
./configure --with-glib=no --with-icu=no --with-freetype=no --with-cairo=no --with-fontconfig=no --enable-shared \
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
set -ex
|
||||
|
||||
rm -rf bin/mesa
|
||||
bin/build get-source mesa-20.1.8 https://archive.mesa3d.org//mesa-20.1.8.tar.xz
|
||||
bin/build get-source-checked df21351494f7caaec5a3ccc16f14f15512e98d2ecde178bba1d134edc899b961 mesa-20.1.8 https://archive.mesa3d.org//mesa-20.1.8.tar.xz
|
||||
mv bin/source bin/mesa
|
||||
|
||||
echo "" > bin/meson_cross.txt
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
if [ ! -d "bin/musl" ]; then
|
||||
echo "Downloading Musl..."
|
||||
|
||||
if [ ! -f "bin/cache/musl-1.2.1.tar" ]; then
|
||||
curl https://musl.libc.org/releases/musl-1.2.1.tar.gz > bin/cache/musl-1.2.1.tar.gz
|
||||
gunzip bin/cache/musl-1.2.1.tar.gz
|
||||
fi
|
||||
|
||||
tar -xf bin/cache/musl-1.2.1.tar
|
||||
mv musl-1.2.1 bin/musl
|
||||
bin/build get-source-checked 68af6e18539f646f9c41a3a2bb25be4a5cfa5a8f65f0bb647fd2bbfdf877e84b musl-1.2.1 https://musl.libc.org/releases/musl-1.2.1.tar.gz
|
||||
mv bin/source bin/musl
|
||||
|
||||
cp ports/musl/changes/config.mak bin/musl/config.mak
|
||||
cp ports/musl/changes/dist_config.mak bin/musl/dist/config.mak
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
set -e
|
||||
SYSROOT=`realpath root`
|
||||
VERSION=2.15.05
|
||||
bin/build get-source nasm-$VERSION https://www.nasm.us/pub/nasm/releasebuilds/$VERSION/nasm-$VERSION.tar.xz
|
||||
bin/build get-source-checked 3caf6729c1073bf96629b57cee31eeb54f4f8129b01902c73428836550b30a3f nasm-$VERSION https://www.nasm.us/pub/nasm/releasebuilds/$VERSION/nasm-$VERSION.tar.xz
|
||||
cd bin/source
|
||||
./configure --host=x86_64-essence CC=x86_64-essence-gcc CXX=x86_64-essence-g++ --prefix=/Applications/POSIX
|
||||
make -j 4
|
||||
|
|
129
util/build.c
129
util/build.c
|
@ -1152,6 +1152,82 @@ void BuildAndRun(int optimise, bool compile, int debug, int emulator, int log) {
|
|||
}
|
||||
}
|
||||
|
||||
void GetSource(const char *parameters, const char *checksum) {
|
||||
if (CallSystem("mkdir -p bin/cache && rm -rf bin/source")) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
const char *folder = parameters;
|
||||
const char *url = NULL;
|
||||
|
||||
for (int i = 0; folder[i]; i++) {
|
||||
if (folder[i] == ' ') {
|
||||
url = folder + i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assert(url);
|
||||
|
||||
char name[1024];
|
||||
strcpy(name, "bin/cache/");
|
||||
|
||||
const char *extension = url;
|
||||
|
||||
for (int i = 0; url[i]; i++) {
|
||||
name[i + 10] = isalnum(url[i]) ? url[i] : '_';
|
||||
name[i + 11] = 0;
|
||||
if (url[i] == '.') extension = url + i;
|
||||
}
|
||||
|
||||
char decompressFlag;
|
||||
|
||||
if (0 == strcmp(extension, ".bz2")) {
|
||||
decompressFlag = 'j';
|
||||
} else if (0 == strcmp(extension, ".xz")) {
|
||||
decompressFlag = 'J';
|
||||
} else if (0 == strcmp(extension, ".gz")) {
|
||||
decompressFlag = 'z';
|
||||
} else {
|
||||
fprintf(stderr, "Unknown archive format.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
FILE *f = fopen(name, "rb");
|
||||
|
||||
if (f) {
|
||||
fclose(f);
|
||||
} else if (CallSystemF("curl -L %s > %s", url, name)) {
|
||||
CallSystemF("rm %s", name); // Remove partially downloaded file.
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define SHA256SUM "sha256 -a 256"
|
||||
#else
|
||||
#define SHA256SUM "sha256sum"
|
||||
#endif
|
||||
|
||||
if (checksum) {
|
||||
int checksumLength = strlen(checksum);
|
||||
|
||||
for (int i = 0; checksum[i]; i++) {
|
||||
if (checksum[i] == ' ') {
|
||||
checksumLength = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (CallSystemF(SHA256SUM " %s | grep %.*s > /dev/null", name, checksumLength, checksum)) {
|
||||
fprintf(stderr, "Checksum mismatch for file '%s' downloaded from '%s'.\n", name, url);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (CallSystemF("tar -x%cf %s", decompressFlag, name)) exit(1);
|
||||
if (CallSystemF("mv %.*s bin/source", (int) (url - folder), folder)) exit(1);
|
||||
}
|
||||
|
||||
void DoCommand(const char *l) {
|
||||
while (l && (*l == ' ' || *l == '\t')) l++;
|
||||
|
||||
|
@ -1549,57 +1625,24 @@ void DoCommand(const char *l) {
|
|||
exit(status);
|
||||
}
|
||||
} else if (0 == memcmp(l, "get-source ", 11)) {
|
||||
if (CallSystem("mkdir -p bin/cache && rm -rf bin/source")) {
|
||||
exit(1);
|
||||
}
|
||||
GetSource(l + 11, NULL);
|
||||
} else if (0 == memcmp(l, "get-source-checked ", 19)) {
|
||||
const char *checksum = l + 19;
|
||||
const char *rest = NULL;
|
||||
|
||||
const char *folder = l + 11;
|
||||
const char *url = NULL;
|
||||
|
||||
for (int i = 0; folder[i]; i++) {
|
||||
if (folder[i] == ' ') {
|
||||
url = folder + i + 1;
|
||||
for (int i = 0; checksum[i]; i++) {
|
||||
if (checksum[i] == ' ') {
|
||||
rest = checksum + i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assert(url);
|
||||
|
||||
char name[1024];
|
||||
strcpy(name, "bin/cache/");
|
||||
|
||||
const char *extension = url;
|
||||
|
||||
for (int i = 0; url[i]; i++) {
|
||||
name[i + 10] = isalnum(url[i]) ? url[i] : '_';
|
||||
name[i + 11] = 0;
|
||||
if (url[i] == '.') extension = url + i;
|
||||
}
|
||||
|
||||
char decompressFlag;
|
||||
|
||||
if (0 == strcmp(extension, ".bz2")) {
|
||||
decompressFlag = 'j';
|
||||
} else if (0 == strcmp(extension, ".xz")) {
|
||||
decompressFlag = 'J';
|
||||
} else if (0 == strcmp(extension, ".gz")) {
|
||||
decompressFlag = 'z';
|
||||
} else {
|
||||
fprintf(stderr, "Unknown archive format.\n");
|
||||
if (!checksum) {
|
||||
fprintf(stderr, "Invalid usage; expected checksum before other arguments.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
FILE *f = fopen(name, "rb");
|
||||
|
||||
if (f) {
|
||||
fclose(f);
|
||||
} else if (CallSystemF("curl -L %s > %s", url, name)) {
|
||||
CallSystemF("rm %s", name); // Remove partially downloaded file.
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (CallSystemF("tar -x%cf %s", decompressFlag, name)) exit(1);
|
||||
if (CallSystemF("mv %.*s bin/source", (int) (url - folder), folder)) exit(1);
|
||||
GetSource(rest, checksum);
|
||||
} else if (0 == strcmp(l, "make-crash-report")) {
|
||||
system("rm crash-report.tar.gz");
|
||||
system("mkdir crash-report");
|
||||
|
|
Loading…
Reference in New Issue