mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-24 15:01:56 +03:00
indexer: libraries-io: fix ordering of packages for hackage
This commit is contained in:
parent
ec2e3456f2
commit
9ea5cc8647
@ -6,12 +6,24 @@ out_file = sys.argv[1]
|
||||
platform = os.environ.get("platform")
|
||||
number = int(os.environ.get("number"))
|
||||
|
||||
if platform == "hackage":
|
||||
sort_key = lambda v: [int(n) for n in v['number'].split('.')]
|
||||
else:
|
||||
sort_key = key=lambda v: v['published_at']
|
||||
|
||||
input = json.load(sys.stdin)
|
||||
projects = []
|
||||
for package in input:
|
||||
versions = package['versions']
|
||||
versions = sorted(versions, key=sort_key, reverse=True)
|
||||
if versions:
|
||||
latest_version = package["latest_stable_release_number"]
|
||||
# latest_stable_release_number is often wrong for hackage
|
||||
if platform == "hackage":
|
||||
latest_version = versions[0]['number']
|
||||
else:
|
||||
latest_version = package["latest_stable_release_number"]
|
||||
if latest_version == None:
|
||||
latest_version = versions[0]['number']
|
||||
projects.append(dict(
|
||||
id=f"{package['name']}-{latest_version}",
|
||||
name=package['name'],
|
||||
|
@ -84,7 +84,9 @@ in {
|
||||
|
||||
# download and unpack package source
|
||||
mkdir source
|
||||
curl -L https://hackage.haskell.org/package/$name-$version/$name-$version.tar.gz > $TMPDIR/tarball
|
||||
url="https://hackage.haskell.org/package/$name-$version/$name-$version.tar.gz"
|
||||
echo "downloading $url"
|
||||
curl -L "$url" > $TMPDIR/tarball
|
||||
cd source
|
||||
cat $TMPDIR/tarball | tar xz --strip-components 1
|
||||
# trigger creation of `dist-newstyle` directory
|
||||
|
@ -102,8 +102,9 @@ in rec {
|
||||
])
|
||||
''
|
||||
set -e
|
||||
mkdir -p /tmp/flake
|
||||
cp -r ./* /tmp/flake
|
||||
rm -rf /tmp/.flake
|
||||
mkdir -p /tmp/.flake
|
||||
cp -r ./* /tmp/.flake
|
||||
set -x
|
||||
git fetch origin ${branchname} || :
|
||||
git checkout -f origin/${branchname} || :
|
||||
@ -111,7 +112,7 @@ in rec {
|
||||
git checkout -b ${branchname}
|
||||
# the flake should always be the one from the current main branch
|
||||
rm -rf ./*
|
||||
cp -r /tmp/flake/. ./
|
||||
cp -r /tmp/.flake/. ./
|
||||
${commands}
|
||||
git add .
|
||||
git commit -m "automatic update - $(date --rfc-3339=seconds)"
|
||||
|
Loading…
Reference in New Issue
Block a user