2015-01-19 17:13:18 +00:00
|
|
|
#!@bash@/bin/bash
|
|
|
|
|
|
|
|
@coreutils@/bin/mkdir tmp; cd tmp
|
|
|
|
|
|
|
|
@wget@/bin/wget -nH -r -c --no-parent $*
|
|
|
|
|
2015-06-15 16:50:39 +01:00
|
|
|
cat >../manifest.json <<EOF
|
2015-01-19 17:13:18 +00:00
|
|
|
[
|
|
|
|
EOF
|
|
|
|
|
|
|
|
workdir=$(pwd)
|
2015-06-15 16:50:39 +01:00
|
|
|
sep=""
|
2015-01-19 17:13:18 +00:00
|
|
|
|
|
|
|
@findutils@/bin/find . | while read path; do
|
|
|
|
if [[ -f "${path}" ]]; then
|
2015-06-15 16:50:39 +01:00
|
|
|
[[ -n "${sep}" ]] && echo "$sep" >>../manifest.json
|
2015-01-19 17:13:18 +00:00
|
|
|
url="${path:2}"
|
|
|
|
# Sanitize file name
|
2015-06-15 16:50:39 +01:00
|
|
|
filename=$(@coreutils@/bin/basename "${path}" | tr '@' '_')
|
|
|
|
nameversion="${filename%.tar.*}"
|
|
|
|
name="${nameversion%-*}"
|
2015-01-19 17:13:18 +00:00
|
|
|
dirname=$(@coreutils@/bin/dirname "${path}")
|
2015-06-15 16:50:39 +01:00
|
|
|
mv "${workdir}/${path}" "${workdir}/${dirname}/${filename}"
|
2015-01-19 17:13:18 +00:00
|
|
|
# Prefetch and hash source file
|
2015-06-15 16:50:39 +01:00
|
|
|
sha256=$(@nix@/bin/nix-prefetch-url "file://${workdir}/${dirname}/${filename}")
|
|
|
|
store=$(@nix@/bin/nix-store --print-fixed-path sha256 "$sha256" "$filename")
|
|
|
|
cat >>../manifest.json <<EOF
|
2015-01-19 17:13:18 +00:00
|
|
|
{
|
2015-06-15 16:50:39 +01:00
|
|
|
"name": "${nameversion}",
|
|
|
|
"store": "${store}",
|
|
|
|
"src": {
|
|
|
|
"url": "${url}",
|
|
|
|
"sha256": "${sha256}",
|
|
|
|
"name": "${filename}"
|
|
|
|
}
|
2015-01-19 17:13:18 +00:00
|
|
|
}
|
|
|
|
EOF
|
2015-06-15 16:50:39 +01:00
|
|
|
sep=","
|
2015-01-19 17:13:18 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2015-06-15 16:50:39 +01:00
|
|
|
echo "]" >>../manifest.json
|
2015-01-19 17:13:18 +00:00
|
|
|
|
|
|
|
cd ..
|