summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2020-06-17 17:57:04 -0400
committerJoey Hess2020-06-17 17:58:12 -0400
commit745784f61bdd678e20b1b18743f18d458836a802 (patch)
tree7a345c7c4bb7a7ead33c86d1dabe1f5840f11d1a
parent298f437253fd87a3f412ae875a56b7833da956e0 (diff)
Support bootstrapping to hosts using cabal 3.x, with new-dist directory.
* Support bootstrapping to hosts using cabal 3.x, with new-dist directory. * Makefile: Fix build with cabal 3.x. This assumes that, once a new-dist directory is created, the host won't revert back to using dist. So it always prefers binaries from new-dist over dist. This commit was sponsored by LND on Patreon.
-rw-r--r--.gitignore3
-rw-r--r--Makefile35
-rw-r--r--debian/changelog2
-rw-r--r--doc/forum/Bootstrapping_with_Cabal_on_Archlinux_fails/comment_4_294fcbae675879cb81aeb8d37cf3b635._comment13
-rw-r--r--src/Propellor/Bootstrap.hs7
5 files changed, 46 insertions, 14 deletions
diff --git a/.gitignore b/.gitignore
index d9285db3..4e1b918c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,8 @@
/propellor
dist/*
+dist-newstyle/*
tags
+configured
privdata/local
privdata/keyring.gpg~
Setup
@@ -15,4 +17,5 @@ propellor.1
.cabal-sandbox/
.dir-locals.el
cabal.sandbox.config
+cabal.project.local
*~
diff --git a/Makefile b/Makefile
index 0e4b2ca3..b5d5708b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,35 +1,43 @@
CABAL?=cabal
DATE := $(shell dpkg-parsechangelog 2>/dev/null | grep Date | cut -d " " -f2-)
-build: tags propellor.1 dist/setup-config
+build: tags propellor.1 configured
$(CABAL) build
- ln -sf dist/build/propellor-config/propellor-config propellor
+ @if [ -d dist-newstyle ]; then \
+ ln -sf $$(find dist-newstyle/ -executable -type f | grep 'build/propellor-config/propellor-config$$') propellor; \
+ else \
+ ln -sf dist/build/propellor-config/propellor-config propellor; \
+ fi
install:
install -d $(DESTDIR)/usr/bin $(DESTDIR)/usr/src/propellor
- install -s dist/build/propellor/propellor $(DESTDIR)/usr/bin/propellor
- mkdir -p dist/gittmp
- $(CABAL) sdist
- cat dist/propellor-*.tar.gz | (cd dist/gittmp && tar zx --strip-components=1)
+ if [ -d dist-newstyle ]; then \
+ install -s $$(find dist-newstyle/ -executable -type f | grep 'build/propellor/propellor$$') $(DESTDIR)/usr/bin/propellor; \
+ else \
+ install -s dist/build/propellor/propellor $(DESTDIR)/usr/bin/propellor; \
+ fi
+ mkdir -p gittmp
+ $(CABAL) sdist -o - | (cd gittmp && tar zx --strip-components=1)
# cabal sdist does not preserve symlinks, so copy over file
- cd dist/gittmp && for f in $$(find -type f); do rm -f $$f; cp -a ../../$$f $$f; done
+ cd gittmp && for f in $$(find -type f); do rm -f $$f; cp -a ../$$f $$f; done
# reset mtime on files in git bundle so bundle is reproducible
- find dist/gittmp -print0 | xargs -0r touch --no-dereference --date="$(DATE)"
+ find gittmp -print0 | xargs -0r touch --no-dereference --date="$(DATE)"
export GIT_AUTHOR_NAME=build \
&& export GIT_AUTHOR_EMAIL=build@buildhost \
&& export GIT_AUTHOR_DATE="$(DATE)" \
&& export GIT_COMMITTER_NAME=build \
&& export GIT_COMMITTER_EMAIL=build@buildhost \
&& export GIT_COMMITTER_DATE="$(DATE)" \
- && cd dist/gittmp && git init \
+ && cd gittmp && git init \
&& git add . \
&& git commit -q -m "distributed version of propellor" \
&& git bundle create $(DESTDIR)/usr/src/propellor/propellor.git master HEAD \
&& git show-ref master --hash > $(DESTDIR)/usr/src/propellor/head
- rm -rf dist/gittmp
+ rm -rf gittmp
clean:
- rm -rf dist Setup tags propellor propellor.1 privdata/local
+ rm -rf dist dist-newstyle configured Setup \
+ tags propellor propellor.1 privdata/local
find . -name \*.o -exec rm {} \;
find . -name \*.hi -exec rm {} \;
@@ -37,11 +45,12 @@ clean:
# duplicate tags with Propellor.Property. removed from the start, as we
# often import qualified by just the module base name.
tags:
- find . | grep -v /.git/ | grep -v /tmp/ | grep -v /dist/ | grep -v /doc/ | egrep '\.hs$$' | xargs hothasktags 2>/dev/null | perl -ne 'print; s/Propellor\.Property\.//; print' | sort > tags || true
+ @find . | grep -v /.git/ | grep -v /tmp/ | grep -v dist/ | grep -v /doc/ | egrep '\.hs$$' | xargs hothasktags 2>/dev/null | perl -ne 'print; s/Propellor\.Property\.//; print' | sort > tags || true
-dist/setup-config: propellor.cabal
+configured: propellor.cabal
@if [ "$(CABAL)" = ./Setup ]; then ghc --make Setup; fi
@$(CABAL) configure
+ touch configured
propellor.1: doc/usage.mdwn doc/mdwn2man
doc/mdwn2man propellor 1 < doc/usage.mdwn > propellor.1
diff --git a/debian/changelog b/debian/changelog
index b46c4b4e..24bbf641 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,8 @@ propellor (5.10.3) UNRELEASED; urgency=medium
* Fix display of concurrent output from processes when using
Propellor.Property.Conductor.
(Reversion introduced in version 5.5.0.)
+ * Support bootstrapping to hosts using cabal 3.x, with new-dist directory.
+ * Makefile: Fix build with cabal 3.x.
-- Joey Hess <id@joeyh.name> Fri, 05 Jun 2020 11:26:21 -0400
diff --git a/doc/forum/Bootstrapping_with_Cabal_on_Archlinux_fails/comment_4_294fcbae675879cb81aeb8d37cf3b635._comment b/doc/forum/Bootstrapping_with_Cabal_on_Archlinux_fails/comment_4_294fcbae675879cb81aeb8d37cf3b635._comment
new file mode 100644
index 00000000..726067da
--- /dev/null
+++ b/doc/forum/Bootstrapping_with_Cabal_on_Archlinux_fails/comment_4_294fcbae675879cb81aeb8d37cf3b635._comment
@@ -0,0 +1,13 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 4"""
+ date="2020-06-17T21:33:14Z"
+ content="""
+ cabal install --install-method=symlink --installdir=. exe:propellor --overwrite-policy=always
+
+But, this seems to do a lot of extra work, including generating a tarball
+of all the source code, and possibly building the package again
+unncessarily. And only works with a new enough cabal version.
+
+Ok, I've implemented it using `find`.
+"""]]
diff --git a/src/Propellor/Bootstrap.hs b/src/Propellor/Bootstrap.hs
index d772d7c7..0fef92f1 100644
--- a/src/Propellor/Bootstrap.hs
+++ b/src/Propellor/Bootstrap.hs
@@ -81,7 +81,12 @@ buildCommand bs = intercalate " && " (go (getBuilder bs))
go Cabal =
[ "cabal configure"
, "cabal build -j1 propellor-config"
- , "ln -sf dist/build/propellor-config/propellor-config propellor"
+ , intercalate "; "
+ [ "if [ -d dist-newstyle ]"
+ , "then ln -sf $(find dist-newstyle/ -executable -type f | grep 'build/propellor-config/propellor-config$') propellor"
+ , "else ln -sf dist/build/propellor-config/propellor-config propellor"
+ , "fi"
+ ]
]
go Stack =
[ "stack build :propellor-config"