AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   Updater (https://forums.alliedmods.net/showthread.php?t=169095)

GoD-Tony 10-08-2011 13:03

Updater
 
2 Attachment(s)
Updater

Allows developers to automatically update their plugins and files. Updates will be checked on server startup and then once every 24 hours. All updates will be logged to Updater.log in your SourceMod log directory.

Installation:
  1. Your server must be running at least one of the following extensions:
  2. Extract updater.zip to your SourceMod directory.
Cvars:
  • sm_updater <1|2|3> - Determines update functionality.
    • 1 = Only notify in the log file when an update is available.
    • 2 = Automatically download and install available updates. *Default
    • 3 = Include the source code with updates.
Commands:
  • sm_updater_check - Forces Updater to check all plugins for updates. Can only be run once per hour.
  • sm_updater_status - View the status of Updater.

GoD-Tony 10-08-2011 13:04

Re: Updater
 
Information for Developers
Code:
/**  * Adds your plugin to the updater. The URL will be updated if  * your plugin was previously added.  *  * @param url      URL to your plugin's update file.  * @noreturn  */ native Updater_AddPlugin(const String:url[]); /**  * Removes your plugin from the updater. This does not need to  * be called during OnPluginEnd.  *  * @noreturn  */ native Updater_RemovePlugin(); /**  * Forces your plugin to be checked for updates. The behaviour  * of the update is dependant on the server's configuration.  *  * @return    True if an update was triggered. False otherwise.  * @error      Plugin not found in updater.  */ native bool:Updater_ForceUpdate(); /**  * Called when your plugin is about to be checked for updates.  *  * @return    Plugin_Handled to prevent checking, Plugin_Continue to allow it.  */ forward Action:Updater_OnPluginChecking(); /**  * Called when your plugin is about to begin downloading an available update.  *  * @return    Plugin_Handled to prevent downloading, Plugin_Continue to allow it.  */ forward Action:Updater_OnPluginDownloading(); /**  * Called when your plugin's update files have been fully downloaded  * and are about to write to their proper location. This should be used  * to free read-only resources that require write access for your update.  *  * @note OnPluginUpdated will be called later during the same frame.  *  * @noreturn  */ forward Updater_OnPluginUpdating(); /**  * Called when your plugin's update has been completed. It is safe  * to reload your plugin at this time.  *  * @noreturn  */ forward Updater_OnPluginUpdated(); /**  * @brief Reloads a plugin.  *  * @param plugin    Plugin Handle (INVALID_HANDLE uses the calling plugin).  * @noreturn  */ stock ReloadPlugin(Handle:plugin=INVALID_HANDLE);

When testing an update with your plugin, I recommend that you test it against a debug version of Updater. It will log detailed download information to Updater_Debug.log in case you accidentally used malformed URLs or paths.
Code:
/* Line 25: updater.sp */ #define DEBUG   // This will enable verbose logging. Useful for developers testing their updates.

Example Plugin
Code:
#include <sourcemod> #undef REQUIRE_PLUGIN #include <updater> #define UPDATE_URL    "http://website.com/myplugin/updatefile.txt" public OnPluginStart() {     if (LibraryExists("updater"))     {         Updater_AddPlugin(UPDATE_URL)     } } public OnLibraryAdded(const String:name[]) {     if (StrEqual(name, "updater"))     {         Updater_AddPlugin(UPDATE_URL)     } }
Now let's take a look at what UPDATE_URL is pointing to ...

Update File Format

Simple Update - Majority of plugins will use this.
Code:

"Updater"
{
        "Information"
        {
                "Version"
                {
                        "Latest"        "1.0.1"
                }
               
                "Notes"        "More info @ www.sourcemod.net. Changes in 1.0.1:"
                "Notes"        "Added new Batman model"
                "Notes"        "Minor code changes"
        }
       
        "Files"
        {
                "Plugin"        "Path_SM/plugins/myplugin.smx"
                "Plugin"        "Path_SM/translations/myplugin.phrases.txt"
                "Plugin"        "Path_SM/translations/ru/myplugin.phrases.txt"
                "Plugin"        "Path_Mod/models/characters/batman.mdl"
                "Plugin"        "Path_Mod/materials/models/characters/batman.vmt"
               
                "Source"        "Path_SM/scripting/myplugin.sp"
        }
}

Patch Update - Useful on large plugins to avoid downloading all files when only a few have changed. Patch files will be used if the "Previous" version matches the server's currently running version.
Code:

"Updater"
{
        "Information"
        {
                "Version"
                {
                        "Latest"        "1.0.1"
                        "Previous"        "1.0.0"
                }
               
                "Notes"        "More info @ www.sourcemod.net. Changes in 1.0.1:"
                "Notes"        "Added Russian phrases"
                "Notes"        "Minor code changes"
        }
       
        "Files"
        {
                "Patch"
                {
                        "Plugin"        "Path_SM/plugins/myplugin.smx"
                        "Plugin"        "Path_SM/translations/ru/myplugin.phrases.txt"

                        "Source"        "Path_SM/scripting/myplugin.sp"
                }
               
                "Plugin"        "Path_SM/plugins/myplugin.smx"
                "Plugin"        "Path_SM/translations/myplugin.phrases.txt"
                "Plugin"        "Path_SM/translations/ru/myplugin.phrases.txt"
                "Plugin"        "Path_Mod/models/characters/batman.mdl"
                "Plugin"        "Path_Mod/materials/models/characters/batman.vmt"
               
                "Source"        "Path_SM/scripting/myplugin.sp"
        }
}

All web paths are relative to your plugin's update file (UPDATE_URL in this case). Using the above example, the URLs for this update would look like this:

Code:

UPDATE_URL = http://website.com/myplugin/updatefile.txt

http://website.com/myplugin/plugins/myplugin.smx
http://website.com/myplugin/translations/myplugin.phrases.txt
http://website.com/myplugin/translations/ru/myplugin.phrases.txt
http://website.com/myplugin/models/characters/batman.mdl
http://website.com/myplugin/materials/models/characters/batman.vmt
http://website.com/myplugin/scripting/myplugin.sp

Final Notes
  • You should only reload your plugin manually if your plugin can handle late load situations. Otherwise letting it reload automatically during the next mapchange is safest.
  • If you have released a plugin that uses Updater, post a link to it in this thread. I'd like to take a look at it!
  • If you're looking for somewhere to host your update files for free: Updater Integration Using Bitbucket

KyleS 10-08-2011 15:54

Re: Updater
 
Holy smokes nice job!

McFlurry 10-08-2011 16:26

Re: Updater
 
This is pretty awesome, have some bacon. :bacon!:

GoD-Tony 10-12-2011 09:05

Re: Updater
 
Changelog
Quote:

Updater 1.2.2
- Added support for downloading updates using the SteamWorks extension.

Quote:

Updater 1.2.1
- Added support for SourceMod 1.7.
- Minor fixes for http-redirects.

Quote:

Updater 1.2.0
- Changed from KV to SMC for parsing updater manifests.
--- This fixes plugin versions sometimes being converted to float values.
- Removed 10 second startup delay.
- Fixed plugins without an info enum logging garbage data.
- Fixed SSL URLs being incorrectly prefixed.
- Fixed error handling when failing to create files.
- Fixed error log ordering potentially affecting downloads.
- Improved Socket extension support.
--- Added support for HTTP redirects.
--- Improved HTTP error logging.
--- SSL download attempts will now properly throw an error.
- Improved debug error logs.

Quote:

Updater 1.1.5
- Fixed multiple HTTP parsing issues with Sockets.

Quote:

Updater 1.1.4
- Added support for nesting plugins in plugin directory.

Quote:

Updater 1.1.3
- Added command to check Updater status: sm_updater_status
- Disabled HTTP download caching on all extensions.
- Improved error logging.
- Updated documentation.

Quote:

Updater 1.1.1
- Auto-fix urls for SteamTools if missing http prefix.

Quote:

Updater 1.1.0
- Added support for downloading updates using the SteamTools extension.
- Added a command to force all plugins to be checked for updates: sm_updater_check
- Improved logging on unsuccessful updates.

Quote:

Updater 1.0.2
- Added a log message when a plugin was successfully updated.
- Added a log message when Updater restarts itself after being updated.

Quote:

Updater 1.0.1
- Prevent parsing of corrupt KV files
- Added more descriptive update logging
- Updated some documentation
- Minor code changes


Powerlord 10-12-2011 09:37

Re: Updater
 
What's the advantage of using this over Plugin Autoupdater?

GoD-Tony 10-12-2011 09:52

Re: Updater
 
Quote:

Originally Posted by Powerlord (Post 1573485)
What's the advantage of using this over Plugin Autoupdater?

I made this because that plugin had bugs piling up and it wasn't being maintained. I originally made this for SMAC early in the year, but decided to release it as a separate plugin so that anyone could use it in other projects, including my own.

I incorporated this quick list of ideas to start:
Quote:

Originally Posted by GoD-Tony (Post 1562013)
  • Bug fixes.
  • Path_SM support instead of having to hardcode the SourceMod folder (none of my servers used the original name).
  • KeyValue files instead of XML.
  • More features for developers, and less confusing for users.
  • The auto-updating plugin should update itself, so that other plugins can always rely on the latest features/fixes.

In addition, XML wasn't very pawn friendly, and there was a bug that scattered files if the URL or local path was too long. This plugin also lets the user to choose which extension they want to use (some had crashing issues with Sockets).

Despirator 10-12-2011 12:02

Re: Updater
 
thank you GoD-Tony. I really appreciate it

Steell 10-12-2011 13:14

Re: Updater
 
If I may request a feature: can we have an option that makes a backup of a certain file, rather than just replacing it?

GoD-Tony 10-12-2011 14:17

Re: Updater
 
Quote:

Originally Posted by Steell (Post 1573602)
can we have an option that makes a backup of a certain file, rather than just replacing it?

I thought about this before but couldn't decide on a proper way to implement it.

How would you like the backups to work? Should all of the replaced files be grouped into the same folder, or should they keep their directory structure intact but move to /data/updater/backups?

The main problem I see with backups is that they're rendered useless if a plugin is updated twice within a close time-frame. Basically your backups would only be as good as the second newest version.

Steell 10-12-2011 15:16

Re: Updater
 
Quote:

Originally Posted by GoD-Tony (Post 1573632)
I thought about this before but couldn't decide on a proper way to implement it.

How would you like the backups to work? Should all of the replaced files be grouped into the same folder, or should they keep their directory structure intact but move to /data/updater/backups?

The main problem I see with backups is that they're rendered useless if a plugin is updated twice within a close time-frame. Basically your backups would only be as good as the second newest version.

I was thinking just rename the file by appending -backupDDMMYYYY to the end of the filename (or something to that effect).

Paparazziv2 10-12-2011 16:36

Re: Updater
 
Quote:

L 10/12/2011 - 17:28:01: [SM] Plugin encountered error 25: Call was aborted
L 10/12/2011 - 17:28:01: [SM] Native "SetFailState" reported: This plugin requires the cURL or Socket extension.
L 10/12/2011 - 17:28:01: [SM] Displaying call stack trace for plugin "updater.smx":
L 10/12/2011 - 17:28:01: [SM] [0] Line 76, updater/download.sp::ProcessDownloadQueue()
L 10/12/2011 - 17:28:01: [SM] [1] Line 97, updater/download.sp::AddToDownloadQueue()
L 10/12/2011 - 17:28:01: [SM] [2] Line 196, D:\srcds\orangebox\cstrike\addons\sourcemod\s cripting\updater.sp::Updater_Check()
L 10/12/2011 - 17:28:01: [SM] [3] Line 140, D:\srcds\orangebox\cstrike\addons\sourcemod\s cripting\updater.sp::Timer_CheckUpdates()
L 10/12/2011 - 17:28:22: [umc-rockthevote.smx] RTV: RTV is now available.
with socket 3.0.1

GoD-Tony 10-12-2011 17:47

Re: Updater
 
Quote:

Originally Posted by Steell (Post 1573661)
I was thinking just rename the file by appending -backupDDMMYYYY to the end of the filename (or something to that effect).

This could create a lot of "hidden spam" for plugins with many update files. If a file buried in the /translations/jp/ folder kept getting written to, a server op may not notice until it's flooded. Using the date is a good idea though.

Quote:

Originally Posted by Paparazziv2 (Post 1573698)
with socket 3.0.1

Something odd is going on with your extension setup. Can you paste an "sm exts list" after the error occurs?

Sockets is somehow loaded in the beginning (passing the first check) but unavailable at the time of the update (10 seconds in).

Paparazziv2 10-12-2011 18:14

Re: Updater
 
yes, now all extension load perfectly (Automatically), but without extension of raydan, (Only Socket 3.0.1). This launch a error, not is problem now, because i have the two sockets. and Thanks!

Steell 10-12-2011 18:14

Re: Updater
 
Quote:

Originally Posted by GoD-Tony (Post 1573753)
This could create a lot of "hidden spam" for plugins with many update files. If a file buried in the /translations/jp/ folder kept getting written to, a server op may not notice until it's flooded. Using the date is a good idea though.

Perhaps have it so it's configurable on a per-file basis for the developer, and have a cvar to enable/disable backup for the client.

Peace-Maker 10-14-2011 19:03

Re: Updater
 
Awesome job! Implementing that into all my plugins now:)

sinblaster 10-14-2011 19:26

Re: Updater
 
Can I ask, is this how the cvar gets entered?
sm_updater "1|2|3"

| < is valid?

Peace-Maker 10-14-2011 19:54

Re: Updater
 
| should be considered as an exclusive "or".

GoD-Tony 10-15-2011 02:06

Re: Updater
 
Quote:

Originally Posted by sinblaster (Post 1575472)
Can I ask, is this how the cvar gets entered?
sm_updater "1|2|3"

| < is valid?

I just meant that the valid options are 1, 2, or 3. :)

sinblaster 10-15-2011 04:42

Re: Updater
 
thanks Tony.

I am getting this error yet I have socket installed, so I didnt think I needed curl also (as mentioned in first post)



L 10/15/2011 - 18:26:08: [SM] Unable to load extension "curl.ext": The specified module could not be found.

GoD-Tony 10-15-2011 05:05

Re: Updater
 
Quote:

Originally Posted by sinblaster (Post 1575741)
I am getting this error yet I have socket installed, so I didnt think I needed curl also (as mentioned in first post)

That is part of bug 5112 which is fixed in SourceMod 1.4. The error is harmless (other than the spam) and can be ignored.

sinblaster 10-15-2011 05:24

Re: Updater
 
Thanks tony, sorry to be such a pain today.

klausenbusk 10-15-2011 15:03

Re: Updater
 
A little note to devs, you can use pastebin (require user for this).
Set update_url "http://pastebin.com/raw.php?i=<paste id>"

GoD-Tony 10-15-2011 15:40

Re: Updater
 
Quote:

Originally Posted by klausenbusk (Post 1576230)
A little note to devs, you can use pastebin (require user for this).
Set update_url "http://pastebin.com/raw.php?i=<paste id>"

Pastebin lets you upload plugins?

klausenbusk 10-15-2011 19:32

Re: Updater
 
Quote:

Originally Posted by GoD-Tony (Post 1576250)
Pastebin lets you upload plugins?

Nope :)

TnTSCS 10-16-2011 12:32

Re: Updater
 
thanks for this plugin - updated :)

so far, only SMAC will stay updated LoL

so far, the updater.txt only shows the following:
Code:


"Updater"
{
        "Information"
        {
                "Version"
                {
                        "Latest"                "0.7.0.3"
                }
        }
       
        "Files"
        {
                "Plugin"                "Path_SM/plugins/smac_spinhack.smx"
                "Source"                "Path_SM/scripting/smac_spinhack.sp"
        }
}

Is that normal? only the one module is listed?

GoD-Tony 10-16-2011 14:22

Re: Updater
 
Quote:

Originally Posted by TnTSCS (Post 1576964)
Is that normal? only the one module is listed?

For SMAC, each module updates itself individually, and I don't add a changelog if nothing significant changed other than the version number. A better example might be the core update file.

GoD-Tony 10-17-2011 05:22

Re: Updater
 
Updater 1.0.2 released - Changelog

sinblaster 10-17-2011 06:35

Re: Updater
 
Thanks heaps

klausenbusk 10-24-2011 05:31

Re: Updater
 
GoD-Tony i have a idea to a plugin, who use this plugin:
Idea: I will make a plugin, who add auto-update feature to plugin there not have it.
So you will have a config file like:
Code:

"Plugins"
{
    "sm_hosties.smx" // plugin file name
    {
        "UPDATE_URL"    "http://example.com/updater1.txt" // url to update file
    }
   
    "respawn.smx"
    {
        "UPDATE_URL"    "http://example.com/updater.txt"
    }
}

So if the auther not will add auto-update functionality. Then the community can!
What do you think? (if you understand)

GoD-Tony 10-24-2011 07:21

Re: Updater
 
Quote:

Originally Posted by klausenbusk (Post 1582356)
Idea: I will make a plugin, who add auto-update feature to plugin there not have it.

If I'm understanding correctly, I don't think this will work because the Updater_AddPlugin native will only add the plugin that calls it.

Thrawn2 10-24-2011 08:50

Re: Updater
 
Quote:

Originally Posted by GoD-Tony (Post 1582380)
If I'm understanding correctly, I don't think this will work because the Updater_AddPlugin native will only add the plugin that calls it.

Damn it. Then i don't need to continue my proof-of-concept that this system could be the foundation to a sourcemod plugin repository.
The plan was to have a plugin that handles several repository-sources, much like /etc/apt/sources.list.
It would contain a repo-name + url to an updater config. The config would contain several trees (or to be precise: their package-lists) that repository provides and update them using Updater --> Part 1 is done, you have self-updating packagelists.
The same/Another plugin would then parse these package-lists, which basically contain all packages (as in plugins/extensions) in that tree and an URL to their updater config. It would hook itself into the admin menu and allow you to select packages you'd want to install by feeding the url from the package-info to Updater_AddPlugin(). -> Part 2 is done.

Second thought: I'll start with a question: Is the same plugin allowed to call Updater_AddPlugin() several times? Then this might be a non-problem, as i only care about installing those packages in the first place and all "new" files could be considered as belonging to the Installer-Plugin. Or does it unload itself when downloading starts or sth?

klausenbusk 10-24-2011 10:11

Re: Updater
 
Quote:

Originally Posted by GoD-Tony (Post 1582380)
If I'm understanding correctly, I don't think this will work because the Updater_AddPlugin native will only add the plugin that calls it.

In this plugin you use:
PHP Code:

Updater_AddPlugin(GetMyHandle(), UPDATE_URL); 

Would it not also be possible to do like this?
PHP Code:

Updater_AddPlugin(FindPluginByFile("test.smx"), UPDATE_URL); 


GoD-Tony 10-24-2011 11:25

Re: Updater
 
Quote:

Originally Posted by Thrawn2 (Post 1582422)
I'll start with a question: Is the same plugin allowed to call Updater_AddPlugin() several times?

Calling Updater_AddPlugin more than once only updates the URL for that plugin.

Quote:

Originally Posted by Thrawn2 (Post 1582422)
Or does it unload itself when downloading starts or sth?

No plugins are automatically removed unless they are unload/reloaded.

Quote:

Originally Posted by klausenbusk (Post 1582454)
In this plugin you use:
PHP Code:

Updater_AddPlugin(GetMyHandle(), UPDATE_URL); 

Would it not also be possible to do like this?
PHP Code:

Updater_AddPlugin(FindPluginByFile("test.smx"), UPDATE_URL); 


That's because Updater is calling it's own internal function, which is different from the native.

All of Updater's natives/fowards are only meant to interact with the single plugin that's being updated. The reason for it is to prevent plugins from conflicting with each others' updates. What would happen if you added an external plugin to Updater, and then that plugin itself included Updater support?

It sounds like you're looking for natives like these:
Code:
native Updater_AddExternalPlugin(Handle:plugin, const String:url[]); native Updater_RemoveExternalPlugin(Handle:plugin);
Your plugin still wouldn't know which plugins have been updated as there is no global forward for that either. I am open for suggestions, but I'd like to see a clear solution before I start adding new API.

klausenbusk 10-24-2011 12:19

Re: Updater
 
Quote:

Originally Posted by GoD-Tony (Post 1582490)
It sounds like you're looking for natives like these: Code:
PHP Code:

native Updater_AddExternalPlugin(Handle:plugin, const String:url[]); 
native Updater_RemoveExternalPlugin(Handle:plugin); 

Your plugin still wouldn't know which plugins have been updated as there is no global forward for that either. I am open for suggestions, but I'd like to see a clear solution before I start adding new API.

Maybe:
PHP Code:

native Updater_AddExternalPlugin(Handle:plugin, &Handle:plugin2, const String:url[]); 
native Updater_RemoveExternalPlugin(Handle:plugin); 

Where plugin2, is where to send the forward. (plugin2 should be optional, can't remember how :D)

Thrawn2 10-24-2011 13:11

Re: Updater
 
After taking a peek at the code, it would indeed be tedious to implement what i'm trying to achieve without changing the whole concept.
Basically i would like to use the downloading+parsing but without the forced plugin relation.
I don't want to reinvent (the axis of) the wheel, any chance you could remove the plugin-specific stuff from your download-queue + parsing stuff and expose them as natives?
I might have missed something here because i only skimmed through, sorry if thats the case ;)

E.g.:
Create a function that takes an updater-url and downloads it.
Create another function to parse it for version information etc.
Create another function to download all files it mentioned.
Use these functions yourself, re-adding any plugin-relations you had before outside of their scope.
Expose these functions.

-> Both of our ideas should be doable then, using the same core.

GoD-Tony 10-25-2011 05:46

Re: Updater
 
Updater 1.1.0 released - Changelog

Updater 1.1.1 released - Changelog

GoD-Tony 10-25-2011 06:01

Re: Updater
 
Quote:

Originally Posted by r3dw3r3w0lf (Post 1582860)
What is this, i don't even.

How did this happen? What were you testing?

napalm00 10-25-2011 06:04

Re: Updater
 
Maybe this?

Drixevel 10-25-2011 06:05

Re: Updater
 
That explains a lot, thanks. lol

Figured it was your plugin since it started to happen right after your last update. lol


All times are GMT -4. The time now is 03:00.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.