You are not logged in.

#1 2012-11-24 01:16:29

grufo
Member
Registered: 2012-08-09
Posts: 64

[Wiki] PKGBUILDs - Declaring more mirrors for a file

Hello everyone,
I wrote the wiki section PKGBUILD - Declare more mirrors for a file. The code i wrote uses wget, which is not part of the base system, so each PKGBUILD with mirrors declared in this way should declare the wget package within the makedepends array. Do you think it would be better to use "curl" instead of "wget"?

Last edited by grufo (2012-11-24 01:19:17)

Offline

#2 2012-11-24 01:19:14

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,822
Website

Re: [Wiki] PKGBUILDs - Declaring more mirrors for a file

grufo wrote:

Do you think it would be better to use "curl" instead of "wget"?

Yes.

I do prefer wget myself (I have no idea why really), and it is usually my  first go to tool for such things.  But when I start distributing a tool I try to make sure I replace wget with curl, or my specific peices with the most general piece that could do the same job.

I don't, however, know why a PKGBUILD would need mirrors.  Shouldn't you just stick with the original upstream source?

Last edited by Trilby (2012-11-24 01:21:06)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#3 2012-11-24 01:22:03

grufo
Member
Registered: 2012-08-09
Posts: 64

Re: [Wiki] PKGBUILDs - Declaring more mirrors for a file

Trilby wrote:
grufo wrote:

Do you think it would be better to use "curl" instead of "wget"?

Yes

Ok. Any code snippet for curl? How I can determine if a remote file exists without downloading it?

Offline

#4 2012-11-24 10:25:08

grufo
Member
Registered: 2012-08-09
Posts: 64

Re: [Wiki] PKGBUILDs - Declaring more mirrors for a file

The wiki user Danielwallace removed my edit writing «just because you can do something doesn't mean you should».

Offline

#5 2012-11-24 11:16:24

Allan
Developer
From: Brisbane, AU
Registered: 2007-06-09
Posts: 10,409
Website

Re: [Wiki] PKGBUILDs - Declaring more mirrors for a file

grufo wrote:

just because you can do something doesn't mean you should.

That is a good point...

Offline

#6 2012-11-24 11:35:12

grufo
Member
Registered: 2012-08-09
Posts: 64

Re: [Wiki] PKGBUILDs - Declaring more mirrors for a file

Allan wrote:

That is a good point...

The discussion about its intervention continues at danielwallace's Talk Page

However… Any code snippet to determine if a remote file exists without downloading it with curl?

Offline

#7 2012-11-26 18:27:59

grufo
Member
Registered: 2012-08-09
Posts: 64

Re: [Wiki] PKGBUILDs - Declaring more mirrors for a file

Since my wiki edit has been removed, I post it here in the case in which someone wants to know for himself how to declare a list of mirror within a PKGBUILD…

Declare more mirrors for a file

Imagine to have a PKGBUILD header like the following:

pkgname="alsa-driver"
pkgver="1.0.25"
source=("ftp://ftp.alsa-project.org/pub/driver/${pkgname}-${pkgver}.tar.bz2" "alsa-driver.install")
md5sums=("ac56465c262ced60b5eb2d6492d7a923" "60e496c5ed52bcd8e2d44c80ab2b4d10")
install="${pkgname}.install"

but you want to declare some mirrors because the primary server (ftp://ftp.alsa-project.org) is not so stable. In this case you need to declare an array of mirrors in order to detect what mirror works. See this example:

pkgname="alsa-driver"
pkgver="1.0.25"

_findMirror() {
	local _mirrors=(
		"http://alsa.mirror.fr/driver/${pkgname}-${pkgver}.tar.bz2"
		"http://dl.ambiweb.de/mirrors/ftp.alsa-project.org/driver/${pkgname}-${pkgver}.tar.bz2"
		"http://gd.tuwien.ac.at/opsys/linux/alsa/driver/${pkgname}-${pkgver}.tar.bz2"
		"http://alsa.cybermirror.org/driver/${pkgname}-${pkgver}.tar.bz2"
		"ftp://gd.tuwien.ac.at/opsys/linux/alsa/driver/${pkgname}-${pkgver}.tar.bz2"
		"ftp://ftp.task.gda.pl/pub/linux/misc/alsa/driver/${pkgname}-${pkgver}.tar.bz2"
		"ftp://mirrors.zerg.biz/alsa/driver/${pkgname}-${pkgver}.tar.bz2"
		"ftp://ftp.alsa-project.org/pub/driver/${pkgname}-${pkgver}.tar.bz2"
	)

	for mirr in ${_mirrors[@]}; do
		if wget --spider -q $mirr; then
			echo -n "$mirr"
			return 0
		fi
	done
	return 1
}

source=("$(_findMirror)" "${pkgname}.install")
md5sums=("ac56465c262ced60b5eb2d6492d7a923" "60e496c5ed52bcd8e2d44c80ab2b4d10")
install="${pkgname}.install"

Offline

#8 2012-11-26 19:18:16

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,656

Re: [Wiki] PKGBUILDs - Declaring more mirrors for a file

Trilby wrote:

I don't, however, know why a PKGBUILD would need mirrors.  Shouldn't you just stick with the original upstream source?

Well, because it could benefit me, as I'm unable to reach kernel.org (or any mirror) from my work. tongue


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#9 2012-11-26 20:23:52

grufo
Member
Registered: 2012-08-09
Posts: 64

Re: [Wiki] PKGBUILDs - Declaring more mirrors for a file

alphaniner wrote:
Trilby wrote:

I don't, however, know why a PKGBUILD would need mirrors.  Shouldn't you just stick with the original upstream source?

Well, because it could benefit me, as I'm unable to reach kernel.org (or any mirror) from my work. tongue

…or because there are packages, like "imule", "alsa-driver" and others, whose upstream source is often slow or broken…

Last edited by grufo (2012-11-27 12:52:13)

Offline

#10 2012-11-29 19:16:06

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 3,727

Re: [Wiki] PKGBUILDs - Declaring more mirrors for a file

Maybe submitting patches to get support into makepkg itself would be a better solution?


Evil #archlinux@freenode channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#11 2012-11-29 19:31:05

grufo
Member
Registered: 2012-08-09
Posts: 64

Re: [Wiki] PKGBUILDs - Declaring more mirrors for a file

Mr.Elendig wrote:

Maybe submitting patches to get support into makepkg itself would be a better solution?

Of course.

@Allan
What do you think about it?

Offline

Board footer

Powered by FluxBB