Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Commit

Permalink
add hashes to cabal.project
Browse files Browse the repository at this point in the history
  • Loading branch information
angerman committed Jan 16, 2020
1 parent 72d1776 commit a502231
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
30 changes: 30 additions & 0 deletions cabal.project
Expand Up @@ -78,6 +78,7 @@ source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-crypto
tag: 4590efa638397e952a51a8994b5543e4ea3c1ecd
--sha256: 0hl2n3bba5v2j0lmxhs7hs01z3aznh2bwf9cb434icq2g0bl8ms3

source-repository-package
type: git
Expand All @@ -89,169 +90,198 @@ source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-prelude
tag: 00487726c4bc21b4744e59d913334ebfeac7d68e
--sha256: 0v4fcq5kdd2r5dgwys8kv46ff33qp756n26ycxrca10wq14zkwm5

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-prelude
tag: 00487726c4bc21b4744e59d913334ebfeac7d68e
subdir: test
--sha256: 0v4fcq5kdd2r5dgwys8kv46ff33qp756n26ycxrca10wq14zkwm5

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-sl-x509
tag: 43a036c5bbe68ca2e9cbe611eab7982e2348fe49
--sha256: 1aw7ns8lv51fjf45k8yzils2j7a6bqzy8hn65kb3z0dn1qsm8x88

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: d5eb7ee92f0974aed5ac4a57a9bf5697ec065b7d
subdir: contra-tracer
--sha256: 1gj72biavm3lv1d891bvy4q03ys4vhs0i5b22kcqfxpp7zgzkp70

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: d5eb7ee92f0974aed5ac4a57a9bf5697ec065b7d
subdir: iohk-monitoring
--sha256: 1gj72biavm3lv1d891bvy4q03ys4vhs0i5b22kcqfxpp7zgzkp70

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: d5eb7ee92f0974aed5ac4a57a9bf5697ec065b7d
subdir: plugins/backend-aggregation
--sha256: 1gj72biavm3lv1d891bvy4q03ys4vhs0i5b22kcqfxpp7zgzkp70

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: d5eb7ee92f0974aed5ac4a57a9bf5697ec065b7d
subdir: plugins/backend-editor
--sha256: 1gj72biavm3lv1d891bvy4q03ys4vhs0i5b22kcqfxpp7zgzkp70

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: d5eb7ee92f0974aed5ac4a57a9bf5697ec065b7d
subdir: plugins/backend-ekg
--sha256: 1gj72biavm3lv1d891bvy4q03ys4vhs0i5b22kcqfxpp7zgzkp70

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: d5eb7ee92f0974aed5ac4a57a9bf5697ec065b7d
subdir: plugins/backend-monitoring
--sha256: 1gj72biavm3lv1d891bvy4q03ys4vhs0i5b22kcqfxpp7zgzkp70

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: d5eb7ee92f0974aed5ac4a57a9bf5697ec065b7d
subdir: plugins/scribe-systemd
--sha256: 1gj72biavm3lv1d891bvy4q03ys4vhs0i5b22kcqfxpp7zgzkp70

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: d5eb7ee92f0974aed5ac4a57a9bf5697ec065b7d
subdir: tracer-transformers
--sha256: 1gj72biavm3lv1d891bvy4q03ys4vhs0i5b22kcqfxpp7zgzkp70

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-base
tag: 53d773907edea2fdcf65cebeb81ab5e47eeab805
subdir: binary
--sha256: 1x3jacfggim9ynnw8rzaswhbvmhk13hid44k91a8137fv0jg6l14

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-base
tag: 53d773907edea2fdcf65cebeb81ab5e47eeab805
subdir: binary/test
--sha256: 1x3jacfggim9ynnw8rzaswhbvmhk13hid44k91a8137fv0jg6l14

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-base
tag: 53d773907edea2fdcf65cebeb81ab5e47eeab805
subdir: cardano-crypto-class
--sha256: 1x3jacfggim9ynnw8rzaswhbvmhk13hid44k91a8137fv0jg6l14

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-base
tag: 53d773907edea2fdcf65cebeb81ab5e47eeab805
subdir: slotting
--sha256: 1x3jacfggim9ynnw8rzaswhbvmhk13hid44k91a8137fv0jg6l14

source-repository-package
type: git
location: https://github.com/input-output-hk/goblins
tag: 26d35ad52fe9ade3391532dbfeb2f416f07650bc
--sha256: 17p5x0hj6c67jkdqx0cysqlwq2zs2l87azihn1alzajy9ak6ii0b

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: bcba1d2d10004f1ce14c5c53478f656deffd4c38
subdir: byron/semantics/executable-spec
--sha256: 0xn1x9dp52frd18jg9i4hvkgaffx3hr64ny87mvmsgg2xbq41a5v

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: bcba1d2d10004f1ce14c5c53478f656deffd4c38
subdir: byron/ledger/executable-spec
--sha256: 0xn1x9dp52frd18jg9i4hvkgaffx3hr64ny87mvmsgg2xbq41a5v

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: bcba1d2d10004f1ce14c5c53478f656deffd4c38
subdir: byron/chain/executable-spec
--sha256: 0xn1x9dp52frd18jg9i4hvkgaffx3hr64ny87mvmsgg2xbq41a5v

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger
tag: d1b4f6520692d7478d81b050385e0a9b71a0c62b
subdir: cardano-ledger
--sha256: 10dv4zfrih2f6ymmgb6w0kaj6iw4kz79bps193v2f3md10wzgn4r

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger
tag: d1b4f6520692d7478d81b050385e0a9b71a0c62b
subdir: cardano-ledger/test
--sha256: 10dv4zfrih2f6ymmgb6w0kaj6iw4kz79bps193v2f3md10wzgn4r

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger
tag: d1b4f6520692d7478d81b050385e0a9b71a0c62b
subdir: crypto
--sha256: 10dv4zfrih2f6ymmgb6w0kaj6iw4kz79bps193v2f3md10wzgn4r

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger
tag: d1b4f6520692d7478d81b050385e0a9b71a0c62b
subdir: crypto/test
--sha256: 10dv4zfrih2f6ymmgb6w0kaj6iw4kz79bps193v2f3md10wzgn4r

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: e0eba52e8e7c81d3f002c8d36a3e5f6ed30bb216
subdir: io-sim-classes
--sha256: 1qrqssix3iwcc7hjy36riapqvaijps6nba0a8hzn2dms37sspf9a

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: e0eba52e8e7c81d3f002c8d36a3e5f6ed30bb216
subdir: network-mux
--sha256: 1qrqssix3iwcc7hjy36riapqvaijps6nba0a8hzn2dms37sspf9a

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: e0eba52e8e7c81d3f002c8d36a3e5f6ed30bb216
subdir: ouroboros-network
--sha256: 1qrqssix3iwcc7hjy36riapqvaijps6nba0a8hzn2dms37sspf9a

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: e0eba52e8e7c81d3f002c8d36a3e5f6ed30bb216
subdir: ouroboros-consensus
--sha256: 1qrqssix3iwcc7hjy36riapqvaijps6nba0a8hzn2dms37sspf9a

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: e0eba52e8e7c81d3f002c8d36a3e5f6ed30bb216
subdir: typed-protocols
--sha256: 1qrqssix3iwcc7hjy36riapqvaijps6nba0a8hzn2dms37sspf9a

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: e0eba52e8e7c81d3f002c8d36a3e5f6ed30bb216
subdir: typed-protocols-cbor
--sha256: 1qrqssix3iwcc7hjy36riapqvaijps6nba0a8hzn2dms37sspf9a
42 changes: 42 additions & 0 deletions update-cabal-project.py
@@ -0,0 +1,42 @@
import re
import subprocess
import json

buffer = open("cabal.project").read()

# match looks like this:

# source-repository-package
# type: git
# location: https://github.com/input-output-hk/iohk-monitoring-framework
# tag: d5eb7ee92f0974aed5ac4a57a9bf5697ec065b7d
# subdir: iohk-monitoring

# subdir is optional, so is a --sha256 comment

pattern = r'source-repository-package.*\n' \
+ r'(?P<pad> .*)type: git.*\n' \
+ r'\1location: (?P<loc>[^ \n]+).*\n' \
+ r'\1tag: (?P<tag>[^ \n]+).*\n' \
+ r'(?P<subdir>\1subdir: [^ \n]+\n){0,1}' \
+ r'(\1--sha256:.*\n){0,1}'
# ( .*--sha256:.*\n){0,1}"""

def repl(match):
dict = match.groupdict()
if not dict["subdir"]:
dict["subdir"] = ''
prefetchJSON = subprocess.run(
["nix-prefetch-git", "--quiet", dict['loc'], dict['tag']],
capture_output=True, check=True).stdout
sha256 = json.loads(prefetchJSON)["sha256"]
return """source-repository-package
{pad}type: git
{pad}location: {loc}
{pad}tag: {tag}
{subdir}{pad}--sha256: {sha256}
""".format(**{**dict, **{"sha256": sha256}})

f = open("cabal.project",'w')
f.write(re.sub(pattern, repl, buffer, flags = re.I + re.M))
f.close()

0 comments on commit a502231

Please sign in to comment.