Jump to page: 1 2
Thread overview
Downloading Latest D Language DMD compiler via Windows 10 batch script file.
Dec 17, 2019
BoQsc
Dec 17, 2019
H. S. Teoh
Dec 17, 2019
Eugene Wissner
Dec 17, 2019
H. S. Teoh
Dec 17, 2019
Eugene Wissner
Dec 19, 2019
JN
Dec 19, 2019
Gregor Mückl
Dec 18, 2019
singingbush
Dec 18, 2019
Laurent Tréguier
Dec 18, 2019
singingbush
Dec 18, 2019
Jacob Carlborg
Dec 19, 2019
BoQsc
December 17, 2019
Initialy I though about a way to download DMD compiler on a single line of command prompt.
However it turned out that dlang website makes downloading the latest version a complex thing.

Here, I'm sharing a batch script that might be interesting if you are wondering how to download and launch latest d language compiler setup in a single click.

Usage: Copy and paste the script below into a text file
and rename the text file to a file name that ends in .cmd or .bat extension

Examples:
download-dmd.cmd
download-dmd.bat

.cmd and .bat extensions are the same thing, no worries about that.


>@ECHO OFF
>
>:Download-version-number-file-from-dlang
>:: Downloads LATEST file from dlang, via bitsadmin - official command line download utility included since Windows 7
>:: LATEST file is a plain text file that contains a single line of text: a number of latest version of DMD. bitsadmin /Transfer "%random%" "http://downloads.dlang.org/releases/LATEST" "%cd%/LATEST"
>IF NOT ERRORLEVEL 0 (
>	TITLE BITSADMIN have an error, retrying to download LATEST file
>	TIMEOUT "2"
>	CLS
>	GOTO :Download-version-number-file-from-dlang )
>:: A hacky Batch language way to store File content inside a variable.
>SET /P "version=" < "LATEST"
>
>:: Simply delete LATEST file, we don't need it anymore LATEST file is stored inside variable named "version"
>DEL "LATEST"
>CLS
>
>
>:: Get YEARS from from Windows 10 Date Environment Variable
>:: Windows 7 might require adjustments to gather the correct years, as the format might be different
>SET "yearsRightNow=%date:~0,4%"
>
>:: Download Latest version of dmd compiler for Windows, via bitsadmin
>bitsadmin /Transfer "%random%" "http://downloads.dlang.org/releases/%yearsRightNow%/dmd-%version%.exe" "%cd%/dmd-%version%.exe"
>
>:: Launch the downloaded compiler's setup
>start "" "dmd-%version%.exe"
>
>
December 17, 2019
On Tue, Dec 17, 2019 at 04:55:56PM +0000, BoQsc via Digitalmars-d wrote:
> Initialy I though about a way to download DMD compiler on a single
> line of command prompt.
> However it turned out that dlang website makes downloading the latest
> version a complex thing.

Why is that?

IMO, we should have a fixed URL, something like http://dlang.org/download/dmd-latest-$OS.zip, that always points to the latest release.  That way people can just download from there without having to figure out what the latest version number is.

On the server side, we could use a HTTP 307 (temporary redirect) from that URL to whatever the latest release is, so that the browser / downloader will get the correct filename, and won't cache old releases incorrectly.


T

-- 
Questions are the beginning of intelligence, but the fear of God is the beginning of wisdom.
December 17, 2019
On Tuesday, 17 December 2019 at 16:55:56 UTC, BoQsc wrote:
> Initialy I though about a way to download DMD compiler on a single line of command prompt.
> However it turned out that dlang website makes downloading the latest version a complex thing.
>
> Here, I'm sharing a batch script that might be interesting if you are wondering how to download and launch latest d language compiler setup in a single click.
>
> Usage: Copy and paste the script below into a text file
> and rename the text file to a file name that ends in .cmd or .bat extension
>
> Examples:
> download-dmd.cmd
> download-dmd.bat
>
> .cmd and .bat extensions are the same thing, no worries about that.
>
>
>>@ECHO OFF
>>
>>:Download-version-number-file-from-dlang
>>:: Downloads LATEST file from dlang, via bitsadmin - official command line download utility included since Windows 7
>>:: LATEST file is a plain text file that contains a single line of text: a number of latest version of DMD. bitsadmin /Transfer "%random%" "http://downloads.dlang.org/releases/LATEST" "%cd%/LATEST"
>>IF NOT ERRORLEVEL 0 (
>>	TITLE BITSADMIN have an error, retrying to download LATEST file
>>	TIMEOUT "2"
>>	CLS
>>	GOTO :Download-version-number-file-from-dlang )
>>:: A hacky Batch language way to store File content inside a variable.
>>SET /P "version=" < "LATEST"
>>
>>:: Simply delete LATEST file, we don't need it anymore LATEST file is stored inside variable named "version"
>>DEL "LATEST"
>>CLS
>>
>>
>>:: Get YEARS from from Windows 10 Date Environment Variable
>>:: Windows 7 might require adjustments to gather the correct years, as the format might be different
>>SET "yearsRightNow=%date:~0,4%"
>>
>>:: Download Latest version of dmd compiler for Windows, via bitsadmin
>>bitsadmin /Transfer "%random%" "http://downloads.dlang.org/releases/%yearsRightNow%/dmd-%version%.exe" "%cd%/dmd-%version%.exe"
>>
>>:: Launch the downloaded compiler's setup
>>start "" "dmd-%version%.exe"

This is the same thing GNOME does. And it allows to automate compiler updates and allows to figure out what is the latest version (useful for tools). "dmd-latest.deb" or similar is more useful for human beings but is less "generic" approach since a tool wouldn't know what version it is. And imho there is the homepage for humans which always displays the latest version.
December 17, 2019
On Tue, Dec 17, 2019 at 06:08:05PM +0000, Eugene Wissner via Digitalmars-d wrote: [...]
> This is the same thing GNOME does. And it allows to automate compiler updates and allows to figure out what is the latest version (useful for tools). "dmd-latest.deb" or similar is more useful for human beings but is less "generic" approach since a tool wouldn't know what version it is.
[...]

Not really.  The idea is this:

1) Have a fixed URL that never changes, that always points to the latest
   release. So your script doesn't have to figure out anything, just
   download from the fixed URL.

2) Use HTTP 307 to redirect the fixed URL to the actual URL, so that the
   downloaded filename will have the correct version embedded.

3) The script can parse the filename to figure out what the version is.


T

-- 
Without geometry, life would be pointless. -- VS
December 17, 2019
On Tuesday, 17 December 2019 at 18:32:30 UTC, H. S. Teoh wrote:
> On Tue, Dec 17, 2019 at 06:08:05PM +0000, Eugene Wissner via Digitalmars-d wrote: [...]
>> [...]
> [...]
>
> Not really.  The idea is this:
>
> 1) Have a fixed URL that never changes, that always points to the latest
>    release. So your script doesn't have to figure out anything, just
>    download from the fixed URL.
>
> 2) Use HTTP 307 to redirect the fixed URL to the actual URL, so that the
>    downloaded filename will have the correct version embedded.
>
> 3) The script can parse the filename to figure out what the version is.
>
>
> T

ah yes, would work too. +1
December 18, 2019
On Tuesday, 17 December 2019 at 16:55:56 UTC, BoQsc wrote:
> Initialy I though about a way to download DMD compiler on a single line of command prompt.
> However it turned out that dlang website makes downloading the latest version a complex thing.
>
> Here, I'm sharing a batch script that might be interesting if you are wondering how to download and launch latest d language compiler setup in a single click.
>
> Usage: Copy and paste the script below into a text file
> and rename the text file to a file name that ends in .cmd or .bat extension
>
> Examples:
> download-dmd.cmd
> download-dmd.bat
>
> .cmd and .bat extensions are the same thing, no worries about that.
>
>
>>[...]

There's no need because both DMD and LDC are in available via chocolatey.

https://chocolatey.org/search?q=Dmd

So simply: choco install dmd
December 18, 2019
On Wednesday, 18 December 2019 at 07:16:30 UTC, singingbush wrote:
> There's no need because both DMD and LDC are in available via chocolatey.
>
> https://chocolatey.org/search?q=Dmd
>
> So simply: choco install dmd

It doesn't look up to date, version 2.087.0 was 2 releases ago. Looking at the package release history, it's updated like once every year, so it's definitely not a good solution to have the latest version.
Besides, it also means depending on chocolatey to download it.
December 18, 2019
On Wednesday, 18 December 2019 at 09:03:25 UTC, Laurent Tréguier wrote:
> On Wednesday, 18 December 2019 at 07:16:30 UTC, singingbush wrote:
>> There's no need because both DMD and LDC are in available via chocolatey.
>>
>> https://chocolatey.org/search?q=Dmd
>>
>> So simply: choco install dmd
>
> It doesn't look up to date, version 2.087.0 was 2 releases ago. Looking at the package release history, it's updated like once every year, so it's definitely not a good solution to have the latest version.
> Besides, it also means depending on chocolatey to download it.

That needs sorting out then. To fair to PxlBuzzard that was only a few months ago. DMD release very frequently. I'd actually rather have less frequent but more reliable releases. That's a separate issue though.

Chocolatey is probably the best option for keeping dev tools up to date on Windows in the same way that Mac users use homebrew and Linux users update from their chosen repositories. It's a lot easier to 'choco upgrade all -y' and have all my tools updated than to individually run scripts for each thing individually.
December 18, 2019
On 2019-12-17 17:55, BoQsc wrote:

>> :: Get YEARS from from Windows 10 Date Environment Variable
>> :: Windows 7 might require adjustments to gather the correct years, as the format might be different
>> SET "yearsRightNow=%date:~0,4%"

Instead of using the current year, you can use this base URL: http://downloads.dlang.org/releases/2.x/

-- 
/Jacob Carlborg
December 19, 2019
On Wednesday, 18 December 2019 at 18:39:11 UTC, Jacob Carlborg wrote:
> On 2019-12-17 17:55, BoQsc wrote:
>
>>> :: Get YEARS from from Windows 10 Date Environment Variable
>>> :: Windows 7 might require adjustments to gather the correct years, as the format might be different
>>> SET "yearsRightNow=%date:~0,4%"
>
> Instead of using the current year, you can use this base URL: http://downloads.dlang.org/releases/2.x/

Well, then the script won't download the latest version, it simply downloads latest version of 2.x version.

You'll never know when 3.x version comes along and will be released.
The script still need additional lines of code to figure out if it is 3.x, 4.x, 5.x release yet.

It is only personal preference. For me, checking for date is more readable, than checking for major version changes.

Although in a perfect world there should be no checks at all, simply a direct link to latest version. Then we would be left with only a single line of code of bitsadmin, and that would be great.
« First   ‹ Prev
1 2