WolverineFan / YNABLinuxInstall

Install script for YNAB 4 on Linux
174 stars 18 forks source link

Automatically check for and download an up-to-date installer #5

Closed ElliotFriend closed 10 years ago

ElliotFriend commented 10 years ago

Hey, WolverineFan!

First, I love your script! Second, I had a thought the other day about a cool feature I'd like to see in it, where the script can download the most up-to-date YNAB4 installer automatically.

I started coding on a branch, and I'm pretty confident I can make that happen on my own. Before I get too far down the rabbit hole, though, I wanted to check with you to see if you'd even be interested in a feature like that.

Thanks! ElliotFriend

WolverineFan commented 10 years ago

Most definitely! That's a feature I wanted to add from the start. I asked the YNAB guys if it would be OK and didn't hear a response, so I'll take that as a tacit "sure thing". Go right ahead and add it :)

ElliotFriend commented 10 years ago

Nothing better than a silent head nod haha

My first effort was to fetch the download page and search through it using a regex for the version number, and download link. Most definitely not a sustainable way to do that. I thought to myself, if YNAB automatically checks for the most recent version, they must have implemented some kind of page that YNAB gets to check the date.

I finally found this JSON page, which should be much easier and less error-prone: http://www.youneedabudget.com/dev/ynab4/liveCaptive/Win/releaseNotesData.js

I reached out to the YNAB peeps, too, concerning this. Haven't heard back from them, either lol

WolverineFan commented 10 years ago

That link sure makes this easier! The one thing I want to avoid is using non-standard Perl modules. Anything bundled with 5.10+ if fair game though. Alternatively you could check to see if they have the command-line tools "curl" or "wget" installed and use which ever they have. I suppose to be complete you could check to see if they have LWP installed (if it's not bundled yet, I haven't checked) and then fall back to command-line.

Let me know if you get stuck. I'd be happy to take a look.

Jeremy

ElliotFriend commented 10 years ago

Thanks, Jeremy!

At first, I was playing with LWP (which was available on my distro, but I'll check what's bundled with 5.10. I'm a perl novice, so I definitely appreciate the pointers.

WolverineFan commented 10 years ago

It's relatively easy to check to see if a module exists (if you haven't figured this out already): eval("use LWP"); if ($@) {

Not there, look for curl or wget

} else {

LWP loaded, we can use it here

}

That might just be the easiest way to go actually.

ElliotFriend commented 10 years ago

Seems good to me. In fact, aside from a couple Arch and one LFS install, I've never come across a distro that doesn't ship with both wget and curl.

Thanks!

ElliotFriend commented 10 years ago

Evidently, I spoke too soon. My freshly installed Mint 16 has wget, but not curl... weird. I'll probably check for wget first, and then fall back to curl if wget is not available. Does that sound good? Should I swap those around?

ElliotFriend commented 10 years ago

I heard back from Ian, and I got an implied "go ahead." He also pointed me to a more to-the-point page to request current version from: http://www.youneedabudget.com/dev/ynab4/liveCaptive/Win/update.xml

Here's the support case, if anyone's interested: https://ynab.fogbugz.com/default.asp?94401_ka45pfmc4usb5dmn

WolverineFan commented 10 years ago

Nice work! And a handy MD5 to boot :)

I don't think the order you check for wget/curl matters so long as you check for both. If they don't have LWP/wget/curl there's not much we can do for them :)

ElliotFriend commented 10 years ago

Everything looks like it's working (at least for me haha): e74cf924f4b3ffcbf201cb75d00ca940b086fae7

Would you mind taking a look? Let me know your thoughts, and you might just have yourself a pull request :-D

I was having trouble using the Digest::MD5 module, which is bundled with 5.10+. For now, I've just made a system call to md5sum, but is that always available?

Thanks!

ElliotFriend commented 10 years ago

Here's a link to the whole file from that commit: https://github.com/ElliotFriend/YNABLinuxInstall/blob/e74cf924f4b3ffcbf201cb75d00ca940b086fae7/YNAB4_LinuxInstall.pl

ElliotFriend commented 10 years ago

I spoke too soon about Digest::MD5: 4c39193e2471cbd6a23e400e0d45fe5f604e0d3f

That's one less thing I'm worried about :)