News:

A forum for users of LackeyCCG

Main Menu

How can I do a plugin autoupdate?

Started by marcianoperdedor, March 24, 2020, 10:29:26 AM

Previous topic - Next topic

marcianoperdedor

I have created a Lackey plugin, but it has to be downloaded and stored on the computer.


It is easier to just paste the link and update the plugin. How can do this?


::) ::) ::)


CrazyChucky

The timing on this is a hell of a thing...

1) The LackeyCCG website went down yesterday.
2) It's sort of back up now, including this forum, but the part of the plugin creation tutorial that covers the autoupdate mechanism seems to be missing.
3) No problem, I thought, the Wayback Machine archives everything. Apparently the Wayback Machine is not working today, which I have literally never seen happen before.

As soon as I notice either of these is back online, I'll link to it.

CrazyChucky

Okay heck, I might as well just explain here, it's not like my schedule is packed, what with being laid off and self-isolated. XD
I'll try to be thorough, but feel free to ask questions, as I'm sure I'll forget something.

Two files make up this process:
  • updatelist.txt ? This allows a user to install the entire plugin from a single URL, as you described.
  • version.txt ? This allows a user's local installation of the plugin to keep itself updated as you, the maintainer, update the plugin.
The version file won't do anything by itself, so let's start with the update list.

Update List

A sample updatelist.txt looks like this:


example 03-21-20
plugins/example/plugininfo.txt http://example.yourserver.com/plugininfo.txt 1234
plugins/example/cardback.jpg http://example.yourserver.com/cardback.jpg 4321

CardGeneralURLs:
http://example.yourserver.com/plugininfo.txt/cardimages/


Each line is tab-separated; those aren't just spaces. The first line is the name of your plugin (which should be the same as the name of the folder you intend to install to, so avoiding spaces and special characters is a good idea) and the date of most recent update, in MM-DD-YY. (Note: as far as I can tell the date in this file isn't checked by Lackey, but it can't hurt to keep it accurate.)

Each subsequent line lists a file your plugin needs to install. First, specify the location Lackey should install the file on the user's local computer, then you tell it the URL Lackey can find that file. The file names and even directory structure don't have to match; you could even store different files on different servers / web sites, if for some reason that's helpful. All Lackey cares about is 1) where it should put the file and 2) where it can get the file. The third item is a checksum, which is for keeping the user's installation up-to-date as you update the plugin. Don't worry about having correct checksums yet, but you do need something here for the update list to function. Just type in random numbers for now.

At the end you can list the place(s) Lackey should look for image files as it needs them on-the-fly. If your plugin is small, you might simply include your card images as regular files to be downloaded; if it's larger, using this alternative mechanism decreases the size of the initial download. Note that card images using the separate CardGeneralURLs mechanism aren't checksummed and can't easily be updated with new ones if you decide later to change them at some point. When Lackey needs a card image and doesn't already have it, it will check [CardGeneralURL]/[card's imageFile field], adding '.jpg' by default if the field doesn't contain an extension. You can even list multiple CardGeneralURLs, and Lackey will check through all of them until it finds one with the file it needs.

If your updatelist.txt is correctly formatted, you should be able to enter it on the plugin tab, hit install, and get a functioning install of the plugin.

Checksums

Let's say that at this point, your updatelist.txt successfully downloads and installs the plugin. If you go back to the plugins tab and hit "Install or update from URL" again, Lackey will now compare your local copy of updatelist.txt against the remote copy located at the install URL. It will see that all the checksums match, and conclude that none of the files have been changed.

But now that you have a functioning updatelist.txt, you can use Lackey to calculate actual checksums. Open Lackey, go to the game tab, and enter "/mkupdate plugins/example/updatelist.txt" in the console. This will generate a new file, updatelistNEW.txt, with all the random numbers replaced by the correct checksums. Either rename this file or copy and paste the contents into the original updatelist.txt, and you're good to go. Now, if you make changes to the plugin, rerun that script, and put the new files and new updatelist on the server, hitting "Install or update from URL" should correctly notice the files that have changed, then download them to the locally installed copy.

Version

But suppose you don't want to have to tell your users every time you've made changes, and require them to go hit the button themselves. That's where version.txt comes in. The version file itself is pretty simple, and it looks like this:


<version>

<lastupdateYYMMDD>200321</lastupdateYYMMDD>
<versionurl>http://example.yourserver.com/version.txt</versionurl>
<updateurl>http://example.yourserver.com/updatelist.txt</updateurl>
<message>I changed some stuff.</message>

</version>


Note that the date is in a different format this time: YYMMDD; different order, with no dashes. This is checked by Lackey. Any time you launch Lackey or load a plugin, if Lackey hasn't already checked the plugin for updates today, it looks at this file, then uses the <versionurl> tag to check the remote file. If the remote file has a newer date, it pulls the remote updatelist and checks for new files using the checksums. (Not that you can't specify a time, only a date, so if you make more than one update in the same day, anyone who got the first update won't automatically get the second one.)

Note also that once you use a version.txt file, you must list it as one of the (checksummed) files in your update list, so that Lackey can keep the local version file up to date.

You can also optionally include a short message saying what you updated. This will be displayed when Lackey asks the user if they want to install the update.

Alastair

#3
I think what you were looking for Chucky was https://www.lackeyccg.com/plugintutorialnew.html

CrazyChucky

#4
In theory, yes, but more than half that page is currently missing.

EDIT: Aha, the Wayback Machine is back in service! The page in question is archived here.

EDIT AGAIN: https://lackeyccg.com/tutorialplugin.html#updatelist