Add checksum-transcriber utility
To convert from sources format to sha256sum format.
This commit is contained in:
parent
0d4abd0223
commit
64ae760529
|
@ -9,6 +9,6 @@ Source: https://github.com/fosslinux/live-bootstrap
|
||||||
# Copyright: $YEAR $NAME <$CONTACT>
|
# Copyright: $YEAR $NAME <$CONTACT>
|
||||||
# License: ...
|
# License: ...
|
||||||
|
|
||||||
Files: sys*/SHA256SUMS.sources sysa/pre-sha.sha256sums sysa/*/*.checksums sysa/SHA256SUMS.pkgs sysc/musl-1.2.3/ld-musl-i386.path
|
Files: sys*/SHA256SUMS.sources sysa/checksum-transcriber.SHA256SUM sysa/pre-sha.sha256sums sysa/*/*.checksums sysa/SHA256SUMS.pkgs sysc/musl-1.2.3/ld-musl-i386.path
|
||||||
Copyright: none
|
Copyright: none
|
||||||
License: MIT
|
License: MIT
|
||||||
|
|
|
@ -32,6 +32,7 @@ cp /${ARCH_DIR}/bin/hex2 ${bindir}/hex2
|
||||||
cp /${ARCH_DIR}/bin/kaem ${bindir}/kaem
|
cp /${ARCH_DIR}/bin/kaem ${bindir}/kaem
|
||||||
cp /${ARCH_DIR}/bin/match ${bindir}/match
|
cp /${ARCH_DIR}/bin/match ${bindir}/match
|
||||||
cp /${ARCH_DIR}/bin/M1 ${bindir}/M1
|
cp /${ARCH_DIR}/bin/M1 ${bindir}/M1
|
||||||
|
cp /${ARCH_DIR}/bin/M2-Mesoplanet ${bindir}/M2-Mesoplanet
|
||||||
cp /${ARCH_DIR}/bin/M2-Planet ${bindir}/M2-Planet
|
cp /${ARCH_DIR}/bin/M2-Planet ${bindir}/M2-Planet
|
||||||
cp /${ARCH_DIR}/bin/mkdir ${bindir}/mkdir
|
cp /${ARCH_DIR}/bin/mkdir ${bindir}/mkdir
|
||||||
cp /${ARCH_DIR}/bin/sha256sum ${bindir}/sha256sum
|
cp /${ARCH_DIR}/bin/sha256sum ${bindir}/sha256sum
|
||||||
|
@ -50,6 +51,7 @@ chmod 755 ${bindir}/hex2
|
||||||
chmod 755 ${bindir}/kaem
|
chmod 755 ${bindir}/kaem
|
||||||
chmod 755 ${bindir}/match
|
chmod 755 ${bindir}/match
|
||||||
chmod 755 ${bindir}/M1
|
chmod 755 ${bindir}/M1
|
||||||
|
chmod 755 ${bindir}/M2-Mesoplanet
|
||||||
chmod 755 ${bindir}/M2-Planet
|
chmod 755 ${bindir}/M2-Planet
|
||||||
chmod 755 ${bindir}/mkdir
|
chmod 755 ${bindir}/mkdir
|
||||||
chmod 755 ${bindir}/sha256sum
|
chmod 755 ${bindir}/sha256sum
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
48831089e26bee3c6ab7f0db048ded98dfbd7d78a75fefb9e0918a346dff10c0 /usr/bin/checksum-transcriber
|
|
@ -0,0 +1,84 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <bootstrappable.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define MAX_STRING 4096
|
||||||
|
#define MAX_TOKENS 3
|
||||||
|
|
||||||
|
char *get_distfiles(char **envp) {
|
||||||
|
char *envvar = "distfiles=";
|
||||||
|
int i = 0;
|
||||||
|
while (envp[i] != NULL && strncmp(envp[i], envvar, strlen(envvar)) != 0) i += 1;
|
||||||
|
// Now we have distfiles= - get just the part we want.
|
||||||
|
require(envp[i] != NULL, "Unable to find distfiles environment variable");
|
||||||
|
return envp[i] + strlen(envvar);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv, char **envp) {
|
||||||
|
// Random file things
|
||||||
|
require(argc == 2, "Usage: checksum-transcriber FILENAME");
|
||||||
|
char *input = argv[1];
|
||||||
|
FILE *in = fopen(input, "r");
|
||||||
|
require(in != NULL, "File does not exist");
|
||||||
|
char *output = calloc(MAX_STRING, sizeof(char));
|
||||||
|
require(strcpy(output, input) != NULL, "Failed copying string");
|
||||||
|
require(strcat(output, ".SHA256SUM") != NULL, "Failed concating string");
|
||||||
|
FILE *out = fopen(output, "w+");
|
||||||
|
require(out != NULL, "Failed opening output file");
|
||||||
|
|
||||||
|
char *orig_line;
|
||||||
|
char *line = calloc(MAX_STRING, sizeof(char));
|
||||||
|
require(line != NULL, "Failed allocating string");
|
||||||
|
char **tokens;
|
||||||
|
char *new_line;
|
||||||
|
char *checksum;
|
||||||
|
char *filename;
|
||||||
|
int i;
|
||||||
|
fgets(line, MAX_STRING, in);
|
||||||
|
while (strlen(line) != 0) {
|
||||||
|
// Split each line into tokens
|
||||||
|
orig_line = line;
|
||||||
|
tokens = calloc(MAX_TOKENS, sizeof(char*));
|
||||||
|
i = 0;
|
||||||
|
while (i < MAX_TOKENS) {
|
||||||
|
tokens[i] = line;
|
||||||
|
new_line = strchr(line, ' ');
|
||||||
|
// Occurs when there are only two tokens
|
||||||
|
if (new_line == NULL) break;
|
||||||
|
line = new_line;
|
||||||
|
line[0] = '\0';
|
||||||
|
line += 1;
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
line = strchr(line, '\n');
|
||||||
|
line[0] = '\0';
|
||||||
|
// Get checksum and filename
|
||||||
|
checksum = tokens[1];
|
||||||
|
if (tokens[2] != NULL) {
|
||||||
|
filename = tokens[2];
|
||||||
|
} else {
|
||||||
|
filename = strrchr(tokens[0], '/');
|
||||||
|
filename += 1;
|
||||||
|
}
|
||||||
|
// Put it all together
|
||||||
|
fputs(checksum, out);
|
||||||
|
fputs(" ", out);
|
||||||
|
fputs(get_distfiles(envp), out);
|
||||||
|
fputc('/', out);
|
||||||
|
fputs(filename, out);
|
||||||
|
fputc('\n', out);
|
||||||
|
// Cleanup
|
||||||
|
i = 0;
|
||||||
|
free(orig_line);
|
||||||
|
free(tokens);
|
||||||
|
line = calloc(MAX_STRING, sizeof(char));
|
||||||
|
require(line != NULL, "Failed allocating string");
|
||||||
|
fgets(line, MAX_STRING, in);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clean up
|
||||||
|
fclose(in);
|
||||||
|
fclose(out);
|
||||||
|
}
|
|
@ -9,6 +9,11 @@
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
|
# checksum-transcriber utility
|
||||||
|
M2LIBC_PATH=/M2libc
|
||||||
|
M2-Mesoplanet --architecture ${ARCH} -f checksum-transcriber.c -o ${bindir}/checksum-transcriber
|
||||||
|
sha256sum -c checksum-transcriber.SHA256SUM
|
||||||
|
|
||||||
# Environmental variables needed for mes
|
# Environmental variables needed for mes
|
||||||
NYACC_PKG=nyacc-1.00.2
|
NYACC_PKG=nyacc-1.00.2
|
||||||
MES_VERSION=0.24
|
MES_VERSION=0.24
|
||||||
|
|
Loading…
Reference in New Issue