Added a generator for CPAN expressions. Expressions often require manual editing, but still something..

svn path=/nixpkgs/trunk/; revision=11947
This commit is contained in:
Michael Raskin 2008-06-02 08:21:38 +00:00
parent 8b83b37ec5
commit b98a144355
12 changed files with 196 additions and 0 deletions

View File

@ -0,0 +1,18 @@
#! /bin/sh
source lib-cache.sh;
print_reqs() {
module_name="$1";
./requirements.sh "$1"| while read; do
if let "$(./source-download-link.sh "${REPLY}" | wc -c)" && [ perl != "$REPLY" ]; then
echo "$REPLY";
fi;
done;
}
module_name="$1";
module_basename="${module_name//::/-}";
cached_output print_reqs "$module_basename" "$module_name" "pure.deps";

View File

@ -0,0 +1,21 @@
#! /bin/sh
source lib-cache.sh;
print_requirements () {
module_name="$1";
./requirements.sh "$module_name" | while read; do
echo "$REPLY";
print_reqs_cache "$REPLY";
done | sort | uniq
};
print_reqs_cache () {
module_name="$1";
module_basename="${module_name//::/-}";
cached_output print_requirements "$module_basename" "$module_name" "full.deps";
};
print_reqs_cache "$@";

View File

@ -0,0 +1,20 @@
#! /bin/sh
source lib-cache.sh
get_file() {
url="$1";
if [ -n "$url" ]; then
curl "$1";
else
echo -n;
fi;
}
url="$1";
name="$2";
name=${name:-$(basename "$url")}
cached_output get_file "${name%%.*}" "$url" "${name#*.}"

View File

@ -0,0 +1,19 @@
# First argument: command to run
# Second argument: cache name
# Third argument: argument to command
# Fourth argument: cache type
cached_output () {
cmd="$1";
basename="$2";
arg="$3";
ext="$4";
if ! [ -e "cache-${ext//./-}/${basename}.${ext}" ]; then
mkdir -p "cache-${ext//./-}";
$cmd $arg > "cache-${ext//./-}/${basename}.${ext}";
fi;
cat "cache-${ext//./-}/${basename}.${ext}";
}

View File

@ -0,0 +1,5 @@
#! /bin/sh
rm -rf test;
mkdir test;
for i in *.sh; do ln -s ../$i test; done;

View File

@ -0,0 +1,17 @@
#! /bin/sh
source lib-cache.sh;
module_name="$1";
module_basename="${1//::/-}";
print_requirements () {
module_name="$1";
./retrieve-meta-yaml.sh "$module_name" |
sed -re '1,/^requires:/d; /^[a-z]/,$d; s@^\s*@@; s@:\s.*@@';
./retrieve-meta-yaml.sh "$module_name" |
sed -re '1,/^build_requires:/d; /^[a-z]/,$d; s@^\s*@@; s@:\s.*@@';
};
cached_output print_requirements "$module_basename" "$module_name" "direct.deps";

View File

@ -0,0 +1,14 @@
#! /bin/sh
module_basename="$1";
file_name="$2";
version_regexp="${module_basename}(-[0-9.a-z]+){0,1}";
author_regexp="[A-Z0-9]+";
./retrieve-modulepage.sh "$module_basename" |
egrep "[<]a href=\"[a-z0-9/]*/(${author_regexp}/){0,1}${version_regexp}/${file_name}" |
sed -re "s@.*href=\"@@; s@\".*@@" |
sed -re 's@^/@http://search.cpan.org/@';
echo "$link_line";

View File

@ -0,0 +1,16 @@
#! /bin/sh
source lib-cache.sh;
print_meta_yaml () {
module_name="$1";
module_basename="${module_name//::/-}";
./grab-url.sh "$(./retrieve-file-link.sh "$module_basename" "META.yml")" \
"${module_basename}.meta.yml";
};
module_name="$1";
module_basename="${module_name//::/-}";
cached_output print_meta_yaml "$module_basename" "$module_name" meta.yaml;

View File

@ -0,0 +1,5 @@
#! /bin/sh
module_basename="$1";
./grab-url.sh "http://search.cpan.org/dist/$module_basename/" "$module_basename".html;

View File

@ -0,0 +1,17 @@
#! /bin/sh
source lib-cache.sh;
module_name="$1";
module_basename="${module_name//::/-}";
write_link() {
module_basename="$1";
./retrieve-modulepage.sh "$module_basename" |
grep -A 2 "This Release" |
grep href |
sed -re 's/.*href="//; s/".*//; s@^/@http://search.cpan.org/@';
}
cached_output write_link "$module_basename" "$module_basename" src.link;

View File

@ -0,0 +1,10 @@
/path/to/write-nix-expression.sh Group::Module::Submodule
It will output Nix assignment formatted for placing into
all-packages.nix amongst all the perl packages, like perlAlgorithmDiff.
Actually it will grab distribution unit Group-Module-Submodule via
search.cpan.org, and make some effort to write correct dependencies.
If among requirements there are some that have empty META.yml, or if
any of requirements acannot be installed by just getting distribution
unit whose name can be guessed by replacing :: with -, manual editing
will be needed.

View File

@ -0,0 +1,34 @@
#! /bin/sh
cd $(dirname $0);
source lib-cache.sh;
print_expression () {
module_name="$1";
module_basename="${module_name//::/-}";
module_compressedname="perl${module_name//::/}";
sourcelink="$(./source-download-link.sh "${module_name}")";
version_name="${sourcelink%.tar.*}";
version_name="${version_name##*/}";
dependencies="$(./filtered-requirements.sh "$module_name" | sed -e 's/^/perl/; s/:://g' | xargs)";
source_hash=$(nix-prefetch-url "$sourcelink" 2>/dev/null);
cat <<EOF
${module_compressedname} = import ../development/perl-modules/generic perl {
name = "${version_name}";
src = fetchurl {
url = ${sourcelink};
sha256 = "$source_hash";
};
propagatedBuildInputs = [${dependencies}];
};
EOF
};
module_name="$1";
module_basename="${module_name//::/-}";
cached_output print_expression "$module_basename" "$module_name" "nix";