ports/128754: [port infrastructure] implement master sites randomization
Eygene Ryabinkin
rea-fbsd at codelabs.ru
Tue Nov 11 06:00:13 UTC 2008
The following reply was made to PR ports/128754; it has been noted by GNATS.
From: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
To: Pav Lucistnik <pav at FreeBSD.org>
Cc: FreeBSD-gnats-submit at FreeBSD.org
Subject: Re: ports/128754: [port infrastructure] implement master sites
randomization
Date: Tue, 11 Nov 2008 08:54:58 +0300
--AKkMM/tm2Mk6Yn/s
Content-Type: multipart/mixed; boundary="Y4VYWfdFdHwFhC6D"
Content-Disposition: inline
--Y4VYWfdFdHwFhC6D
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Pav, good day.
Mon, Nov 10, 2008 at 05:07:11PM +0100, Pav Lucistnik wrote:
> You know there already is a RANDOMIZE_MASTER_SITES variable you can put
> into your /etc/make.conf?
Now I know ;)) Thanks for the pointer!
Anyway, may be the modified awk script can be used as the drop-in
replacement for the /usr/games/random -- not every system has games
installed. One can leave the current behaviour intact, but use awk
script when /usr/games/random is unexistent.
The new patch is attached.
--=20
Eygene
_ ___ _.--. #
\`.|\..----...-'` `-._.-'_.-'` # Remember that it is hard
/ ' ` , __.--' # to read the on-line manual =20
)/' _/ \ `-_, / # while single-stepping the kernel.
`-'" `"\_ ,_.-;_.-\_ ', fsc/as #
_.-'_./ {_.' ; / # -- FreeBSD Developers handbook=20
{_.-``-' {_/ #
--Y4VYWfdFdHwFhC6D
Content-Type: text/x-diff; charset=koi8-r
Content-Disposition: attachment; filename="0001-Add-awk-randomization-script.patch"
Content-Transfer-Encoding: quoted-printable
=46rom 84c116afbd5afdf1c25823bf5a5498ae695b8ae2 Mon Sep 17 00:00:00 2001
=46rom: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
Date: Mon, 10 Nov 2008 18:38:01 +0300
Subject: [PATCH] Add awk randomization script
Currently port download sites can be randomized only if the system
has /usr/games/random installed. I introduce the script that acts
as the replacement for /usr/games/random and needs no parts that are
not exists in the base system (only AWK is needed ;))
Signed-off-by: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
---
Mk/bsd.port.mk | 5 ++++-
Mk/rnd.awk | 21 +++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletions(-)
create mode 100644 Mk/rnd.awk
diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk
index 85ec297..078634a 100644
--- a/Mk/bsd.port.mk
+++ b/Mk/bsd.port.mk
@@ -2172,8 +2172,11 @@ FETCH_CMD?=3D ${FETCH_BINARY} ${FETCH_ARGS}
.if exists(/usr/games/random)
RANDOM_CMD?=3D /usr/games/random
RANDOM_ARGS?=3D "-w -f -"
-_RANDOMIZE_SITES=3D " |${RANDOM_CMD} ${RANDOM_ARGS}"
+.else
+RANDOM_CMD?=3D ${AWK}
+RANDOM_ARGS?=3D "-f ${PORTSDIR}/Mk/rnd.awk"
.endif
+_RANDOMIZE_SITES=3D " |${RANDOM_CMD} ${RANDOM_ARGS}"
.endif
=20
TOUCH?=3D /usr/bin/touch
diff --git a/Mk/rnd.awk b/Mk/rnd.awk
new file mode 100644
index 0000000..cc7e60d
--- /dev/null
+++ b/Mk/rnd.awk
@@ -0,0 +1,21 @@
+BEGIN {
+ count =3D 0;
+}
+{
+ for (i =3D 1; i <=3D NF; i++)
+ array[count++] =3D $i;
+}
+END {
+# Need to drop a couple of initial rand() values: they tend
+# to be around 0.8 - 0.9, so for fairly small array lenght
+# they will produce identical values at the beginning.
+ srand(); rand(); rand(); rand(); rand();
+ for (i =3D count - 1; i > 0; i--) {
+ j =3D int(10*count*rand()) % i;
+ if (j =3D=3D i) continue;
+ t =3D array[i]; array[i] =3D array[j]; array[j] =3D t;
+ }
+
+ for (i =3D 0; i < count; i++)
+ print array[i];
+}
--=20
1.6.0.3
--Y4VYWfdFdHwFhC6D--
--AKkMM/tm2Mk6Yn/s
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (FreeBSD)
iEYEARECAAYFAkkZHjIACgkQthUKNsbL7Yh9GACfavtQMyMWNvStR3cUEwyoX56C
vkAAnjbS2jitZg2V12y5EgZWWJpcJpzT
=MvWz
-----END PGP SIGNATURE-----
--AKkMM/tm2Mk6Yn/s--
More information about the freebsd-ports-bugs
mailing list