indexer: libraries-io: fix ordering of packages for hackage

This commit is contained in:
DavHau 2022-10-07 18:49:35 +02:00
parent ec2e3456f2
commit 9ea5cc8647
3 changed files with 20 additions and 5 deletions

View File

@ -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'],

View File

@ -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

View File

@ -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)"