From fbea8a558a44cce4db3f5bd1b4758b5bfe4bd875 Mon Sep 17 00:00:00 2001 From: Michael Raskin <7c6f434c@mail.ru> Date: Wed, 26 Aug 2009 11:13:36 +0000 Subject: [PATCH] Adding WebDruid log analyzer. In the same time, reworking source autoupdate system a bit svn path=/nixpkgs/trunk/; revision=16859 --- .../builder-defs/builder-defs.nix | 5 +++ .../builder-defs/template-bdp-uud.nix | 12 ++---- .../build-support/upstream-updater/design.txt | 2 + .../upstream-updater/snippets.sh | 6 +++ .../upstream-updater/update-upstream-data.sh | 43 ++++++++++++++----- pkgs/development/libraries/geoip/default.nix | 25 +++++++++++ .../libraries/geoip/src-for-default.nix | 8 ++++ .../libraries/geoip/src-info-for-default.nix | 6 +++ pkgs/tools/admin/webdruid/default.nix | 30 +++++++++++++ pkgs/tools/admin/webdruid/src-for-default.nix | 8 ++++ .../admin/webdruid/src-info-for-default.nix | 7 +++ pkgs/top-level/all-packages.nix | 9 ++++ 12 files changed, 142 insertions(+), 19 deletions(-) create mode 100644 pkgs/build-support/upstream-updater/snippets.sh create mode 100644 pkgs/development/libraries/geoip/default.nix create mode 100644 pkgs/development/libraries/geoip/src-for-default.nix create mode 100644 pkgs/development/libraries/geoip/src-info-for-default.nix create mode 100644 pkgs/tools/admin/webdruid/default.nix create mode 100644 pkgs/tools/admin/webdruid/src-for-default.nix create mode 100644 pkgs/tools/admin/webdruid/src-info-for-default.nix diff --git a/pkgs/build-support/builder-defs/builder-defs.nix b/pkgs/build-support/builder-defs/builder-defs.nix index 94d3ea8265c..e4bf4c148c4 100644 --- a/pkgs/build-support/builder-defs/builder-defs.nix +++ b/pkgs/build-support/builder-defs/builder-defs.nix @@ -521,4 +521,9 @@ let inherit (builtins) head tail trace; in ensureDir $(toPythonPath $out) export PYTHONPATH=$PYTHONPATH''${PYTHONPATH:+:}$(toPythonPath $out) '') ["minInit" "addInputs" "defEnsureDir"]; + + fetchUrlFromSrcInfo = srcInfo: fetchurl { + url = srcInfo.url; + sha256 = srcInfo.hash; + }; }) // args diff --git a/pkgs/build-support/builder-defs/template-bdp-uud.nix b/pkgs/build-support/builder-defs/template-bdp-uud.nix index 46d2da40a70..a84239f62d5 100644 --- a/pkgs/build-support/builder-defs/template-bdp-uud.nix +++ b/pkgs/build-support/builder-defs/template-bdp-uud.nix @@ -1,26 +1,20 @@ a : let - fetchurl = a.fetchurl; - s = import ./src-info-for-default.nix; - - version = a.lib.attrByPath ["version"] s.version a; + s = import ./src-for-default.nix; buildInputs = with a; [ ]; in rec { - src = fetchurl { - url = s.url; - sha256 = s.hash; - }; + src = a.fetchUrlFromSrcInfo s; + inherit (s) name; inherit buildInputs; configureFlags = []; /* doConfigure should be removed if not needed */ phaseNames = ["doConfigure" "doMakeInstall"]; - name = "${abort "Specify name"}-" + version; meta = { description = "${abort "Specify description"}"; maintainers = [ diff --git a/pkgs/build-support/upstream-updater/design.txt b/pkgs/build-support/upstream-updater/design.txt index 2f5a78c0bfa..407f9e5bc1b 100644 --- a/pkgs/build-support/upstream-updater/design.txt +++ b/pkgs/build-support/upstream-updater/design.txt @@ -12,6 +12,7 @@ Attributes: src-info-for-file.nix: downloadPage +baseName (default = unnamed-package) sourceRegexp (default = '.*[.]tar[.].*') choiceCommand (default = 'head -1') versionExtractorSedScript (default = 's/.*-([0-9.]+)[.].*/\1/') @@ -24,3 +25,4 @@ advertisedUrl (its match is the check for update presence) url hash version +name diff --git a/pkgs/build-support/upstream-updater/snippets.sh b/pkgs/build-support/upstream-updater/snippets.sh new file mode 100644 index 00000000000..27a7c14b1ec --- /dev/null +++ b/pkgs/build-support/upstream-updater/snippets.sh @@ -0,0 +1,6 @@ +# sed scripts + +#http://sourceforge.net/projects/webdruid/files/webdruid/0.6.0-alpha5/webdruid-0.6.0-alpha5.tar.gz/download +#http://downloads.sourceforge.net/webdruid/files/webdruid/0.6.0-alpha5/webdruid-0.6.0-alpha5.tar.gz +skipRedirectSF='s@^http://sourceforge.net/projects/@http://downloads.sourceforge.net/@; s@/download$@@' +extractReleaseSF='s@.*/([^/]+)/[^/]+@\1@' diff --git a/pkgs/build-support/upstream-updater/update-upstream-data.sh b/pkgs/build-support/upstream-updater/update-upstream-data.sh index 4aad91fdac2..b07e867fda9 100755 --- a/pkgs/build-support/upstream-updater/update-upstream-data.sh +++ b/pkgs/build-support/upstream-updater/update-upstream-data.sh @@ -1,13 +1,18 @@ #! /bin/sh +set -x + own_dir="$(cd "$(dirname "$0")"; sh -c pwd)" +source "$own_dir/snippets.sh" + main_file="$1" main_dir="$(cd "$(dirname "$main_file")" ; sh -c pwd)" file_name="$(basename "$main_file")" defs_file="$main_dir"/src-info-for-"$file_name" src_file="$main_dir"/src-for-"$file_name" -new_src_file="$main_dir"/updated-src-for-"$file_name" +# OK, [vcs] revert is always possible +new_src_file="$main_dir"/src-for-"$file_name" forcedUrl="$2" @@ -23,8 +28,12 @@ getAttr () { if [ -z "$forcedUrl" ] ; then freshUrl="$("$own_dir"/urls-from-page.sh "$(getAttr downloadPage)" | - egrep "$(getAttr sourceRegexp '.*[.]tar[.].*')" | - sh -c "$(getAttr choiceCommand 'head -1')")" + eval "egrep \"$(getAttr sourceRegexp '.*[.]tar[.].*')\"" | + eval "$(getAttr choiceCommand 'head -1')")" + + if ! egrep ':' freshUrl ; then + freshUrl="$(dirname "$(getAttr downloadPage).")/$freshUrl" + fi echo "Found download link: $freshUrl" >&2 else @@ -37,21 +46,35 @@ if [ x"$freshUrl" = x"$(cat "$src_defs_dir"/advertisedUrl)" ]; then fi version="$(echo "$freshUrl" | - sed -re "$(getAttr versionExtractorSedScript \ - 's/.*-([0-9.]+)[.].*/\1/')")" + eval "sed -re \"$(getAttr versionExtractorSedScript \ + 's/.*-([0-9.]+)[.].*/\1/')\"")" mirrorUrl="$(echo "$freshUrl" | - sed -r -e "$(getAttr versionReferenceCreator \ - 's/-([0-9.]+)[.]/-${version}./')" | - sed -r -e "$(getAttr mirrorSedScript)")" + eval "sed -r -e \"$(getAttr versionReferenceCreator \ + 's/-([0-9.]+)[.]/-${version}./')\"" | + eval "sed -r -e \"$(getAttr mirrorSedScript)\"")" hash=$(nix-prefetch-url "$freshUrl") +baseName="$(getAttr baseName 'unnamed-package')" +name="$baseName-$version" + +advertisedUrl="$freshUrl" +url="$mirrorUrl" + +extraAssignments="" +for i in $(getAttr extraVars ''); do + eval "$(getAttr "eval_$i" 'i=""')" + extraAssignments="$extraAssignments $i=\"$(eval echo \"\$$i\")\";" +done + cat << EOF > "$new_src_file" rec { - advertisedUrl="$freshUrl"; + advertisedUrl="$advertisedUrl"; version = "$version"; - url="$mirrorUrl"; + url="$url"; hash = "$hash"; + name = "$name"; + $extraAssignments } EOF diff --git a/pkgs/development/libraries/geoip/default.nix b/pkgs/development/libraries/geoip/default.nix new file mode 100644 index 00000000000..86982025416 --- /dev/null +++ b/pkgs/development/libraries/geoip/default.nix @@ -0,0 +1,25 @@ +a : +let + s = import ./src-for-default.nix; + buildInputs = with a; [ + zlib + ]; +in +rec { + src = a.fetchUrlFromSrcInfo s; + + inherit (s) name; + inherit buildInputs; + configureFlags = []; + + /* doConfigure should be removed if not needed */ + phaseNames = ["doConfigure" "doMakeInstall"]; + goSrcDir = "cd GeoIP-*/"; + + meta = { + description = "Geolocation API"; + maintainers = [ + a.lib.maintainers.raskin + ]; + }; +} diff --git a/pkgs/development/libraries/geoip/src-for-default.nix b/pkgs/development/libraries/geoip/src-for-default.nix new file mode 100644 index 00000000000..cb9a5e758fc --- /dev/null +++ b/pkgs/development/libraries/geoip/src-for-default.nix @@ -0,0 +1,8 @@ +rec { + advertisedUrl="http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.6.tar.gz"; + version = "1.4.6"; + url="http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.6.tar.gz"; + hash = "1i4ixj6ha62qqzsn23qg428cv1zjj2ip7kmas62xgivvgm02kd0n"; + name = "geoip-1.4.6"; + +} diff --git a/pkgs/development/libraries/geoip/src-info-for-default.nix b/pkgs/development/libraries/geoip/src-info-for-default.nix new file mode 100644 index 00000000000..99c79227c63 --- /dev/null +++ b/pkgs/development/libraries/geoip/src-info-for-default.nix @@ -0,0 +1,6 @@ +{ + downloadPage = "http://geolite.maxmind.com/download/geoip/api/c/"; + sourceRegexp = "GeoIP-[0-9.]+[.]tar[.]gz"; + choiceCommand = "tail -1"; + baseName = "geoip"; +} diff --git a/pkgs/tools/admin/webdruid/default.nix b/pkgs/tools/admin/webdruid/default.nix new file mode 100644 index 00000000000..d1b3bd009ce --- /dev/null +++ b/pkgs/tools/admin/webdruid/default.nix @@ -0,0 +1,30 @@ +a : +let + s = import ./src-for-default.nix; + buildInputs = with a; [ + zlib libpng freetype gd which libxml2 + geoip + ]; +in +rec { + src = a.fetchUrlFromSrcInfo s; + + inherit (s) name; + inherit buildInputs; + configureFlags = []; + + /* doConfigure should be removed if not needed */ + phaseNames = ["doConfigure" "doMakeInstall" "doLinks"]; + + doLinks = a.fullDepEntry ('' + ln -s shared_en.xsl $out/share/webdruid/classic/shared.xsl + '') ["minInit"]; + + meta = { + description = "A web log analyzer"; + maintainers = [ + a.lib.maintainers.raskin + ]; + platforms = a.lib.platforms.all; + }; +} diff --git a/pkgs/tools/admin/webdruid/src-for-default.nix b/pkgs/tools/admin/webdruid/src-for-default.nix new file mode 100644 index 00000000000..edc770a5fbb --- /dev/null +++ b/pkgs/tools/admin/webdruid/src-for-default.nix @@ -0,0 +1,8 @@ +rec { + advertisedUrl="http://downloads.sourceforge.net/webdruid/files/webdruid/0.6.0-alpha5/webdruid-0.6.0-alpha5.tar.gz"; + version = "0.6.0-alpha5"; + url="http://downloads.sourceforge.net/webdruid/files/webdruid/${version}/webdruid-${version}.tar.gz"; + hash = "1aiqffccayvf02snl9la62zqb1674cp4rv19af6xyxgvw4334hw0"; + name = "webdruid-0.6.0-alpha5"; + +} diff --git a/pkgs/tools/admin/webdruid/src-info-for-default.nix b/pkgs/tools/admin/webdruid/src-info-for-default.nix new file mode 100644 index 00000000000..9a4eff29682 --- /dev/null +++ b/pkgs/tools/admin/webdruid/src-info-for-default.nix @@ -0,0 +1,7 @@ +{ + downloadPage = "http://sourceforge.net/projects/webdruid/files/"; + choiceCommand = ''head -1 | sed -re "$skipRedirectSF"''; + versionExtractorSedScript = ''$extractReleaseSF''; + versionReferenceCreator = ''s@$version@\''${version}@g''; + baseName = "webdruid"; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ee627cb81f5..3f857765753 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1516,6 +1516,11 @@ let inherit (gtkLibs) glib; }; + webdruid = builderDefsPackage ../tools/admin/webdruid { + inherit zlib libpng freetype gd which + libxml2 geoip; + }; + wget = import ../tools/networking/wget { inherit fetchurl stdenv gettext openssl; }; @@ -3097,6 +3102,10 @@ let inherit (gtkLibs) pango glib gtk; }; + geoip = builderDefsPackage ../development/libraries/geoip { + inherit zlib; + }; + geos = import ../development/libraries/geos { inherit fetchurl fetchsvn stdenv autoconf automake libtool swig which lib composableDerivation python ruby;