Jump to content
Ketarin forum

Omniferum's Sourceforge Template


Omniferum
 Share

Recommended Posts

I've tried to make a fairly easy to use/universal template for the souceforge site with some custom install commands that you can decomment (that just means delete the :: from the 2nd line in the scripts onwards) in order to use them.

You can use any sourceforge URL project page, this will automatically find the latest file. You can just use the 'download latest' button however I prefer to download binaries/zipped/portable versions which aren't the ones that are hosted in the 'latest' button.

Accurately defines the version variable/name and everything so tuck in.

Global variables that are used in this (that I think everyone should use anyway but whatever) are:

installpath = {root}Programs\
temppath = {root}Ketatemp\
7z = start "" /wait {root}"Programs\File Management\7-ZipPortable\App\7-Zip\7z.exe"
ue = start "" /wait {root}"Programs\File Management\Universal Extractor\UniExtract.exe"
copyfolder = xcopy /E /C /I /Q /H /Y
downloadpath = {root}Software\Ketarin Maintained Applications\
copyfile = xcopy /C /I /Q /H /Y

sfua = (!)

Just add the above values to your global variables and you will be set. Of course for the 7z/ue you need to change the path to your actual 7zip/uniextract exe file. However the only global variable you really need in order for the template to download anything is the sfua. Just an acronym for SourceForgeUserAgent.

<!--?xml version='1.0' encoding='utf-8'?-->
<Jobs>
<ApplicationJob xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Guid="806226d4-a355-4ff8-81d3-5f0956cc1658">
<WebsiteUrl>{url}</WebsiteUrl>
<UserNotes />
<IgnoreFileInformation>false</IgnoreFileInformation>
<DownloadBeta>Default</DownloadBeta>
<CheckForUpdatesOnly>false</CheckForUpdatesOnly>
<VariableChangeIndicator>version</VariableChangeIndicator>
<CanBeShared>true</CanBeShared>
<ShareApplication>false</ShareApplication>
<ExclusiveDownload>false</ExclusiveDownload>
<UserAgent>{sfua}</UserAgent>
<HttpReferer />
<Variables>
<item>
<key>
<string>download</string>
</key>
<value>
<UrlVariable>
<RegexRightToLeft>false</RegexRightToLeft>
<VariableType>RegularExpression</VariableType>
<Regex>[^"'<>\*]+files[^"'<>\*]+\.(?>zip|7z|rar|exe|msi)</Regex>
<Url>http://sourceforge.net{refer2}</Url>
<Name>download</Name>
</UrlVariable>
</value>
</item>
<item>
<key>
<string>installtype</string>
</key>
<value>
<UrlVariable>
<RegexRightToLeft>false</RegexRightToLeft>
<VariableType>Textual</VariableType>
<Regex />
<TextualContent><placeholder name="Installation type" value="" options="No Install|Binary Unzip|Manual Install|Standalone EXE|Uniextract Executable" /></TextualContent>
<Name>installtype</Name>
</UrlVariable>
</value>
</item>
<item>
<key>
<string>name</string>
</key>
<value>
<UrlVariable>
<RegexRightToLeft>false</RegexRightToLeft>
<VariableType>RegularExpression</VariableType>
<Regex><title>(.*?)[\s-]+</Regex>
<Url>http://sourceforge.net{page}</Url>
<Name>name</Name>
</UrlVariable>
</value>
</item>
<item>
<key>
<string>page</string>
</key>
<value>
<UrlVariable>
<RegexRightToLeft>false</RegexRightToLeft>
<VariableType>RegularExpression</VariableType>
<Regex>[^"';=]+files[^"';=]+</Regex>
<Url>{url}</Url>
<Name>page</Name>
</UrlVariable>
</value>
</item>
<item>
<key>
<string>refer1</string>
</key>
<value>
<UrlVariable>
<RegexRightToLeft>false</RegexRightToLeft>
<VariableType>RegularExpression</VariableType>
<Regex>folder.*?([^"']+files[^"']+)</Regex>
<Url>http://sourceforge.net{page}</Url>
<Name>refer1</Name>
</UrlVariable>
</value>
</item>
<item>
<key>
<string>refer2</string>
</key>
<value>
<UrlVariable>
<RegexRightToLeft>false</RegexRightToLeft>
<VariableType>RegularExpression</VariableType>
<Regex>folder.*?([^"']+files[^"']+)</Regex>
<Url>http://sourceforge.net{refer1}</Url>
<Name>refer2</Name>
</UrlVariable>
</value>
</item>
<item>
<key>
<string>url</string>
</key>
<value>
<UrlVariable>
<RegexRightToLeft>false</RegexRightToLeft>
<VariableType>RegularExpression</VariableType>
<Regex>[^"']+projects/.*?./</Regex>
<Url><placeholder name="Application URL" /></Url>
<Name>url</Name>
</UrlVariable>
</value>
</item>
<item>
<key>
<string>version</string>
</key>
<value>
<UrlVariable>
<RegexRightToLeft>false</RegexRightToLeft>
<VariableType>RegularExpression</VariableType>
<Regex>[^"'<>\*]+files[^"'<>\*]+\.(?>zip|7z|rar|exe|msi).*?(\d\d\d\d[\d\-\: ]+)</Regex>
<Url>http://sourceforge.net{refer2}</Url>
<Name>version</Name>
</UrlVariable>
</value>
</item>
</Variables>
<ExecuteCommand>/*This is a comment line, the line below is the C# script. It will run the instructions found in the Setup Tab. If the command below is encapsulated with stars and slashes merely remove them to make the command function, otherwise it will remain a comment*/
app.Install(null);</ExecuteCommand>
<ExecutePreCommand />
<ExecuteCommandType>CS</ExecuteCommandType>
<ExecutePreCommandType>Batch</ExecutePreCommandType>
<SetupInstructions>
<SetupInstruction xsi:type="CustomSetupInstruction">
<Code>::Use this if the file you are downloading is a binary that can be unzipped and run

if "{installtype}" neq "Binary Unzip" exit

::Check to see if program is running and offer to kill it
for /f "tokens=1 delims=." %b in ('wmic process get Description^,ExecutablePath^,CommandLine ^| findstr /v cmd.exe ^| findstr /v explorer.exe ^| findstr /v findstr ^| findstr "{installpath}{category}\{appname:regexreplace: \(.*\):}"') do set progkill=%~nxb & set prog=%b & set restart=yes
if defined progkill start /wait cmd.exe /c "Echo {appname} is currently running and has to be terminated before updating, press any key to terminate the program & PAUSE & taskkill /f /im %progkill%.exe"
::/Check to see if program is running and offer to kill it

{7z} x "{file}" -o"{temppath}{appname:regexreplace: \(.*\):}" -y
for /f "tokens=2 delims=[]" %a in ('dir /b /s "{temppath}{appname:regexreplace: \(.*\):}\*.exe" ^| find /v /n "" ^| findstr /c:[1]') do set dir=%~dpa*
{copyfolder} "%dir%" "{installpath}{category}\{appname:regexreplace: \(.*\):}\"
rd /s /q "{temppath}{appname:regexreplace: \(.*\):}"

::Update finished, starting program
if defined restart start cmd.exe /c "%prog%.exe""
::/Update finished, starting program</Code>
<Type>Batch</Type>
</SetupInstruction>
<SetupInstruction xsi:type="CustomSetupInstruction">
<Code>::Use this if the file you are downloading is an executable that can be UniExtracted and run

if "{installtype}" neq "Uniextract Executable" exit

::Check to see if program is running and offer to kill it
for /f "tokens=1 delims=." %b in ('wmic process get Description^,ExecutablePath^,CommandLine ^| findstr /v cmd.exe ^| findstr /v explorer.exe ^| findstr /v findstr ^| findstr "{installpath}{category}\{appname:regexreplace: \(.*\):}"') do set progkill=%~nxb & set prog=%b & set restart=yes
if defined progkill start /wait cmd.exe /c "Echo {appname} is currently running and has to be terminated before updating, press any key to terminate the program & PAUSE & taskkill /f /im %progkill%.exe"
::/Check to see if program is running and offer to kill it

{ue} "{file}" "{temppath}{appname:regexreplace: \(.*\):}"
for /f "tokens=2 delims=[]" %a in ('dir /b /s "{temppath}{appname:regexreplace: \(.*\):}\*.exe" ^| find /v /n "" ^| findstr /c:[1]') do set dir=%~dpa*
{copyfolder} "%dir%" "{installpath}{category}\{appname:regexreplace: \(.*\):}\"
rd /s /q "{temppath}{appname:regexreplace: \(.*\):}"

::Update finished, starting program
if defined restart start cmd.exe /c "%prog%.exe""
::/Update finished, starting program</Code>
<Type>Batch</Type>
</SetupInstruction>
<SetupInstruction xsi:type="CustomSetupInstruction">
<Code>::Use this if your file cannot be installed automatically and needs to be run manually after Ketarin finishes

if "{installtype}" neq "Manual Install" exit


::Check to see if program is running and offer to kill it
for /f "tokens=1 delims=." %b in ('wmic process get Description^,ExecutablePath^,CommandLine ^| findstr /v cmd.exe ^| findstr /v explorer.exe ^| findstr /v findstr ^| findstr "{installpath}{category}\{appname:regexreplace: \(.*\):}"') do set progkill=%~nxb & set prog=%b & set restart=yes
if defined progkill start /wait cmd.exe /c "Echo {appname} is currently running and has to be terminated before updating, press any key to terminate the program & PAUSE & taskkill /f /im %progkill%.exe"
::/Check to see if program is running and offer to kill it

START CMD /C "ECHO Re: {appname} You will have to run this file manually after Ketarin finishes updating && PAUSE"
&

::Update finished, starting program
if defined restart start cmd.exe /c "%prog%.exe""
::/Update finished, starting program</Code>
<Type>Batch</Type>
</SetupInstruction>
<SetupInstruction xsi:type="CustomSetupInstruction">
<Code>::Use this if your download is a standalone executable which just needs to be copied to the right place

if "{installtype}" neq "Standalone EXE" exit

::Check to see if program is running and offer to kill it
for /f "tokens=1 delims=." %b in ('wmic process get Description^,ExecutablePath^,CommandLine ^| findstr /v cmd.exe ^| findstr /v explorer.exe ^| findstr /v findstr ^| findstr "{installpath}{category}\{appname:regexreplace: \(.*\):}"') do set progkill=%~nxb & set prog=%b & set restart=yes
if defined progkill start /wait cmd.exe /c "Echo {appname} is currently running and has to be terminated before updating, press any key to terminate the program & PAUSE & taskkill /f /im %progkill%.exe"
::/Check to see if program is running and offer to kill it

{copyfile} "{file}" "{installpath}{category}\{appname:regexreplace: \(.*\):}\"

::Update finished, starting program
if defined restart start cmd.exe /c "%prog%.exe""
::/Update finished, starting program</Code>
<Type>Batch</Type>
</SetupInstruction>
</SetupInstructions>
<Category><placeholder name="Category" options="{categories}" /></Category>
<SourceType>FixedUrl</SourceType>
<DeletePreviousFile>true</DeletePreviousFile>
<Enabled>true</Enabled>
<FileHippoId />
<TargetPath>{downloadpath}{category}\</TargetPath>
<FixedDownloadUrl>{download}</FixedDownloadUrl>
<Name><placeholder name="Name of application" variable="name" /></Name>
</ApplicationJob>
</Jobs>

EDIT: Made the option choice for user to select the type of install. I would recommend however knowing the installation method for the file you are downloading from sourceforge beforehand before blindly selecting what install type. The default option is "No Install" meaning it will just download and not execute any of my custom install options.

EDIT: Tweaked the 'version' variable as sourceforge does stuff like "Updated 1 hour ago" and so on. Changed it to the time stamp of the file you are actually downloading. Some regex tweaks (Atomic Grouping specifically). Also implemented my new 'kill program if running' dialog. It basically looks into your default install path and checks if any executables are running from that path before giving the option to terminate it.
Link to comment
Share on other sites

I did consider doing that a while ago however it is hard to automatically detect if the executable will run via being uniextracted so people would still prefer to pick/choose/figure out for themselves what is the best install method for their program. A zip can contain a standalone executable or an extractable msi file which may have to be installed anyway. Plus not everyone wants a portable installation of a program like me.

 

I'm sure though I could patch a script up to account for 90% of situations however if you make things too automated I find people tend to become too complacent. As for a GUID 'tis done even though i've never gotten the prototype templates to work for me ever, no idea why

Link to comment
Share on other sites

  • 1 month later...

I get the following error when impoting:

 

 

---------------------------

Failed to import the file: The 'applicationjob' start tag on line 3 does not match the end tag of 'ApplicationJob'. Line 220, position 5.

---------------------------

Link to comment
Share on other sites

  • 1 year later...
Guest Tomatko

OK.. so i try it, but it doesn't work at all :( Tryed with Filezilla.. put the link as: http://sourceforge.net/projects/filezilla/?source=directory.. but it messed it up. It show,that URI can't be determinated. Also if i put this address http://sourceforge.net/projects/filezilla/files/FileZilla_Client/3.7.3/FileZilla_3.7.3_win32-setup.exe/download .. but it is the same :( Where do I make mistake ?

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.