Re: [GNC] Windows Installation Package - getting the version to register correctly
Ken Pyzik <[email protected]> Fri, 20 Dec 2024 03:58:44 +0000
| Newsgroups | gmane.comp.gnome.apps.gnucash.user,gmane.comp.gnome.apps.gnucash.devel |
|---|---|
| Message-ID | <BY5PR07MB6705F258B53E0DF3E38BD8C6AE072@BY5PR07MB6705.namprd07.prod.outlook.com> |
Actually, it is not really a bug. I started the thread based upon the new = installation of GnuCash on a Windows 11 Pro machine, mentioning that it was= registering incorrectly as 5.9 instead of 5.10. I do not consider this a= bug, perse. It is more of an administrative thing. Since I started it = =97 I have replied here with a new title. Ken ________________________________ From: gnucash-user <[email protected]> o= n behalf of Danny Siminiuk <[email protected]> Sent: Thursday, December 19, 2024 6:24 PM Cc: [email protected] <[email protected]>; gnucas= [email protected] <[email protected]> Subject: Re: [GNC] ANNOUNCE: GnuCash 5.10 Released It would be really polite if there were an issue or bug that required discu= ssion if that could be started on a new topic rather the "ANNOUNCE" topic. Asking for a friend. :) ----- Original Message ----- From: "Sherlock" <[email protected]> To: [email protected] Cc: [email protected] Sent: Thursday, December 19, 2024 4:12:26 PM Subject: Re: [GNC] ANNOUNCE: GnuCash 5.10 Released On 12/18/24 8:11 PM, John Ralls wrote: > > >> On Dec 18, 2024, at 15:56, AP <[email protected]> wrote: >> >> On Tue, Dec 17, 2024 at 08:01:01PM -0800, John Ralls wrote: >>> I=92d made an error when I wrote bit in the bundler script that derives= the version to pass to the setup-generator: It gets the release instal dir= ectories, sorts them, and grabs the last one. The problem with that is that= it=92s a lexical sort so if say 5.8, 5.9. and 5.10 directories exist then = the sort order is >>> Gnucash-5.10 >>> Gnucash-5.8 >>> Gnucash-5.9 >>> And the last one is 5.9. https://github.com/Gnucash/gnucash-on-windows/= commit/317b10b7d99a4ae8281e866efc4403b9b7624320 changes it to sort them by = creation date. That=92s still not perfect, of course, because someone might= come along and builds an earlier version by hand it will have the last tim= e stamp. >> >> I asked the Lord God AI (as I'm not a powershell user) and it came up wi= th this: >> >> --- 8<--- >> # Define an array of strings with non-version related text before the ve= rsion numbers >> $versionStrings =3D @( >> 'ProductA v1.2.3', >> 'ProductB v1.10.0', >> 'ProductC v1.3.5', >> 'ProductD v2.0.0' >> ) >> >> # Extract the version part using a regular expression and sort by the ex= tracted version >> $sortedVersions =3D $versionStrings | Sort-Object { >> if ($_ -match 'v([\d\.]+)$') { >> [version]$matches[1] >> } >> } >> >> # Display the sorted versions >> $sortedVersions >> --- 8<--- >> >> Don't know how right it is but if it's not right in and of itself then, = maybe, it's right enough to get you most of the way there. :) >> > > You don=92t show the output, but the result of the regex match is still a= string so I think it will still sort lexically, i.e. 1.10.0, 1.2.3, 1.3.5,= 2.0.0. > > This S-O suggests using a function called System.Version: https://stackov= erflow.com/questions/711107/sorting-powershell-versions. Dunno if it works = on two-digit version numbers. My default approach in most languages would b= e to do two captures, =91(\d+).(\d+)$=92 and cast each to int and do a two-= level sort. https://stackoverflow.com/questions/71232189/how-to-sort-multi= level-list suggests how to do the multi-level sort part. > > Regards, > John Ralls > > _______________________________________________ > gnucash-user mailing list > [email protected] > To update your subscription preferences or to unsubscribe: > https://lists.gnucash.org/mailman/listinfo/gnucash-user > ----- > Please remember to CC this list on all your replies. > You can do this by using Reply-To-List or Reply-All. John, The PowerShell's System.Version object supports the form of: Major . Minor . Build . Revision The cast maps the missing elements to -1. | For example: PS C:\Users\sherlock> [version]"1.0" Major Minor Build Revision ----- ----- ----- -------- 1 0 -1 -1 The sort implemented is an appropriate multi-level numeric order: Major, then Minor, then Build, and finally Revision. If you really want to select the gnucash folder with the greatest version suffix in bundle-mingw64.ps1 (assuming there is such a folder), the following should suffice: $gnucash =3D get-childitem -path $target_dir\build | sort-object { [Version] $(if ($_.Name -match "^gnucash-([0-9\.]+)$") { $matches[1] } else { "0.0.0.0" }) } | select-object -last 1 You may want to add some logic in bundle-mingw64.ps1 to verify the package version subsequently derived from the config.h contained within the selected folder is a match. Regards, Sherlock _______________________________________________ gnucash-user mailing list [email protected] To update your subscription preferences or to unsubscribe: https://lists.gnucash.org/mailman/listinfo/gnucash-user ----- Please remember to CC this list on all your replies. You can do this by using Reply-To-List or Reply-All. _______________________________________________ gnucash-user mailing list [email protected] To update your subscription preferences or to unsubscribe: https://lists.gnucash.org/mailman/listinfo/gnucash-user ----- Please remember to CC this list on all your replies. You can do this by using Reply-To-List or Reply-All. _______________________________________________ gnucash-user mailing list [email protected] To update your subscription preferences or to unsubscribe: https://lists.gnucash.org/mailman/listinfo/gnucash-user ----- Please remember to CC this list on all your replies. You can do this by using Reply-To-List or Reply-All.