From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1n9sj6-000855-2i for mharc-grub-devel@gnu.org; Tue, 18 Jan 2022 12:57:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9siy-000834-2y for grub-devel@gnu.org; Tue, 18 Jan 2022 12:56:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29547) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9siv-0003NM-A0 for grub-devel@gnu.org; Tue, 18 Jan 2022 12:56:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642528606; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HW3NcwXTBsBlqgsX/Ha56wjAmAyCn7pdLjhjx+PAm+0=; b=VYA/2EgkxhoziTve0Resl7bBOhlK70JubcrXiwjyoWHZcQfChH4crXmpOFtQp2Cwh+2x4k 75TYVXo66OAnhD/IO3ePELuJUVoIZJkud58LeVrWowxA9gx9qp7USYi/8pzxkWM7ohLsjA fhaIaf4piiF+ADZHZRMSB5cy6OxB5z8= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-275-pUynEZc-MnOjE707Okd02w-1; Tue, 18 Jan 2022 12:56:43 -0500 X-MC-Unique: pUynEZc-MnOjE707Okd02w-1 Received: by mail-qt1-f198.google.com with SMTP id f21-20020ac840d5000000b002c93f29abbcso9857341qtm.14 for ; Tue, 18 Jan 2022 09:56:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version; bh=z1ZPr7OWIwk7PBOTDanRx/ulZs3R8ggpaEpwzNEMFDo=; b=TCEvA4j3scCgwp7ZMNFCpjjtigv6rxzSULhF2LrgbXR6pcQGmMgfF2QMqiOypA0xXQ xGvthADc0m4tkdwAyPtUHtbgy6dqXZA+ZAN11RqWpVUxFtgtbB+HcUXYOJWSxf/e62EZ LFH35XFbtXKZ29B0SsZUeDrFpKdHvOHLJW//TliwR3NiRsOUPFjK3YZ/wuXC08o0tU/n U9aBuRJEoAdq59zmgK/am0pSHXYTRh8b3Jrjyew8mWVBn6Fdgt/vtX1hR/8G3No2YglK rCHkDJxGCVIBSy+8BHDMaWpbj3pbCByrzXE5M270cMP9EtisY89MtDIDI7I4Q7XiCups Pxmg== X-Gm-Message-State: AOAM533LxrkxaXiJXRM+osKC4E8mxJ+AtI5QPFRymA7MkZshIGdkBJcY GSqkuD43G7JGsq6Dveowz8+xp6HcjAc9ISmwJqNX4n7fkXGd48HqaX8I6WVq2yDDPGE0GV/pZMK jsffXtvnXZqjLvILkIbpEDZkWEcIATRkKWQdrzI5XApAbCReCrVQ4nbGLDBeWIps= X-Received: by 2002:a37:bd4:: with SMTP id 203mr19153645qkl.701.1642528600072; Tue, 18 Jan 2022 09:56:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyLpNI6KXKr292kNowOXwWspJvpbyXGOvuSlfKbcl0+qtxo0KqS4h8E9YIILgjeNerRo6REjA== X-Received: by 2002:a37:bd4:: with SMTP id 203mr19153597qkl.701.1642528599105; Tue, 18 Jan 2022 09:56:39 -0800 (PST) Received: from localhost ([2601:184:4181:74c0:862e:5809:ed9e:e10e]) by smtp.gmail.com with ESMTPSA id x16sm10960738qko.15.2022.01.18.09.56.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 09:56:38 -0800 (PST) From: Robbie Harwood To: grub-devel@gnu.org Subject: Re: [PATCH] Correct sorting of kernel names containing '_' In-Reply-To: <20220118172943.9903-1-rharwood@redhat.com> References: <20220118172943.9903-1-rharwood@redhat.com> Date: Tue, 18 Jan 2022 12:56:34 -0500 Message-ID: MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=rharwood@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Received-SPF: pass client-ip=170.10.129.124; envelope-from=rharwood@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Jan 2022 17:56:56 -0000 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Robbie Harwood writes: > sort(1) from GNU coreutils does not treat underscore as part of a > version number for `sort -V. This causes misorderings on x86_64, where > e.g. kernel-core-3.17.6-300.11.fc21.x86_64 will incorrectly sort > *before* kernel-core-3.17.6-300.fc21.x86_64. > > To cope with this behavior, replace underscores with dashes in order to > approximate their intended meaning as version component separators. > > Fixes: https://savannah.gnu.org/bugs/?42844 > Signed-off-by: Robbie Harwood > --- > util/grub-mkconfig_lib.in | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in > index 301d1ac22..23d41475f 100644 > --- a/util/grub-mkconfig_lib.in > +++ b/util/grub-mkconfig_lib.in > @@ -243,8 +243,8 @@ version_test_numeric () > =20 > version_test_gt () > { > - version_test_gt_a=3D"`echo "$1" | sed -e "s/[^-]*-//"`" > - version_test_gt_b=3D"`echo "$2" | sed -e "s/[^-]*-//"`" > + version_test_gt_a=3D"`echo "$1" | sed -e "s/[^-]*-//" -e "s/_/-/g"`" > + version_test_gt_b=3D"`echo "$2" | sed -e "s/[^-]*-//" -e "s/_/-/g"`" > version_test_gt_cmp=3Dgt > if [ "x$version_test_gt_b" =3D "x" ] ; then > return 0 > --=20 > 2.34.1 Before yinz bikeshed this into the ground, here are some other approaches I considered: - Use a C program to invoke librpm. This has the advantage of being already written - it's what we currently do downstream: https://github.com/rhboot/grub2/commit/81e155df39c9fbc97803cf9032f4138f5d= 9a0310 I dislike the approach regardless because it's heavyweight and doesn't generalize to non-RPM distros (especially since e.g. Debian can install a /usr/bin/rpm & co.). But it is "more correct", so if you want to merge that instead, there's the patch :) - Invoke rpmdev-vercmp if available. Problem here is that it may not be (it's not part of the rpm package itself on Fedora, but rather rpmdev-tools), and again, won't generalize to non-RPM distros. - Strip out any dot-delimited section that contains non-numerics. This has also been written and is the attached solution to https://savannah.gnu.org/bugs/?42844 - but since it hasn't been merged in the six years since posting, I have to assume it's been rejected. It also would not correctly handle the case of e.g. kernel-core-2.6.32-1_test2.x86_64 vs kernel-core-2.6.32-1.x86_64 - Strip underscore entirely, either with sed or tr. This has the same problem as the previous one in my mind - underscore is intended as a separator, and this causes it to not be treated as one. - Ignore the sorting problem and keep the status quo as it is in upstream. Attractive, but my bugzilla mailbox has plenty of angry people in it already :) Be well, --Robbie --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJIBAEBCgAyFiEEA5qc6hnelQjDaHWqJTL5F2qVpEIFAmHm/1IUHHJoYXJ3b29k QHJlZGhhdC5jb20ACgkQJTL5F2qVpELo0hAAhXK2ymrOhxmv36itaoZXbyBkixDI MAcixap3B4EQU5q1XxlE9M2HwirqOTegjxwzOxHY4U+aJPVpzITuqbhXrfovMBdk Q970vDkKK3aRNWQ1mPIujleRMs3znRtssb0d317MrTC2CPFwNlZE0aMB4nqN028B 5NT3bX3PkFeV2u0wxfy/hhK86NpWl4gduvpbqD74/BFMIDw/GxEbG9+hgQ7f9zDX 9KgjmGHsdL9o63FCo3HRe1JVPVU9o2CHUSiCTJ6vBzfwZvL1is4FHcALw5vXdufI CCPRoZdR6BiThSol+UWQc9w+g9uLSxrcLAOwf0/QO7nWSgYaWjokqB/O96S2kcS7 KyiX2Rc755TIFnhr+q+Cl+/0IxYBxOSq3CPY27ZDWcKs06SyTpHX+U1Ws0IUE+Je NIMipKi/9cva2d250r8giLXSYu3BmJaWopqGHyNd5vY9w8rzzBIg+82r4mbH0p8m C/msRjoPVvae1cS8nITsla489RazN9IadvXoB8wI9muHC6w4Rkm3Qn49svyzRegd oCZXpB1dFmq2jIRMp/KRNXkcMp6weBJ8OLro6vUi/B3NC99li1hEXnJZ/a9+4nsa 4kYGaaXbyHRYieUw9mWi0II1zKcpxTue+dYmpqPbV0/AwIcfCsqEQH/bZMYH5w5d gTD/Ruy4ilIYn2o= =vnnC -----END PGP SIGNATURE----- --=-=-=--