forked from vieter-v/libvieter
refactor: Added SHA256 to package description file.
parent
3d69c8edeb
commit
1da345f8b3
|
@ -120,6 +120,14 @@ Pkg *package_read_archive(const char *pkg_path) {
|
|||
return pkg;
|
||||
}
|
||||
|
||||
void sha256sum(Pkg *pkg, char *res) {
|
||||
char command[SMALL_BUFF_SIZE];
|
||||
snprintf(command, SMALL_BUFF_SIZE, "sha256sum %s", pkg->path);
|
||||
FILE *p = popen(command, "r");
|
||||
|
||||
fgets(res, 65, p);
|
||||
pclose(p);
|
||||
}
|
||||
|
||||
char *package_to_description(Pkg *pkg) {
|
||||
PkgInfo *pkg_info = pkg->info;
|
||||
|
@ -142,7 +150,16 @@ char *package_to_description(Pkg *pkg) {
|
|||
ADD_ARRAY("\n\n%%GROUPS%%\n%s", groups);
|
||||
ADD_STRING("\n\n%%CSIZE%%\n%ld", csize);
|
||||
ADD_STRING("\n\n%%ISIZE%%\n%ld", size);
|
||||
//SHA256SUM
|
||||
|
||||
char res[65];
|
||||
sha256sum(pkg, res);
|
||||
snprintf(aux, SMALL_BUFF_SIZE, "\n\n%%SHA256SUM%%\n%s", res);
|
||||
if (buff_size < strlen(description) + SMALL_BUFF_SIZE + 1) {
|
||||
description = realloc(description, buff_size * 2);
|
||||
buff_size *= 2;
|
||||
}
|
||||
strcat(description, aux);
|
||||
|
||||
ADD_STRING("\n\n%%URL%%\n%s", url);
|
||||
ADD_ARRAY("\n\n%%LICENSE%%\n%s", licenses);
|
||||
ADD_STRING("\n\n%%ARCH%%\n%s", arch);
|
||||
|
|
Loading…
Reference in New Issue