diff --git a/LICENSES/Unlicense.txt b/LICENSES/Unlicense.txt new file mode 100644 index 0000000..5227a51 --- /dev/null +++ b/LICENSES/Unlicense.txt @@ -0,0 +1,22 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or distribute +this software, either in source code form or as a compiled binary, for any +purpose, commercial or non-commercial, and by any means. + +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and +to the detriment of our heirs and +successors. We intend this dedication to be an overt act of relinquishment +in perpetuity of all present and future rights to this software under copyright +law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/SHA256SUMS.sources b/SHA256SUMS.sources index 3608aee..7d709c0 100644 --- a/SHA256SUMS.sources +++ b/SHA256SUMS.sources @@ -17,3 +17,4 @@ ecb5c6469d732bcf01d6ec1afe9e64f1668caba5bfdb103c28d7f537ba3cdb8a patch-2.5.9.ta 9fa29beb2fc4a3c373829fc051830796de301f32a719d0b52a400d1719bbd7b1 perl-5.003.tar.gz 1184478b298978b164a383ed5661e3a117c48ab97d6d0ab7ef614cdbe918b9eb perl5.004_05.tar.gz c6c37e888b136ccefab903c51149f4b7bd659d69d4aea21245f61053a57aa60a tar-1.12.tar.gz +404a8d72427a559c074e581bf8f7d5a73283faf249cd3faf6dc1c6faf97d07c7 sha-2-61555d.tar.gz diff --git a/rootfs.sh b/rootfs.sh index 3454705..4667e35 100755 --- a/rootfs.sh +++ b/rootfs.sh @@ -148,6 +148,9 @@ get_file https://ftp.gnu.org/gnu/gzip/gzip-1.2.4.tar 1 # patch 2.5.9 get_file https://ftp.gnu.org/pub/gnu/patch/patch-2.5.9.tar.gz 1 +# sha-2 61555d +get_file https://github.com/amosnier/sha-2/archive/61555d.tar.gz 1 sha-2-61555d.tar.gz + # make 3.80 get_file https://ftp.gnu.org/gnu/make/make-3.80.tar.gz 1 diff --git a/sysa/after.kaem.run b/sysa/after.kaem.run index b8b568f..fb136ae 100755 --- a/sysa/after.kaem.run +++ b/sysa/after.kaem.run @@ -86,41 +86,47 @@ cd ${pkg} kaem --file ${pkg}.kaem cd .. -# Part 12: mes-libc-patched +# Part 12: sha-2 +pkg="sha-2-61555d" +cd ${pkg} +kaem --file ${pkg}.kaem +cd .. + +# Part 13: mes-libc-patched cd tcc-0.9.27 kaem --file mes-libc-patched.kaem cd .. -# Part 13: tcc-patched +# Part 14: tcc-patched cd tcc-0.9.27 kaem --file tcc-patched.kaem cd .. -# Part 14: make +# Part 15: make pkg="make-3.80" cd ${pkg} kaem --file ${pkg}.kaem cd .. -# Part 15: bzip2 +# Part 16: bzip2 pkg="bzip2-1.0.8" cd ${pkg} kaem --file ${pkg}.kaem cd .. -# Part 16: coreutils +# Part 17: coreutils pkg="coreutils-5.0" cd ${pkg} kaem --file ${pkg}.kaem cd .. -# Part 17: heirloom-devtools +# Part 18: heirloom-devtools pkg="heirloom-devtools-070527" cd ${pkg} kaem --file ${pkg}.kaem cd .. -# Part 18: bash +# Part 19: bash pkg="bash-2.05b" cd ${pkg} kaem --file ${pkg}.kaem diff --git a/sysa/run.sh b/sysa/run.sh index c545ed1..4c58023 100755 --- a/sysa/run.sh +++ b/sysa/run.sh @@ -9,36 +9,36 @@ set -e export PREFIX=/after -# Part 19 +# Part 20 build flex-2.5.11 -# Part 20 +# Part 21 build musl-1.1.24 -# Part 21 -build tcc-0.9.27 tcc-musl.sh - # Part 22 -build m4-1.4.7 +build tcc-0.9.27 tcc-musl.sh checksums/tcc-musl # Part 23 -build flex-2.6.4 +build m4-1.4.7 # Part 24 +build flex-2.6.4 + +# Part 25 build bison-3.4.1 stage1.sh build bison-3.4.1 stage2.sh build bison-3.4.1 stage3.sh -# Part 25 +# Part 26 build grep-2.4 -# Part 26 +# Part 27 build diffutils-2.7 -# Part 27 +# Part 28 build coreutils-5.0 -# Part 28 +# Part 29 build gawk-3.0.4 # Part 29 diff --git a/sysa/sha-2-61555d/checksums b/sysa/sha-2-61555d/checksums new file mode 100644 index 0000000..4c9c42d --- /dev/null +++ b/sysa/sha-2-61555d/checksums @@ -0,0 +1 @@ +53384 /after/bin/sha256sum diff --git a/sysa/sha-2-61555d/patches/frontend.patch b/sysa/sha-2-61555d/patches/frontend.patch new file mode 100644 index 0000000..706e531 --- /dev/null +++ b/sysa/sha-2-61555d/patches/frontend.patch @@ -0,0 +1,151 @@ +SPDX-FileCopyrightText: 2021 Bastian Bittorf +SPDX-FileCopyrightText: 2021 fosslinux + +SPDX-License-Identifier: Unlicense + +This adds a main() function to this tool, giving a frontend so we can call +it from the command line. + +--- sha-256.c 2019-08-04 22:20:53.000000000 +1000 ++++ sha-256.c 2021-02-15 17:21:27.478945543 +1100 +@@ -1,10 +1,16 @@ + #include + #include +- +-#include "sha-256.h" ++#include + + #define CHUNK_SIZE 64 + #define TOTAL_LEN_LEN 8 ++#define MAX_FILE_SIZE 2*1024*1024 ++ ++void show_usage(void) ++{ ++ printf("Usage: sha256sum \n"); ++ printf(" sha256sum -c \n"); ++} + + /* + * ABOUT bool: this file does not use bool in order to be as pre-C99 compatible as possible. +@@ -217,3 +223,121 @@ + hash[j++] = (uint8_t) h[i]; + } + } ++ ++static void hash_to_string(char hash_string[66], uint8_t hash[32]) ++{ ++ for (size_t i = 0; i < 32; i++) { ++ hash_string += sprintf(hash_string, "%02x", hash[i]); ++ } ++ hash_string[65] = '\0'; ++} ++ ++static void hash_as_string(char filename[128], char hash_string[66]) ++{ ++ char buffer[MAX_FILE_SIZE]; ++ ++ FILE* fp = fopen(filename, "r"); ++ if (fp == NULL) ++ { ++ printf("Opening file %s failed!", filename); ++ hash_string = NULL; ++ return; ++ } ++ ++ size_t i; ++ for (i = 0; i < MAX_FILE_SIZE; i++) { ++ int c = fgetc(fp); ++ if (c == EOF) { ++ break; ++ } ++ buffer[i] = c; ++ } ++ ++ uint8_t hash[32]; ++ ++ calc_sha_256(hash, buffer, i); ++ hash_to_string(hash_string, hash); ++} ++ ++int main(int argc, char **argv) ++{ ++ char buffer[MAX_FILE_SIZE]; ++ size_t i; ++ FILE *fp; ++ FILE *csum_fp; ++ ++ if (argc == 1) { ++ show_usage(); ++ return 2; ++ } ++ ++ if ((strcmp(argv[1], "-c") == 0) || (strcmp(argv[1], "--check") == 0)) { ++ /* Operate in check mode */ ++ int failed = 0; ++ ++ /* Get and open checksum file */ ++ char *csum_filename = argv[2]; ++ csum_fp = fopen(csum_filename, "r"); ++ if (csum_fp == NULL) { ++ printf("Opening file %s failed!", csum_filename); ++ }; ++ ++ /* We break out of this loop at EOF */ ++ while (1) { ++ /* Get the hash we need to check against */ ++ char hash_true[256]; ++ char filename[512]; ++ int c = fgetc(csum_fp); ++ i = 0; ++ while (c != ' ' && c != EOF) { ++ hash_true[i] = c; ++ c = fgetc(csum_fp); ++ i++; ++ } ++ if(c == EOF) break; ++ /* Skip the next space(s) */ ++ while (c == ' ') { ++ c = fgetc(csum_fp); ++ } ++ if(c == EOF) break; ++ /* Get the filename */ ++ i = 0; ++ while (c != '\n' && c != EOF) { ++ filename[i] = c; ++ c = fgetc(csum_fp); ++ i++; ++ } ++ filename[i] = '\0'; ++ ++ /* Break out @ EOF */ ++ if (c == EOF) break; ++ ++ /* Get the hash */ ++ char hash_string[66]; ++ hash_as_string(filename, hash_string); ++ if (hash_string == NULL) return 127; ++ ++ /* Output results */ ++ printf("%s: ", filename); ++ if (strcmp(hash_true, hash_string)) { ++ printf("FAILED\n"); ++ failed = 1; ++ } else { ++ printf("OK\n"); ++ } ++ } ++ ++ if (failed) return 1; ++ } else { ++ /* All the arguments are files to generate checksums for */ ++ ++ for (i = 1; i < argc; i++) { ++ char hash[66]; ++ hash_as_string(argv[i], hash); ++ if (hash == NULL) return 127; ++ printf("%s %s\n", hash, argv[i]); ++ } ++ } ++ ++ return 0; ++} diff --git a/sysa/sha-2-61555d/sha-2-61555d.kaem b/sysa/sha-2-61555d/sha-2-61555d.kaem new file mode 100755 index 0000000..0a9a642 --- /dev/null +++ b/sysa/sha-2-61555d/sha-2-61555d.kaem @@ -0,0 +1,30 @@ +#!/bin/sh + +# SPDX-FileCopyrightText: 2021 fosslinux +# +# SPDX-License-Identifier: GPL-3.0-or-later + +set -ex + +cd build + +# Extract +gunzip ../src/${pkg}.tar.gz +tar xf ../src/${pkg}.tar +cd sha-2-61555d45676473e77c11f8da97301e2d2b865871 + +# Patch +patch -Np0 -i ../../patches/frontend.patch + +# Compile +tcc -c -o sha-256.o sha-256.c + +# Link +tcc -static -o ${bindir}/sha256sum sha-256.o + +# No test avaliable + +cd ../.. + +# Checksums +fletcher16 checksums