refactor: Package extension now depends on what compression method was detected.
ci/woodpecker/pr/lint Pipeline was successful Details
ci/woodpecker/pr/test Pipeline failed Details
ci/woodpecker/pr/test-mem unknown status Details

GreekStapler 2023-02-02 11:42:00 +00:00
parent c0925fec14
commit da7e41e8ca
2 changed files with 20 additions and 4 deletions

View File

@ -185,11 +185,25 @@ char *vieter_package_to_description(vieter_package *pkg) {
int i; int i;
// special case for FILENAME // special case for FILENAME
// assuming .pkg.tar.zst; other formats are valid, this should account for char *ext;
// that switch (pkg->compression) {
case 0:
ext = ".tar";
break;
case 1:
ext = ".tar.gz";
break;
case 6:
ext = ".tar.xz";
break;
case 14:
ext = ".tar.zst";
break;
}
size_to_be_written = size_to_be_written =
snprintf(aux, small_buff_size, "%%FILENAME%%\n%s-%s-%s.pkg.tar.zst", snprintf(aux, small_buff_size, "%%FILENAME%%\n%s-%s-%s.pkg%s",
pkg_info->name, pkg_info->version, pkg_info->arch); pkg_info->name, pkg_info->version, pkg_info->arch, ext);
// We neither want to let an arbritrarily long input to overflow the buffer // We neither want to let an arbritrarily long input to overflow the buffer
// nor to truncate perfectly valid inputs // nor to truncate perfectly valid inputs

View File

@ -78,6 +78,8 @@ void test_pkg_read_archive_desc() {
fclose(f); fclose(f);
TEST_CHECK(!strcmp(description, desc)); TEST_CHECK(!strcmp(description, desc));
vieter_package_free(&pkg);
} }
TEST_LIST = { TEST_LIST = {