Bisa / factorio-init

Factorio init script
MIT License
426 stars 86 forks source link

Updates using factorio-updater do not work for 2.x #207

Open bioxz opened 1 month ago

bioxz commented 1 month ago

I guess due to a changed package name, using the update function does not work for 2.x

Due to a change of the --version output of the binary, updates are not working for the 2.x version.

$ /opt/factorio/factorio-init/factorio update -l

Running updater in --dry-run mode, no patches will be applied
Checking for updates...
Traceback (most recent call last):
  File "/opt/factorio/factorio-updater/update_factorio.py", line 295, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/factorio/factorio-updater/update_factorio.py", line 279, in main
    updates, latest = pick_updates(j, args.package, for_version, args.experimental)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/factorio/factorio-updater/update_factorio.py", line 85, in pick_updates
    for row in updater_json[factorio_package]:
               ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
KeyError: 'core-linux_headless'
Update check failed!

Factorio 1.x prints a Binary version, while 2.x prints just a Version:

Version: 1.1.108 (build 62305, linux64, headless)
Binary version: 64
Map input version: 0.18.0-0
Map output version: 1.1.108-0
Version: 2.0.8 (build 79416, linux64, headless)
Version: 64
Map input version: 1.0.0-0
Map output version: 2.0.8-1

This leads to the 64 missing in the package name.

Running the updater by hand did work (at least from 2.0.7 stable to 2.0.8 experimental). The server-init itself is also still running well.

Beanux commented 1 month ago

quick answer to patch it on the related issue of the related repos. https://github.com/narc0tiq/factorio-updater/issues/66#issuecomment-2439549425

narc0tiq commented 1 month ago

I will not accept a patch to mangle the provided input; please either make factorio-init supply the correct argument to --package or don't send one at all.

narc0tiq commented 1 month ago

Here is the relevant place to fix in factorio-init: https://github.com/Bisa/factorio-init/blob/94e949999b680946c0f7f6828bb98da607a4ca1a/factorio#L559-L561

You can't look only for Binary version because now it might be Version; honestly, given that 32-bit versions stopped existing many years ago, you can probably just keep it a static 64 and be fine for the next few decades (indeed, that's what #209 does).

Beanux commented 1 month ago

You were just too fast for me.

Here is what's returned by factorio --version and than can be helped to determine the version:

Version: 2.0.10 (build 79578, linux64, headless) Version: 64

Either Version: 64 or linux64 could be the one to determine arch. I'll make something work based on linux64 and provide it here, but i don't have the knowledge of previous versions and if it would work or if you want to keep support 32 bit version that's not existent anymore.

Edit: here is the patch proposed, it detect 64 bit version, and keep the same system (just returning the command rather than conditionnal test).

diff --git a/factorio b/factorio
index 3fb7ad3..b9389d1 100755
--- a/factorio
+++ b/factorio
@@ -557,7 +557,7 @@ function get_bin_version(){
 }

 function get_bin_arch(){
-  as_user "$BINARY --version |egrep '^Binary version: ' |egrep -o '[0-9]{2}'"
+  as_user "$BINARY --version |egrep '^Version: ' |egrep -o 'linux[0-9]{2}' |egrep -o '[0-9]{2}'"
 }
bioxz commented 4 weeks ago

Here is the relevant place to fix in factorio-init:

https://github.com/Bisa/factorio-init/blob/94e949999b680946c0f7f6828bb98da607a4ca1a/factorio#L559-L561

You can't look only for Binary version because now it might be Version; honestly, given that 32-bit versions stopped existing many years ago, you can probably just keep it a static 64 and be fine for the next few decades (indeed, that's what #209 does).

Right, I did not comment here again, but I don't think it's worth to fix the architecture detection (which is always dangerous, as it does not rely on a documented API, it could break at any time again) and instead just assume it's always the 64 bit build. I can't really image that there are any users who want to use the latest version of this repo to update a years old Factorio version. In the worst case one could always take an old version of this repo, which was fully working for the older versions of Factorio.