refactor: Package extension now depends on what compression method was detected.

package
GreekStapler 2023-02-02 11:42:00 +00:00
parent df83bf9fb3
commit ea852f9102
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;
// special case for FILENAME
// assuming .pkg.tar.zst; other formats are valid, this should account for
// that
char *ext;
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 =
snprintf(aux, small_buff_size, "%%FILENAME%%\n%s-%s-%s.pkg.tar.zst",
pkg_info->name, pkg_info->version, pkg_info->arch);
snprintf(aux, small_buff_size, "%%FILENAME%%\n%s-%s-%s.pkg%s",
pkg_info->name, pkg_info->version, pkg_info->arch, ext);
// We neither want to let an arbritrarily long input to overflow the buffer
// nor to truncate perfectly valid inputs

View File

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