How to rename a distfile

I'm trying to learn how to write ports. I'm trying my hand at some simple things first. One issue I've run into is that on some sites, like Github, I may run into instances where the link to download the file has one name, but when I click on the link in a web browser, it downloads with a different name. The link may have nothing but a version number, but the downloaded file may have the software's name appended. Yet freeBSD's fetch command download's the file with the name in the link without changing it to the proper, expected name. How do I get the desired behavior?

For example, the link may be https://github.com/bibendovsky/bstone/archive/v1.1.9.tar.gz and the file, when downloaded with a web browser, will be named bstone-1.1.9.tar.gz, but fetch will save the file as v1.1.9.tar.gz. Obviously this is unacceptable because it would lead to filename collisions when downloading distfiles. I use Github in my example, but this kind of behavior can be observed on other download sites as well.
 
Yet freeBSD's fetch command download's the file with the name in the link without changing it to the proper, expected name. How do I get the desired behavior?
Something like fetch [URL='https://github.com/bibendovsky/bstone/archive/v1.1.9.tar.gz']https://github.com/bibendovsky/bstone/archive/v1.1.9.tar.gz?dummy=/bstone-1.1.9.tar.gz[/URL]

However this is not what you need to use here. Use USE_GITHUB [1] to fetch the file when using GitHub's archive function. Then you also get a sane filename automatically.

[1] https://www.freebsd.org/doc/en_US.I...e-distfiles.html#makefile-master_sites-github

P.S. We already have games/bstone in the ports tree.
 
Thanks, tobik. I've been referencing the Porter's Handbook a lot as I learn how to write ports, but it's not always easy to quickly find the answer to a specific question. I come from the Gentoo world where you just point to the URI and use the -> redirector to automatically save the file under the desired name. So while I've got a bit of experience with this sort of thing, I'm having to learn a different way of doing things and a different way of even approaching a given task.

As far as there already being a port for bstone, I did realize that after I started working on one. But it doesn't matter. For the purposes of practice and learning, I don't mind writing a port for something which already exists if it gives me the experience I need to move forward with more complex ports. Besides, I've noticed some ports which have missing dependencies and such, so it's not necessarily a bad thing to have a second pair of eyes look at things and maybe submit a patch here or there.

Edit: For clarification, I thought the USE_GITHUB function was only for fetching specific commits from the git source and not for fetching release archives. Is this incorrect?
 
PaddyMac

USE_GITHUB is to tell the port system to use the builtin GitHub facility, then you have other necessary options.

For specific commits you should use GH_TAGNAME, and for submodules you have to use GH_SUBDIR or GH_TUPLE.
 
Back
Top