From 13e3c8ada17544e23446b9bd7f8a6a5f57619138 Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Thu, 31 Oct 2024 07:13:58 +0800 Subject: [PATCH] Fix `Debian` version detection [GitHub #110] --- src/recipe/os/APT/common.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/recipe/os/APT/common.h b/src/recipe/os/APT/common.h index a812113..448b21f 100644 --- a/src/recipe/os/APT/common.h +++ b/src/recipe/os/APT/common.h @@ -4,7 +4,7 @@ * File Authors : Aoran Zeng * Contributors : Nil Null * Created On : <2024-06-14> - * Last Modified : <2024-08-16> + * Last Modified : <2024-10-31> * ------------------------------------------------------------*/ #define OS_Apt_SourceList "/etc/apt/sources.list" @@ -63,6 +63,11 @@ ensure_apt_sourcelist (int debian_type) char *version_id = xy_run ("sed -nr 's/VERSION_ID=(.*)/\\1/p' " ETC_OS_RELEASE, 0, NULL); version_id = xy_str_delete_suffix (codename, "\n"); + + // 得到的结果是带双引号的,需要去掉,如 "12" + version_id = xy_str_delete_prefix (version_id, "\""); + version_id = xy_str_delete_suffix (version_id, "\""); + double version = atof (version_id); char *makeup = NULL;