ports/128754: [port infrastructure] implement master sites randomization
Eygene Ryabinkin
rea-fbsd at codelabs.ru
Tue Nov 11 07:00:14 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: bug-followup at FreeBSD.org
Cc:
Subject: Re: ports/128754: [port infrastructure] implement master sites
randomization
Date: Tue, 11 Nov 2008 09:51:58 +0300
--YiEDa0DAkWCtVeE4
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Tue, Nov 11, 2008 at 08:54:58AM +0300, Eygene Ryabinkin wrote:
> The new patch is attached.
Trying to properly reattach the patch to be properly displayed
by query-pr.cgi.
--- 0001-Add-awk-randomization-script.patch begins here ---
=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
--- 0001-Add-awk-randomization-script.patch ends here ---
--=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
{_.-``-' {_/ #
--YiEDa0DAkWCtVeE4
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (FreeBSD)
iEYEARECAAYFAkkZK44ACgkQthUKNsbL7YihmgCbBcNB9tpJodL79RJhv+DBJ57a
jNcAoK3SVaSyymNmCxEdrVgZE9ONNvEu
=52zH
-----END PGP SIGNATURE-----
--YiEDa0DAkWCtVeE4--
More information about the freebsd-ports-bugs
mailing list