diff --git a/ChangeLog b/ChangeLog
deleted file mode 100644
--- a/ChangeLog
+++ /dev/null
@@ -1,586 +0,0 @@
-# 2.2.0 (2024-03-27)
-- Dependencies excludedPkgs: add system-cxx-std-lib
-- Dependencies: withGhcProfLibType to respect %with_ghc_prof for builddeps
-- PackageUtils dependencySortCabals: do nothing if empty
-- Snapshots: update stackage snapshots.json url
-- Spec: usesOptparse, maybeGenerateBashCompletion, maybeGenerateManpage
-- spec: add %{?haskell_setup}
-- spec: define and use %ghc_major for --with-compiler
-- spec: do not BR ghcX.Y-prof for standalone
-
-# 2.1.5 (2023-11-10)
-- bugfix: --flags should be optional!
-- PackageUtils pkgSpecPkgData: error displaying an unparsable pkgid
-
-# 2.1.4 (2023-11-03)
-- spec --standalone should not create subpkgs (regression in 2.1.3)
-- spec: when subpackaging include prof for main exec deps
-- fix --flags parsing to actually work!
-- PackageUtils bringTarball: create SOURCES/ earlier for new user
-
-# 2.1.3 (2023-09-27)
-- spec: implement recursive missing deps fully; use cabal-sort if available
-- spec: also get the license of subpkgs now
-- spec: optparse-simple also supports bash completions
-- spec: simplify standalone %ghc_set_gcc_flags conditional
-- Stackage: prefer stack list if available: should be faster
-- Stackage: cache latest snapshots versions with code from stack-all
-- update: be more careful about adding new revised .cabal
-
-# 2.1.2 (2023-07-27, F39)
-- PackageUtils checkForPkgCabalFile: check within BUILD dir
-- PackageUtils patchSpec: drop problem code for showing patch -.rej
-- Stackage: bump default to lts-21
-- allow Cabal-3.10
-- https for COPYING urls
-- spec: add %autopatch if Patch's and no %patch
-- spec: exclude missing deps from missing testsuite deps
-- spec: revert from %autosetup to %setup
-- spec: standalone should not use prof
-- update: --old-stream option for subpackages
-- update: invert gitBool check for local changes
-- update: use wasrevised to control revision of old reference spec
-
-# 2.1.1 (2023-03-27)
-- spec: use %autosetup
-- PackageUtils patchSpec: adding newline to stdin hangs patch
-
-# 2.1.0 (2023-02-15)
-- spec: list out ghc-*-prof BRs separately from ghc-*-devel
-- spec: output SPDX license tags
-- spec: for standalone f36+ cabal-install needs %ghc_set_gcc_flags
-- spec: handle '.' paragraph separator lines in description
-- spec: initial support for --with-ghc version to build with ghcX.Y
-- spec: check if deps of missing deps available
-- spec: for --standalone define %cabal_install for cabal
-- Stackage: default to latest lts-20 stream
-- refresh: build cabal-rpm in tempdir
-- PackageUtils rpmbuild: no longer override _builddir, _rpmdir, _srcrpmdir
-- PackageUtils tryUnpack: now into %_builddir
-- PackageUtils patchSpec: show .rej if patch fails
-- PackageUtils: handle tools like ghc-tags which are not a library
-- always assume revised .cabal is wanted/used
-- remove all the keep logic for tmpdir processing
-- allow Cabal-3.8
-- GH action: add 9.4 and bump actions versions
-- Diff: use extra withTempDir
-- simplify withTempDirectory with withCurrentDirectory
-
-# 2.0.11.1 (2022-03-28)
-- support building with Cabal 3.6
-
-# 2.0.11 (2022-03-13)
-- take build-tool-depends into account
-- 'spec','update': detect %autorelease and preserve %autochangelog
-- 'spec --standalone': strip executable
-- support %_builddir
-
-# 2.0.10 (2021-08-14)
-- pkgSpecPkgData: try allowing versioned dir
-- update: only output old version if upgrading
-- stack: use final lts17
-- Stackage: bump to LTS 18
-- Spec: drop %ghc_fix_rpath for subpkgs
-
-# 2.0.9 (2021-06-08)
-- spec: doc requires ghc-filesystem
-- spec: make %cabal_test conditional explicit
-- refresh: fix installation of cabal-rpm-version with cabal install
-- spec: tweak conditions for standalone sandbox (ie rhel8)
-
-# 2.0.8 (2021-03-27)
-- update: make sure krb ticket exists before uploading source
-- spec: executable doc files now handled by ghc-rpm-macros
-- move dos2unix for revised DOS .cabal from download to spec build time
-- spec: do not enable testsuite for standalone package
-- spec: also bash-completion for simple-cmd-args
-- spec: for bash-completions use default not filenames
-- Stackage: use lts-17
-- pkgInstallMissing: also install ghc-rpm-macros
-
-# 2.0.7 (2020-10-07)
-- spec: setup bash completions for optparse-applicative
-- spec: --ignore-missing to ignore deps not yet in hackage
-- update: only commit revised if actual changes
-- show rpmbuild mode
-- spec --standalone updated for cabal-install 3 (f33+)
-
-# 2.0.6 (2020-06-28) Fedora 33
-- spec: use packager's name in %changelog
-- spec: default package versions to Stackage LTS 16
-- spec now also leaves newly prepped source tree around
-- spec: handle testsuite tool deps separately
-- spec, refresh, update: more care about whether to revise or not
-- diff: ignore release field
-- prep: be quiet
-- spec: add a comment for missing testsuite deps
-- only allow specifying major Stackage LTS versions (not minor):
-  for more progressive updating logic (lts-n -> lts-(n+1) -> nightly -> Hackage)
-- spec: don't warn "spec exists" explicitly
-- spec: take specified stream into account for subpackaging
-- update: finally run prep to check update okay
-- prep/srpm --verbose and local --quiet options
-- spec: move chmod for docs to %prep
-- spec: check existing .spec file for detecting dropped deps and executable deps
-- update: also commit revised .cabal file when no update
-- fix copying of cached tarballs (longstanding defect)
-
-# 2.0.5.1 (2020-06-11)
-- spec: fix grep breakage in 2.0.5 release
-- refresh and update now leave newly prepped source tree around
-- spec: dropped deprecated %post and %postun scriptlets
-
-# 2.0.5 (2020-06-10)
-- spec --tests flag to force enabling testsuite
-- spec: fix permissions of extra-source-files
-- update url for Fedora Haskell Packaging Guidelines (TristanCacqueray)
-- make cabal update silent and check for 01-index
-- support Cabal-3.2 ShortText (hekkaidekapus)
-- use simple-cmd-args 0.1.6 for working subcommand help
-- improve handling of update --stream for subpackaging
-- bump latest Stackage to LTS 15
-- spec: exclude deps dropped with cabal-tweak-drop-dep
-
-# 2.0.4 (2020-02-27) Fedora 32
-- update: also unbreak patching
-
-# 2.0.3 (2020-02-24)
-- refresh: unbreak to patch spec file
-- spec: detect local revised .cabal file
-
-# 2.0.2 (2020-02-20)
-- drop %_devel compat macro
-- default stream is now lts-14
-- sort deps of subpackages
-- metapkgs don't have prof or doc
-- fix generation of subpackages for a new package
-- update: logic reworked to reduce redundant downloads
-
-# 2.0.1 (2020-02-06)
-- quote macros in commented fields
-- read --subpackage from spec header
-- generate BRs for subpackages
-
-# 2.0.0 (2020-01-16)
-- major refactor to handle stream/pkgid more precisely and correctly
-  (hence major version bump due to behavior changes)
-  - eg can no longer specify both stream and pkg-ver
-- check for package first in default LTS, then latest LTS, and Nightly,
-  before Hackage
-- respect and read/write --standalone and --stream in spec header consistently
-  (note default LTS stream is not written to header)
-- fix infinite loop for 'install'
-- optionally use libcurl binding instead of former stackage-query fallback
-
-# 1.0.3 (2019-12-31)
-- define %_devel for f30 packaging compatibility
-- missingdeps and builddep fixes
-- --standalone: add BRs for deps of missing deps
-
-# 1.0.2 (2019-12-09)
-- allow newer time for ghc-8.8
-- more type refactoring: PackageIdentifier, LibPkgType, RpmPackage
-  and some associated bugfixes
-
-# 1.0.1 (2019-09-29)
-- doc and prof subpackages for libraries
-- reworked to use optparse-applicative (simple-cmd-args)
-- default to Stackage LTS 13
-- F31+ uses triggers for ghc-pkg recache
-- wait 10^4s (< 3 hours) between cabal update's
-- refactor using simple-cabal, PackageName and LibPkgType
-- handle setup-depends
-- diff: autodetect subpackaging
-- diff (experimental): trim %changelog with bawolk/hsp if available
-- drop pre-built manpage: use Makefile to build it
-
-# 0.13.3 (2019-05-10)
-- default stream to lts-12
-- repoquery for missing deps' package .conf file to avoid modular ghc conflicts
-- only --assumeyes for dnf install when not tty
-- give up if more than one spec file
-- fix handling unversioned update
-- map cabal build-tool to cabal-install
-- use tmpdir for tmp spec files and building missing deps
-- finalPackageDescription for debugging Cabal
-- use simple-cmd-0.1.3.1 for sudo fixes
-
-# 0.13.2 (2019-04-09)
-- include ANNOUNCE in docs
-- if dependency parallel directory exists, don't check if installed
-- fix buildDepends on Cabal-2.4
-- new --standalone option for private packages built with cabal-install
-- print --{missing,standalone,subpackage} options on spec file header line
-
-# 0.13.1 (2019-02-27)
-- update: fix rw git dir detection
-- fix tarball downloading and copying of revised .cabal file
-- show output (errors) when prepping source and prep in working dir
-- include BUGS and CONTRIBUTING as docs
-- need chrpath for subpackages
-- move license dir to any common subpackage
-
-# 0.13 (2019-02-18)
-- improve license and doc filtering
-- backup revised .cabal files
-- fallback to spectool for source downloading
-- drop selfdep
-- common subpackage for binlib data files
-- section dividers for sources, setup, build, install, and files
-- only run "cabal update" if more than 10min old
-- drop support for ghc-7.4.2
-
-# 0.12.6 (2018-10-20)
-- update: remove old revised .cabal
-- convert revised .cabal file to unix format
-- spec: support haskell-gi libraries
-- most of SysCmd moved to simple-cmd library (new dep)
-- can now download multiple source files
-- use line-buffering for stdout
-- always do cabal update
-- support ghc_without_dynamic for static executables
-- build with Cabal-2.4 (ghc-8.6)
-
-# 0.12.5 (2018-07-29)
-- update: more careful now with fuzz 1
--- handle revised to non-revised
--- improved for subpackaging
-- improvements to revising of .cabal files
--- place after any subpackages
--- use revision when prep'ing and building
-- use "fedpkg sources" to fetch current Fedora sources
-- refresh: handle subpackages
-- missing: better output for missing sub-deps
-- do not put doc* in docs
-
-# 0.12.4 (2018-05-31)
-- now uses Hackage revisions of packages (using wget)
-- spec --stream STREAM replaces --hackage
-- disable https for ghc < 7.10
-
-# 0.12.3 (2018-05-14)
-- build: remove erroneous tarball check
-- refresh: use cblrpm for old cabal-rpm
-
-# 0.12.2 (2018-03-29)
-- diff now supports CBLRPM_DIFF envvar to override "diff -u"
-- try to build even when missing rpms deps not available
-- package now builds with Cabal-2.2
-
-# 0.12.1 (2018-02-20)
-- new option --missing: comments out missing dependencies
-- put license files in lib subpackage
-- no longer append %_isa to C BuildRequires (#54)
-- no longer leave leftover tmpdirs (#26)
-- change 'cblrpm' to 'cabal-rpm' in documentation
-- drop support for SCM snapshot releases
-
-# 0.12 (2017-11-17)
-- default to querying stackage.org directly via https
-- fix stackage-query usage and suggest installing if missing
-- run cabal update before cabal commands
-- devel packages now provide doc subpackage for forward compatibility
-- new --hackage option to get package version from Hackage not Stackage
-- do not add .cabal files containing "doc" to docs
-- silence mock rpmbuild -bs warnings about undefined %ghc_version
-- allow building with ghc-8.2 and Cabal-2.0
-
-# 0.11.2 (2017-07-31)
-- fix cabal-rpm update --subpackage
-- fix rpm installation when no sudo (#49)
-- fix handling of no exposed modules (#50)
-- fix license handling for selfdep binlib (#51)
-
-# 0.11.1 (2017-03-13)
-- support building meta (compat) packages
-- invocation of optional stackage-query to update to LTS now works
-- initial --subpackage support for %{subpkgs} of missing deps:
-  including downloading, but update is not properly implemented yet
-- new %{pkgver} macro
-- (+-+) absorbs extra space
-- update no longer resets release for %{subpkgs}
-
-# 0.11 (2017-01-27)
-- refresh command now reads the cabal-rpm version header in the spec file and
-  installs that version of cabal-rpm under ~/.cblrpm/ and uses it to make patch
-- diff and update now follow package-version args
-- update tries to use stackage-query to check latest Stackage version
-  before falling back to latest Hackage
-- update from Hackage now follows "Default available version"
-- sync some changes from opensuse-haskell/cabal-rpm
-- rename Setup to Options
-- silence <$> import warnings
-
-# 0.10.1 (2016-11-29)
-- no longer need to remove License file by hand
-- use new %ghc_fix_rpath
-- include Contributors in docs
-- warn about duplicate docs in datadir and remove them
-
-# 0.10.0 (2016-07-27)
-- rename executable and manpage back to 'cabal-rpm': more predictable
-- explicit error for unknown command
-- sort docs and include upstream changelogs and news
-- add cabal-rpm version header line to spec files
-- new highly experimental command to refresh spec files
-- only add "ExclusiveArch: %{ghc_arches_with_ghci}" for RHEL/EPEL
-- use revised Hackage .cabal files on SUSE (@peti)
-- on SUSE add explicit requires for pkgconfig
-- new --compiler option (@peti)
-- new --distro option (@peti)
-- new --strict option which fails when unresolved cdeps (@peti),
-  otherwise a warning is output
-- update now shows diff
-- use %cabal_test (@mimi1vx)
-- no longer duplicate docs in datadir
-- package datadir better
-- for SUSE libs executables now go in the base package
-
-# 0.9.11 (2016-05-06)
-- build with Cabal-1.24
-
-# 0.9.10 (2016-03-24)
-- bugfixes
-  - update no longer tries to grep non-existent .git
-  - fix duplicate clibs
-- fix build with ghc-8.0 (Cabal-1.23 and time-1.6)
-- SuSE improvements: no disttag or rpmdev-bumpspec
-
-# 0.9.9 (2016-01-25)
-- couple of minor improvements for SUSE packaging
-
-# 0.9.8 (2015-10-08)
-- better %license logic
-- fix handling of versions without '.'
-- no duplicate test deps
-
-# 0.9.7 (2015-08-28)
-- only list buildable executables in spec file
-- bring back 'build' as an alias for 'local'
-- use %license macro
-- do not warn about missing optional system programs
-
-# 0.9.6 (2015-05-21)
-- make "cabal list" quiet
-- filter missing packages from repoquery
-
-# 0.9.5.1 (2015-05-01)
-- add old-locale Cabal flag to fix build on ghc-7.10
-
-# 0.9.5 (2015-04-20)
-- fix for dnf repoquery
-- create SOURCES/ for tarball
-- fixes for Cabal-1.22
-- nogpgcheck for Fedora 22+
-- warn about hidden backup spec files
-
-# 0.9.4 (2015-02-17)
-- use dnf if installed instead of yum for install and repoquery
-- update now only commits changes and new source if git origin is ssh
-- allow Cabal-1.22
-
-# 0.9.3 (2015-02-05)
-- make sure tarball destdir exists before copying
-- improve output for listing missing packages
-- update improvements: new-sources first, continue if patch fails, git commit changes
-- spec: sort executables and use %pkg_name in %ghc_fix_dynamic_rpath
-- drop the debuginfo handling for C files
-- ignore emacs temp ".#pkgname.spec" files
-
-# 0.9.2 (2014-12-18)
-- lots of bug fixes
-- improved missingdeps output
-- use https for hackage URLs (codeblock)
-- no longer override %_sourcedir, %_rpmdir, and %_srcrpmdir, unless git dir
-- new "update" command to update spec to latest version
-- use 'rpm --eval "%{?dist}"' to determine OS type
-- fix build and warnings for Cabal 1.20
-- use TMPDIR
-
-# 0.9.1 (2014-08-26)
-- missingdeps now lists missing dependencies recursively and outputs Hackage
-  package names rather than ghc-*-devel package names
-- do not assume package order when testing if dependencies installed
-- check  ~/.cabal/packages/ exists before looking for tarballs
-- pass actual exeNames to %ghc_fix_dynamic_rpath
-
-# 0.9 (2014-07-17)
-- reworked initial logic to make better use of existing spec files,
-  and prep source tree properly
-- default to Library packaging instead of BinLib:
-  override with --binary which replaces --library
-- prep src for version in existing spec file when building
-- 'install' command now does local recursive rpmbuilding
-- try "rpm -qf" and then rpmquery to resolve clib devel depends
-- support SUSE packaging (thanks Jan Matějka)
-- support RHEL5 packaging
-- support Cabal-1.20
-- improve output for 'depends' command
-- no duplicate clibs deps
-- include "cblrpm" in tempdir names
-- use current dir name as a last guess of package name
-
-# 0.8.11 (2014-05-17)
-- build command renamed again from "rpm" to "local" (like fedpkg)
-- use .spec file to determine pkg-ver when no .cabal file around
-- automatically generate bcond for %check and add testsuite BRs
-  when testsuites available
-- disable debuginfo explicitly when no c-sources in preparation for
-  ghc-rpm-macros no longer disabling debuginfo
-- reset filemode of downloaded hackage tarballs to 0644:
-  workaround for cabal-install setting 0600
-- include release again in initial changelog
-- also pull in Cabal and ghc-rpm-macros when yum installing deps
-- no longer depends on regex-compat
-- some refactorings
-
-# 0.8.10 (2014-03-03)
-- diff command replaces cblrpm-diff script
-- new missingdeps command
-- replace use of rpmspec: no "rpmspec --srpm" on RHEL 5 and 6
-
-# 0.8.9 (2014-02-10)
-- bugfix for error handling dir with spec file
-- cblrpm-diff arg is now optional
-
-# 0.8.8 (2014-02-09)
-- updated GPLv3 license headers
-- use .spec file to determine package if no .cabal file (works with
-  or without arg)
-- bugfix: install command now works even if some dependencies not packaged
-- bugfix: do not re-copy cached tarball each time
-- use new shorter hackage2 URL for packages
-- capitalize start of summary and description
-- filter @ and \ quotes in descriptions
-- new prep command (like "rpmbuild -bp" or "fedpkg prep")
-- new depends and requires commands list package depends or buildrequires
-- new builddep command (like yum-buildep, but allows missing packages)
-- notice for overwriting existing spec file with force option
-
-# 0.8.7 (2013-12-31)
-- new "install" command wrapping "cabal install"
-- "build" command renamed to "rpm"
-- sort devel Requires
-- cblrpm-diff: allow package arg
-- support copying tarball fetched from another remote-repo (Ricky Elrod)
-- hlint cleanup
-- support AGPL license in Cabal-1.18
-
-# 0.8.6 (2013-10-04)
-- check for _darcs or .git dir in package topdir not pwd
-
-# 0.8.5 (2013-09-29)
-- fix repoquery when a package update exists for C lib
-- make cblrpm-diff quieter
-
-# 0.8.4 (2013-09-28)
-- use repoquery to determine extra C library dependencies
-- quote "pkgconfig(foo)" for rpm query and yum install
-- show sudo command before sudo password prompt appears
-- exclude hsc2hs from build tool deps
-- devel provides ghc-<pkg>-static
-- drop release from initial changelog entry for packager to add an entry
-- do not try to fetch tarball for a darcs or git source dir
-
-# 0.8.3 (2013-07-12)
-- only try to install missing dependencies
-- for executables depending on own lib add BR chrpath and %ghc_fix_dynamic_rpath
-- word-wrap generic descriptions
-- map ffi to libffi
-- move modules to toplevel
-- Rpm module split into Spec and Build in Commands/
-
-# 0.8.2 (2013-07-02)
-- handle pkg-ver arg, and check cabal list is non-empty
-- sort all generated deps
-- use yum-builddep again to install deps
-- copy tarball into cwd for rpmbuild
-- warn about long synopsis rather than multiline
-- wrap after end of sentence near end of line
-- use _isa in requires ghc-<pkg>
-- --version now outputs to stdout
-- new --force flag to overwrite existing .spec file
-
-# 0.8.1 (2013-06-14)
-- word wrapping of descriptions
-- use generic description for shared subpackage
-- simplify logic for summary and description processing
-
-# 0.8.0 (2013-05-31)
-- new simplier revision to Fedora Packaging
-  - drop %common_summary and %common_description
-  - drop %ghc_package, %ghc_description, %ghc_devel_package,
-    %ghc_devel_description, %ghc_devel_post_postun, %ghc_files,
-    and %ghc_devel_requires
-- check external programs available before use
-- tweaks for ghc-7.6.3 and Cabal-1.16
-
-# 0.7.1 (2013-03-22)
-- add final full-stop to description if missing
-- add ver-rel to initial changelog entry
-- fix use of cblrpm-diff force lib option
-- output warning when .spec already exists
-- fix handling of package names that end in a digit
-- output when trying a path
-- map curl C dep to libcurl
-
-# 0.7.0 (2013-01-22)
-- cabal-rpm command renamed to cblrpm, and cabal-rpm-diff to cblrpm-diff
-- cblrpm now has commands for spec, srpm, and build
-- cblrpm will try to install packaged uninstalled depends with sudo yum install
-- add %ghc_arches_with_ghci for hamlet dep
-- cblrpm-diff supports -l
-- cblrpm --version
-- sort extralibs depends
-- cleanup of unused options and help output
-
-# 0.6.6 (2012-11-21)
-- generate BRs and Req's for C libraries (extra-libraries)
-- initial map for some C libs: libglut, libiw, libz, libX*
-- generate BRs and Req's for pkgconfig-depends
-- generate BRs for build-tools
-- initial map for build-tools: gtk2hs-buildtools
-- map LGPL-2.1 license to LGPLv2+ tag
-- backup suffix changed from .cabal-rpm to .cblrpm
-- don't mistake non-existent file in cwd for a package
-
-# 0.6.5 (2012-11-01)
-- drop hscolour BuildRequires
-- simplify generated BuildRequires: drop version ranges for now,
-  exclude pkg self, base libs, and Cabal
-- use ExclusiveArch ghc_arches_with_ghci for template-haskell dep
-- replace --name option with --library to force Lib
-
-# 0.6.4 (2012-09-25)
-- add cabal-rpm-diff
-- fix manpage generation
-
-# 0.6.3 (2012-09-24)
-- support tarball path argument
-- use a temporary working dir for opening tarball or cabal unpack
-- add a manpage
-
-# 0.6.2 (2012-09-10)
-- fix output of L/GPL version
-
-# 0.6.1 (2012-07-25)
-bugfixes:
-- fix "cabal-rpm pkg" when other *pkg* packages exist in hackage
-- always generate the extra docs list from the pkg src dir!
-- now no backslash at end of common_description
-
-# 0.6.0 (2012-07-24)
-- updated to work with Cabal >= 1.10 and current cabal2spec style packaging
-  using currently actively used ghc-rpm-macros
-- should generate haskell dependencies correctly and also summary and
-  description text
-- some of the generic compiler supported was dropped for simplicity
-- rpmbuild support will be re-introduced in a future version
-
-# 0.5.1 and earlier (2007-2008) released by Bryan O'Sullivan
-- should work with ghc-6.8
-
-
-# Local Variables:
-# mode: text
-# End:
diff --git a/ChangeLog.md b/ChangeLog.md
new file mode 100644
--- /dev/null
+++ b/ChangeLog.md
@@ -0,0 +1,607 @@
+# 2.2.1 (2024-08-02)
+- getBuildDir: handle new rpm-4.20 BUILD/n-v-build dir
+- spec: --stream should be used first when determining stream
+- spec: also output %haskell_setup when subpackaging
+- spec: only autorelease if not subpackaging
+- spec: change --tests to --no-tests to force disabling testsuite
+- spec: don't reverse order independent subpkgs
+- spec: only put --stream nightly or hackage into spec header line
+- spec: set PATH in %check
+- spec --standalone: drop cabal-install BR version and use %defined
+- spec: simplify generated bash-completion and manpage
+- spec: use %bash_completions_dir in filelist
+- update: now checks .cabal revision number explicitly whether changed
+- update: use fkinit instead of kinit
+- repoquerying with dnf5: use --whatprovides and repoquery must be --quiet
+- Dependencies: resolveLib now warns with name of missing library
+- PackageUtils findDocsLicenses: ignore Haskell source files
+- .cabal: add ghc-options (from hkgr) and drop redundant build-depends
+- .cabal: need simple-cmd-args 0.1.7 to drop direct optparse-applicative dep
+- .cabal: drop the old-time flag (for time < 1.5)
+
+# 2.2.0 (2024-03-27)
+- Dependencies excludedPkgs: add system-cxx-std-lib
+- Dependencies: withGhcProfLibType to respect %with_ghc_prof for builddeps
+- PackageUtils dependencySortCabals: do nothing if empty
+- Snapshots: update stackage snapshots.json url
+- Spec: usesOptparse, maybeGenerateBashCompletion, maybeGenerateManpage
+- spec: add %{?haskell_setup}
+- spec: define and use %ghc_major for --with-compiler
+- spec: do not BR ghcX.Y-prof for standalone
+
+# 2.1.5 (2023-11-10)
+- bugfix: --flags should be optional!
+- PackageUtils pkgSpecPkgData: error displaying an unparsable pkgid
+
+# 2.1.4 (2023-11-03)
+- spec --standalone should not create subpkgs (regression in 2.1.3)
+- spec: when subpackaging include prof for main exec deps
+- fix --flags parsing to actually work!
+- PackageUtils bringTarball: create SOURCES/ earlier for new user
+
+# 2.1.3 (2023-09-27)
+- spec: implement recursive missing deps fully; use cabal-sort if available
+- spec: also get the license of subpkgs now
+- spec: optparse-simple also supports bash completions
+- spec: simplify standalone %ghc_set_gcc_flags conditional
+- Stackage: prefer stack list if available: should be faster
+- Stackage: cache latest snapshots versions with code from stack-all
+- update: be more careful about adding new revised .cabal
+
+# 2.1.2 (2023-07-27, F39)
+- PackageUtils checkForPkgCabalFile: check within BUILD dir
+- PackageUtils patchSpec: drop problem code for showing patch -.rej
+- Stackage: bump default to lts-21
+- allow Cabal-3.10
+- https for COPYING urls
+- spec: add %autopatch if Patch's and no %patch
+- spec: exclude missing deps from missing testsuite deps
+- spec: revert from %autosetup to %setup
+- spec: standalone should not use prof
+- update: --old-stream option for subpackages
+- update: invert gitBool check for local changes
+- update: use wasrevised to control revision of old reference spec
+
+# 2.1.1 (2023-03-27)
+- spec: use %autosetup
+- PackageUtils patchSpec: adding newline to stdin hangs patch
+
+# 2.1.0 (2023-02-15)
+- spec: list out ghc-*-prof BRs separately from ghc-*-devel
+- spec: output SPDX license tags
+- spec: for standalone f36+ cabal-install needs %ghc_set_gcc_flags
+- spec: handle '.' paragraph separator lines in description
+- spec: initial support for --with-ghc version to build with ghcX.Y
+- spec: check if deps of missing deps available
+- spec: for --standalone define %cabal_install for cabal
+- Stackage: default to latest lts-20 stream
+- refresh: build cabal-rpm in tempdir
+- PackageUtils rpmbuild: no longer override _builddir, _rpmdir, _srcrpmdir
+- PackageUtils tryUnpack: now into %_builddir
+- PackageUtils patchSpec: show .rej if patch fails
+- PackageUtils: handle tools like ghc-tags which are not a library
+- always assume revised .cabal is wanted/used
+- remove all the keep logic for tmpdir processing
+- allow Cabal-3.8
+- GH action: add 9.4 and bump actions versions
+- Diff: use extra withTempDir
+- simplify withTempDirectory with withCurrentDirectory
+
+# 2.0.11.1 (2022-03-28)
+- support building with Cabal 3.6
+
+# 2.0.11 (2022-03-13)
+- take build-tool-depends into account
+- 'spec','update': detect %autorelease and preserve %autochangelog
+- 'spec --standalone': strip executable
+- support %_builddir
+
+# 2.0.10 (2021-08-14)
+- pkgSpecPkgData: try allowing versioned dir
+- update: only output old version if upgrading
+- stack: use final lts17
+- Stackage: bump to LTS 18
+- Spec: drop %ghc_fix_rpath for subpkgs
+
+# 2.0.9 (2021-06-08)
+- spec: doc requires ghc-filesystem
+- spec: make %cabal_test conditional explicit
+- refresh: fix installation of cabal-rpm-version with cabal install
+- spec: tweak conditions for standalone sandbox (ie rhel8)
+
+# 2.0.8 (2021-03-27)
+- update: make sure krb ticket exists before uploading source
+- spec: executable doc files now handled by ghc-rpm-macros
+- move dos2unix for revised DOS .cabal from download to spec build time
+- spec: do not enable testsuite for standalone package
+- spec: also bash-completion for simple-cmd-args
+- spec: for bash-completions use default not filenames
+- Stackage: use lts-17
+- pkgInstallMissing: also install ghc-rpm-macros
+
+# 2.0.7 (2020-10-07)
+- spec: setup bash completions for optparse-applicative
+- spec: --ignore-missing to ignore deps not yet in hackage
+- update: only commit revised if actual changes
+- show rpmbuild mode
+- spec --standalone updated for cabal-install 3 (f33+)
+
+# 2.0.6 (2020-06-28) Fedora 33
+- spec: use packager's name in %changelog
+- spec: default package versions to Stackage LTS 16
+- spec now also leaves newly prepped source tree around
+- spec: handle testsuite tool deps separately
+- spec, refresh, update: more care about whether to revise or not
+- diff: ignore release field
+- prep: be quiet
+- spec: add a comment for missing testsuite deps
+- only allow specifying major Stackage LTS versions (not minor):
+  for more progressive updating logic (lts-n -> lts-(n+1) -> nightly -> Hackage)
+- spec: don't warn "spec exists" explicitly
+- spec: take specified stream into account for subpackaging
+- update: finally run prep to check update okay
+- prep/srpm --verbose and local --quiet options
+- spec: move chmod for docs to %prep
+- spec: check existing .spec file for detecting dropped deps and executable deps
+- update: also commit revised .cabal file when no update
+- fix copying of cached tarballs (longstanding defect)
+
+# 2.0.5.1 (2020-06-11)
+- spec: fix grep breakage in 2.0.5 release
+- refresh and update now leave newly prepped source tree around
+- spec: dropped deprecated %post and %postun scriptlets
+
+# 2.0.5 (2020-06-10)
+- spec --tests flag to force enabling testsuite
+- spec: fix permissions of extra-source-files
+- update url for Fedora Haskell Packaging Guidelines (TristanCacqueray)
+- make cabal update silent and check for 01-index
+- support Cabal-3.2 ShortText (hekkaidekapus)
+- use simple-cmd-args 0.1.6 for working subcommand help
+- improve handling of update --stream for subpackaging
+- bump latest Stackage to LTS 15
+- spec: exclude deps dropped with cabal-tweak-drop-dep
+
+# 2.0.4 (2020-02-27) Fedora 32
+- update: also unbreak patching
+
+# 2.0.3 (2020-02-24)
+- refresh: unbreak to patch spec file
+- spec: detect local revised .cabal file
+
+# 2.0.2 (2020-02-20)
+- drop %_devel compat macro
+- default stream is now lts-14
+- sort deps of subpackages
+- metapkgs don't have prof or doc
+- fix generation of subpackages for a new package
+- update: logic reworked to reduce redundant downloads
+
+# 2.0.1 (2020-02-06)
+- quote macros in commented fields
+- read --subpackage from spec header
+- generate BRs for subpackages
+
+# 2.0.0 (2020-01-16)
+- major refactor to handle stream/pkgid more precisely and correctly
+  (hence major version bump due to behavior changes)
+  - eg can no longer specify both stream and pkg-ver
+- check for package first in default LTS, then latest LTS, and Nightly,
+  before Hackage
+- respect and read/write --standalone and --stream in spec header consistently
+  (note default LTS stream is not written to header)
+- fix infinite loop for 'install'
+- optionally use libcurl binding instead of former stackage-query fallback
+
+# 1.0.3 (2019-12-31)
+- define %_devel for f30 packaging compatibility
+- missingdeps and builddep fixes
+- --standalone: add BRs for deps of missing deps
+
+# 1.0.2 (2019-12-09)
+- allow newer time for ghc-8.8
+- more type refactoring: PackageIdentifier, LibPkgType, RpmPackage
+  and some associated bugfixes
+
+# 1.0.1 (2019-09-29)
+- doc and prof subpackages for libraries
+- reworked to use optparse-applicative (simple-cmd-args)
+- default to Stackage LTS 13
+- F31+ uses triggers for ghc-pkg recache
+- wait 10^4s (< 3 hours) between cabal update's
+- refactor using simple-cabal, PackageName and LibPkgType
+- handle setup-depends
+- diff: autodetect subpackaging
+- diff (experimental): trim %changelog with bawolk/hsp if available
+- drop pre-built manpage: use Makefile to build it
+
+# 0.13.3 (2019-05-10)
+- default stream to lts-12
+- repoquery for missing deps' package .conf file to avoid modular ghc conflicts
+- only --assumeyes for dnf install when not tty
+- give up if more than one spec file
+- fix handling unversioned update
+- map cabal build-tool to cabal-install
+- use tmpdir for tmp spec files and building missing deps
+- finalPackageDescription for debugging Cabal
+- use simple-cmd-0.1.3.1 for sudo fixes
+
+# 0.13.2 (2019-04-09)
+- include ANNOUNCE in docs
+- if dependency parallel directory exists, don't check if installed
+- fix buildDepends on Cabal-2.4
+- new --standalone option for private packages built with cabal-install
+- print --{missing,standalone,subpackage} options on spec file header line
+
+# 0.13.1 (2019-02-27)
+- update: fix rw git dir detection
+- fix tarball downloading and copying of revised .cabal file
+- show output (errors) when prepping source and prep in working dir
+- include BUGS and CONTRIBUTING as docs
+- need chrpath for subpackages
+- move license dir to any common subpackage
+
+# 0.13 (2019-02-18)
+- improve license and doc filtering
+- backup revised .cabal files
+- fallback to spectool for source downloading
+- drop selfdep
+- common subpackage for binlib data files
+- section dividers for sources, setup, build, install, and files
+- only run "cabal update" if more than 10min old
+- drop support for ghc-7.4.2
+
+# 0.12.6 (2018-10-20)
+- update: remove old revised .cabal
+- convert revised .cabal file to unix format
+- spec: support haskell-gi libraries
+- most of SysCmd moved to simple-cmd library (new dep)
+- can now download multiple source files
+- use line-buffering for stdout
+- always do cabal update
+- support ghc_without_dynamic for static executables
+- build with Cabal-2.4 (ghc-8.6)
+
+# 0.12.5 (2018-07-29)
+- update: more careful now with fuzz 1
+-- handle revised to non-revised
+-- improved for subpackaging
+- improvements to revising of .cabal files
+-- place after any subpackages
+-- use revision when prep'ing and building
+- use "fedpkg sources" to fetch current Fedora sources
+- refresh: handle subpackages
+- missing: better output for missing sub-deps
+- do not put doc* in docs
+
+# 0.12.4 (2018-05-31)
+- now uses Hackage revisions of packages (using wget)
+- spec --stream STREAM replaces --hackage
+- disable https for ghc < 7.10
+
+# 0.12.3 (2018-05-14)
+- build: remove erroneous tarball check
+- refresh: use cblrpm for old cabal-rpm
+
+# 0.12.2 (2018-03-29)
+- diff now supports CBLRPM_DIFF envvar to override "diff -u"
+- try to build even when missing rpms deps not available
+- package now builds with Cabal-2.2
+
+# 0.12.1 (2018-02-20)
+- new option --missing: comments out missing dependencies
+- put license files in lib subpackage
+- no longer append %_isa to C BuildRequires (#54)
+- no longer leave leftover tmpdirs (#26)
+- change 'cblrpm' to 'cabal-rpm' in documentation
+- drop support for SCM snapshot releases
+
+# 0.12 (2017-11-17)
+- default to querying stackage.org directly via https
+- fix stackage-query usage and suggest installing if missing
+- run cabal update before cabal commands
+- devel packages now provide doc subpackage for forward compatibility
+- new --hackage option to get package version from Hackage not Stackage
+- do not add .cabal files containing "doc" to docs
+- silence mock rpmbuild -bs warnings about undefined %ghc_version
+- allow building with ghc-8.2 and Cabal-2.0
+
+# 0.11.2 (2017-07-31)
+- fix cabal-rpm update --subpackage
+- fix rpm installation when no sudo (#49)
+- fix handling of no exposed modules (#50)
+- fix license handling for selfdep binlib (#51)
+
+# 0.11.1 (2017-03-13)
+- support building meta (compat) packages
+- invocation of optional stackage-query to update to LTS now works
+- initial --subpackage support for %{subpkgs} of missing deps:
+  including downloading, but update is not properly implemented yet
+- new %{pkgver} macro
+- (+-+) absorbs extra space
+- update no longer resets release for %{subpkgs}
+
+# 0.11 (2017-01-27)
+- refresh command now reads the cabal-rpm version header in the spec file and
+  installs that version of cabal-rpm under ~/.cblrpm/ and uses it to make patch
+- diff and update now follow package-version args
+- update tries to use stackage-query to check latest Stackage version
+  before falling back to latest Hackage
+- update from Hackage now follows "Default available version"
+- sync some changes from opensuse-haskell/cabal-rpm
+- rename Setup to Options
+- silence <$> import warnings
+
+# 0.10.1 (2016-11-29)
+- no longer need to remove License file by hand
+- use new %ghc_fix_rpath
+- include Contributors in docs
+- warn about duplicate docs in datadir and remove them
+
+# 0.10.0 (2016-07-27)
+- rename executable and manpage back to 'cabal-rpm': more predictable
+- explicit error for unknown command
+- sort docs and include upstream changelogs and news
+- add cabal-rpm version header line to spec files
+- new highly experimental command to refresh spec files
+- only add "ExclusiveArch: %{ghc_arches_with_ghci}" for RHEL/EPEL
+- use revised Hackage .cabal files on SUSE (@peti)
+- on SUSE add explicit requires for pkgconfig
+- new --compiler option (@peti)
+- new --distro option (@peti)
+- new --strict option which fails when unresolved cdeps (@peti),
+  otherwise a warning is output
+- update now shows diff
+- use %cabal_test (@mimi1vx)
+- no longer duplicate docs in datadir
+- package datadir better
+- for SUSE libs executables now go in the base package
+
+# 0.9.11 (2016-05-06)
+- build with Cabal-1.24
+
+# 0.9.10 (2016-03-24)
+- bugfixes
+  - update no longer tries to grep non-existent .git
+  - fix duplicate clibs
+- fix build with ghc-8.0 (Cabal-1.23 and time-1.6)
+- SuSE improvements: no disttag or rpmdev-bumpspec
+
+# 0.9.9 (2016-01-25)
+- couple of minor improvements for SUSE packaging
+
+# 0.9.8 (2015-10-08)
+- better %license logic
+- fix handling of versions without '.'
+- no duplicate test deps
+
+# 0.9.7 (2015-08-28)
+- only list buildable executables in spec file
+- bring back 'build' as an alias for 'local'
+- use %license macro
+- do not warn about missing optional system programs
+
+# 0.9.6 (2015-05-21)
+- make "cabal list" quiet
+- filter missing packages from repoquery
+
+# 0.9.5.1 (2015-05-01)
+- add old-locale Cabal flag to fix build on ghc-7.10
+
+# 0.9.5 (2015-04-20)
+- fix for dnf repoquery
+- create SOURCES/ for tarball
+- fixes for Cabal-1.22
+- nogpgcheck for Fedora 22+
+- warn about hidden backup spec files
+
+# 0.9.4 (2015-02-17)
+- use dnf if installed instead of yum for install and repoquery
+- update now only commits changes and new source if git origin is ssh
+- allow Cabal-1.22
+
+# 0.9.3 (2015-02-05)
+- make sure tarball destdir exists before copying
+- improve output for listing missing packages
+- update improvements: new-sources first, continue if patch fails, git commit changes
+- spec: sort executables and use %pkg_name in %ghc_fix_dynamic_rpath
+- drop the debuginfo handling for C files
+- ignore emacs temp ".#pkgname.spec" files
+
+# 0.9.2 (2014-12-18)
+- lots of bug fixes
+- improved missingdeps output
+- use https for hackage URLs (codeblock)
+- no longer override %_sourcedir, %_rpmdir, and %_srcrpmdir, unless git dir
+- new "update" command to update spec to latest version
+- use 'rpm --eval "%{?dist}"' to determine OS type
+- fix build and warnings for Cabal 1.20
+- use TMPDIR
+
+# 0.9.1 (2014-08-26)
+- missingdeps now lists missing dependencies recursively and outputs Hackage
+  package names rather than ghc-*-devel package names
+- do not assume package order when testing if dependencies installed
+- check  ~/.cabal/packages/ exists before looking for tarballs
+- pass actual exeNames to %ghc_fix_dynamic_rpath
+
+# 0.9 (2014-07-17)
+- reworked initial logic to make better use of existing spec files,
+  and prep source tree properly
+- default to Library packaging instead of BinLib:
+  override with --binary which replaces --library
+- prep src for version in existing spec file when building
+- 'install' command now does local recursive rpmbuilding
+- try "rpm -qf" and then rpmquery to resolve clib devel depends
+- support SUSE packaging (thanks Jan Matějka)
+- support RHEL5 packaging
+- support Cabal-1.20
+- improve output for 'depends' command
+- no duplicate clibs deps
+- include "cblrpm" in tempdir names
+- use current dir name as a last guess of package name
+
+# 0.8.11 (2014-05-17)
+- build command renamed again from "rpm" to "local" (like fedpkg)
+- use .spec file to determine pkg-ver when no .cabal file around
+- automatically generate bcond for %check and add testsuite BRs
+  when testsuites available
+- disable debuginfo explicitly when no c-sources in preparation for
+  ghc-rpm-macros no longer disabling debuginfo
+- reset filemode of downloaded hackage tarballs to 0644:
+  workaround for cabal-install setting 0600
+- include release again in initial changelog
+- also pull in Cabal and ghc-rpm-macros when yum installing deps
+- no longer depends on regex-compat
+- some refactorings
+
+# 0.8.10 (2014-03-03)
+- diff command replaces cblrpm-diff script
+- new missingdeps command
+- replace use of rpmspec: no "rpmspec --srpm" on RHEL 5 and 6
+
+# 0.8.9 (2014-02-10)
+- bugfix for error handling dir with spec file
+- cblrpm-diff arg is now optional
+
+# 0.8.8 (2014-02-09)
+- updated GPLv3 license headers
+- use .spec file to determine package if no .cabal file (works with
+  or without arg)
+- bugfix: install command now works even if some dependencies not packaged
+- bugfix: do not re-copy cached tarball each time
+- use new shorter hackage2 URL for packages
+- capitalize start of summary and description
+- filter @ and \ quotes in descriptions
+- new prep command (like "rpmbuild -bp" or "fedpkg prep")
+- new depends and requires commands list package depends or buildrequires
+- new builddep command (like yum-buildep, but allows missing packages)
+- notice for overwriting existing spec file with force option
+
+# 0.8.7 (2013-12-31)
+- new "install" command wrapping "cabal install"
+- "build" command renamed to "rpm"
+- sort devel Requires
+- cblrpm-diff: allow package arg
+- support copying tarball fetched from another remote-repo (Ricky Elrod)
+- hlint cleanup
+- support AGPL license in Cabal-1.18
+
+# 0.8.6 (2013-10-04)
+- check for _darcs or .git dir in package topdir not pwd
+
+# 0.8.5 (2013-09-29)
+- fix repoquery when a package update exists for C lib
+- make cblrpm-diff quieter
+
+# 0.8.4 (2013-09-28)
+- use repoquery to determine extra C library dependencies
+- quote "pkgconfig(foo)" for rpm query and yum install
+- show sudo command before sudo password prompt appears
+- exclude hsc2hs from build tool deps
+- devel provides ghc-<pkg>-static
+- drop release from initial changelog entry for packager to add an entry
+- do not try to fetch tarball for a darcs or git source dir
+
+# 0.8.3 (2013-07-12)
+- only try to install missing dependencies
+- for executables depending on own lib add BR chrpath and %ghc_fix_dynamic_rpath
+- word-wrap generic descriptions
+- map ffi to libffi
+- move modules to toplevel
+- Rpm module split into Spec and Build in Commands/
+
+# 0.8.2 (2013-07-02)
+- handle pkg-ver arg, and check cabal list is non-empty
+- sort all generated deps
+- use yum-builddep again to install deps
+- copy tarball into cwd for rpmbuild
+- warn about long synopsis rather than multiline
+- wrap after end of sentence near end of line
+- use _isa in requires ghc-<pkg>
+- --version now outputs to stdout
+- new --force flag to overwrite existing .spec file
+
+# 0.8.1 (2013-06-14)
+- word wrapping of descriptions
+- use generic description for shared subpackage
+- simplify logic for summary and description processing
+
+# 0.8.0 (2013-05-31)
+- new simplier revision to Fedora Packaging
+  - drop %common_summary and %common_description
+  - drop %ghc_package, %ghc_description, %ghc_devel_package,
+    %ghc_devel_description, %ghc_devel_post_postun, %ghc_files,
+    and %ghc_devel_requires
+- check external programs available before use
+- tweaks for ghc-7.6.3 and Cabal-1.16
+
+# 0.7.1 (2013-03-22)
+- add final full-stop to description if missing
+- add ver-rel to initial changelog entry
+- fix use of cblrpm-diff force lib option
+- output warning when .spec already exists
+- fix handling of package names that end in a digit
+- output when trying a path
+- map curl C dep to libcurl
+
+# 0.7.0 (2013-01-22)
+- cabal-rpm command renamed to cblrpm, and cabal-rpm-diff to cblrpm-diff
+- cblrpm now has commands for spec, srpm, and build
+- cblrpm will try to install packaged uninstalled depends with sudo yum install
+- add %ghc_arches_with_ghci for hamlet dep
+- cblrpm-diff supports -l
+- cblrpm --version
+- sort extralibs depends
+- cleanup of unused options and help output
+
+# 0.6.6 (2012-11-21)
+- generate BRs and Req's for C libraries (extra-libraries)
+- initial map for some C libs: libglut, libiw, libz, libX*
+- generate BRs and Req's for pkgconfig-depends
+- generate BRs for build-tools
+- initial map for build-tools: gtk2hs-buildtools
+- map LGPL-2.1 license to LGPLv2+ tag
+- backup suffix changed from .cabal-rpm to .cblrpm
+- don't mistake non-existent file in cwd for a package
+
+# 0.6.5 (2012-11-01)
+- drop hscolour BuildRequires
+- simplify generated BuildRequires: drop version ranges for now,
+  exclude pkg self, base libs, and Cabal
+- use ExclusiveArch ghc_arches_with_ghci for template-haskell dep
+- replace --name option with --library to force Lib
+
+# 0.6.4 (2012-09-25)
+- add cabal-rpm-diff
+- fix manpage generation
+
+# 0.6.3 (2012-09-24)
+- support tarball path argument
+- use a temporary working dir for opening tarball or cabal unpack
+- add a manpage
+
+# 0.6.2 (2012-09-10)
+- fix output of L/GPL version
+
+# 0.6.1 (2012-07-25)
+bugfixes:
+- fix "cabal-rpm pkg" when other *pkg* packages exist in hackage
+- always generate the extra docs list from the pkg src dir!
+- now no backslash at end of common_description
+
+# 0.6.0 (2012-07-24)
+- updated to work with Cabal >= 1.10 and current cabal2spec style packaging
+  using currently actively used ghc-rpm-macros
+- should generate haskell dependencies correctly and also summary and
+  description text
+- some of the generic compiler supported was dropped for simplicity
+- rpmbuild support will be re-introduced in a future version
+
+# 0.5.1 and earlier (2007-2008) released by Bryan O'Sullivan
+- should work with ghc-6.8
+
+
+# Local Variables:
+# mode: text
+# End:
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -59,7 +59,7 @@
 
     $ cabal-rpm update
 
-updates the package to the latest Hackage version
+updates the package to the latest Stackage or Hackage version
 
     $ cabal-rpm refresh
 
@@ -70,10 +70,12 @@
 
 ## Help output
 `$ cabal-rpm --version`
+
 ```
-2.2.0
+2.2.1
 ```
 `$ cabal-rpm --help`
+
 ```
 Tool to create RPM packages from Haskell Hackage/Stackage
 
@@ -104,7 +106,7 @@
 ## Installation
 cabal-rpm is packaged in Fedora and EPEL.
 
-It currently needs at least ghc 8 or newer and Cabal 1.10 or later to build.
+It currently needs at least ghc 8 or newer and Cabal 1.18 or later to build.
 
 The package is on Hackage. If you have cabal-install you can install simply with
 
diff --git a/cabal-rpm.cabal b/cabal-rpm.cabal
--- a/cabal-rpm.cabal
+++ b/cabal-rpm.cabal
@@ -1,6 +1,6 @@
 Cabal-version:       1.18
 Name:                cabal-rpm
-Version:             2.2.0
+Version:             2.2.1
 Synopsis:            RPM packaging tool for Haskell Cabal-based packages
 Description:
     This package provides a RPM packaging tool for Haskell Cabal-based
@@ -27,7 +27,7 @@
                      2012-2024 Jens Petersen <juhpetersen@gmail.com>
 Category:            Distribution
 Build-type:          Simple
-Extra-doc-files:     ChangeLog README.md TODO
+Extra-doc-files:     ChangeLog.md README.md TODO
 Tested-with:         GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4,
                      GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.7,
                      GHC == 9.0.2, GHC == 9.2.8, GHC == 9.4.8,
@@ -37,10 +37,6 @@
   type:     git
   location: https://github.com/juhp/cabal-rpm
 
-Flag old-locale
-  Description:   Use old-locale and time < 1.5
-  Default:       False
-
 Flag curl
   Description:   Use curl library to query Stackage instead of http-client
   Default:       False
@@ -55,25 +51,18 @@
                    extra,
                    filepath >= 1.4,
                    http-query,
-                   optparse-applicative,
-                   process,
                    simple-cabal >= 0.1.3,
                    simple-cmd >= 0.2.3,
-                   simple-cmd-args >= 0.1.6,
+                   simple-cmd-args >= 0.1.7,
+                   time >= 1.5,
                    text,
                    unix
-    if flag(old-locale)
-       Build-Depends: old-locale >= 1 && < 1.1,
-                      time >= 1.2 && < 1.5
-    else
-       Build-Depends: time >= 1.5
     if impl(ghc<8.0)
        Build-Depends: semigroups
     if impl(ghc >= 8.0) && !flag(curl)
        Build-Depends: bytestring,
                       http-client >= 0.4.30,
-                      http-client-tls,
-                      http-conduit
+                      http-client-tls
     else
        Build-Depends: curl
        Cpp-options: -DCURL
@@ -98,4 +87,17 @@
                   Types,
                   Paths_cabal_rpm
     Hs-Source-Dirs:     src
-    GHC-options:        -fwarn-missing-signatures -Wall
+    ghc-options:        -fwarn-missing-signatures -Wall
+  if impl(ghc >= 8.0)
+    ghc-options:       -Wcompat
+                       -Widentities
+                       -Wincomplete-uni-patterns
+                       -Wincomplete-record-updates
+                       -Wredundant-constraints
+  if impl(ghc >= 8.2)
+    ghc-options:       -fhide-source-paths
+  if impl(ghc >= 8.4)
+    ghc-options:       -Wmissing-export-lists
+                       -Wpartial-fields
+  if impl(ghc >= 8.10)
+    ghc-options:       -Wunused-packages
diff --git a/src/Commands/Depends.hs b/src/Commands/Depends.hs
--- a/src/Commands/Depends.hs
+++ b/src/Commands/Depends.hs
@@ -38,7 +38,7 @@
 
 depends :: Depends -> Flags -> Maybe PackageVersionSpecifier -> IO ()
 depends action flags mpvs = do
-  pkgdata <- prepare flags mpvs
+  pkgdata <- prepare flags Nothing mpvs
   let pkgDesc = packageDesc pkgdata
   case action of
     Depends -> do
diff --git a/src/Commands/Diff.hs b/src/Commands/Diff.hs
--- a/src/Commands/Diff.hs
+++ b/src/Commands/Diff.hs
@@ -36,7 +36,7 @@
 
 diff :: Flags -> PackageType -> Maybe PackageVersionSpecifier -> IO ()
 diff flags pkgtype mpvs = do
-  pkgdata <- prepare flags mpvs
+  pkgdata <- prepare flags Nothing mpvs
   case specFilename pkgdata of
     Nothing -> error' "No (unique) .spec file in directory."
     Just spec -> do
diff --git a/src/Commands/Refresh.hs b/src/Commands/Refresh.hs
--- a/src/Commands/Refresh.hs
+++ b/src/Commands/Refresh.hs
@@ -39,7 +39,7 @@
 
 refresh :: Bool -> PackageType -> Maybe PackageVersionSpecifier -> IO ()
 refresh dryrun pkgtype mpvs = do
-  pkgdata <- prepare [] mpvs
+  pkgdata <- prepare [] Nothing mpvs
   case specFilename pkgdata of
     Nothing -> error' "No (unique) .spec file in directory."
     Just spec -> do
diff --git a/src/Commands/RpmBuild.hs b/src/Commands/RpmBuild.hs
--- a/src/Commands/RpmBuild.hs
+++ b/src/Commands/RpmBuild.hs
@@ -36,7 +36,7 @@
 rpmBuild :: RpmStage -> Bool -> Flags -> PackageType -> Bool
          -> Maybe PackageVersionSpecifier -> IO FilePath
 rpmBuild stage quiet flags pkgtype subpackage mpvs = do
-  pkgdata <- prepare flags mpvs
+  pkgdata <- prepare flags Nothing mpvs
   when (stage == Binary) $
     void $ pkgInstallMissing' pkgdata
   let pkgDesc = packageDesc pkgdata
diff --git a/src/Commands/Spec.hs b/src/Commands/Spec.hs
--- a/src/Commands/Spec.hs
+++ b/src/Commands/Spec.hs
@@ -31,7 +31,6 @@
 import SimpleCabal (buildable, mkPackageName, PackageDescription (..),
                     PackageIdentifier(..))
 import SimpleCmd ((+-+), cmd, cmdLines, cmdMaybe, grep, grep_, removePrefix)
-import Stackage (defaultLTS)
 import Types
 
 import Control.Monad.Extra
@@ -44,7 +43,7 @@
 import Data.List.Extra
 import Data.Maybe       (isJust, isNothing, fromMaybe, fromJust)
 import Data.Time.Clock  (getCurrentTime)
-import Data.Time.Format (formatTime)
+import Data.Time.Format (defaultTimeLocale, formatTime)
 import qualified Data.Version as V
 
 import Distribution.PackageDescription (
@@ -66,11 +65,6 @@
 
 import System.Directory (doesFileExist)
 import System.IO     (IOMode (..), hClose, hPutStrLn, openFile)
-#if MIN_VERSION_time(1,5,0)
-import Data.Time.Format (defaultTimeLocale)
-#else
-import System.Locale (defaultTimeLocale)
-#endif
 import System.FilePath (takeBaseName, (</>), (<.>))
 
 import qualified Paths_cabal_rpm (version)
@@ -90,8 +84,8 @@
                -> PackageType -> Maybe (Maybe Stream) -> Maybe V.Version
                -> Maybe FilePath -> Maybe PackageVersionSpecifier
                -> IO FilePath
-createSpecFile ignoreMissing verbose flags norevision testsuite force pkgtype subpkgStream mwithghc mdest mpvs = do
-  pkgdata <- prepare flags mpvs
+createSpecFile ignoreMissing verbose flags norevision notestsuite force pkgtype subpkgStream mwithghc mdest mpvs = do
+  pkgdata <- prepare flags Nothing mpvs
   let mspec = case pkgtype of
                 SpecFile f -> Just f
                 _ -> specFilename pkgdata
@@ -180,15 +174,18 @@
     when (maybe True realdir mdest) $
       putStrLn pkgname
 
-  mstream <- case pvsStream =<< mpvs of
-               Just s -> return $ Just s
-               Nothing ->
-                 case mpvs of
-                   Just (PVPackageId _) -> return Nothing
-                   _ -> case mspec of
-                          Just spec ->
-                            withSpecHead spec (return . fmap read . headerOption "--stream")
-                          Nothing ->  return Nothing
+  mstream <- case subpkgStream of
+               Just (Just stream) -> return $ Just stream
+               _ ->
+                 case pvsStream =<< mpvs of
+                   Just s -> return $ Just s
+                   Nothing ->
+                     case mpvs of
+                       Just (PVPackageId _) -> return Nothing
+                       _ -> case mspec of
+                              Just spec ->
+                                withSpecHead spec (return . fmap read . headerOption "--stream")
+                              Nothing ->  return Nothing
 
   h <- openFile outputFile WriteMode
   let putHdr hdr val = hPutStrLn h (hdr ++ ":" ++ padding hdr ++ val)
@@ -201,7 +198,7 @@
       subpkgParam lt = if binlib then "-n" +-+ ghc_name ++ "-%{name}" ++ pkgSuffix lt else show lt
 
   put $ "# generated by cabal-rpm-" ++ V.showVersion Paths_cabal_rpm.version
-    +-+ unwords (["--standalone" | standalone] ++ ["--stream " ++ showStream (fromJust mstream) | isJust mstream, mstream /= Just defaultLTS] ++ ["--subpackage" | subpackage])
+    +-+ unwords (["--standalone" | standalone] ++ ["--stream " ++ showStream (fromJust mstream) | isJust mstream, mstream > Just LatestLTS] ++ ["--subpackage" | subpackage])
   put "# https://docs.fedoraproject.org/en-US/packaging-guidelines/Haskell/"
   putNewline
 
@@ -263,6 +260,7 @@
   when hasLib $ do
     global "pkg_name" name
     global "pkgver" "%{pkg_name}-%{version}"
+  when (hasLib || subpackage) $ do
     put "%{?haskell_setup}"
     putNewline
 
@@ -276,7 +274,8 @@
     deep <- recurseMissing flags mstream [] $ nub (subs ++ miss)
     --print deep
     return $ filter (\(d,_) -> pkgName d `notElem` droppedDeps) deep
-  subpkgsOrdered <- dependencySortCabals mspec $ map fst missingLibsLicenses
+  let version = display $ pkgVersion pkgid
+  subpkgsOrdered <- dependencySortCabals (pkgname ++ '-' : version) mspec $ map fst missingLibsLicenses
   --print subpkgs
   let subpkgs = sort subpkgsOrdered
       mkSubpkgMacro = packageMacro . display . pkgName
@@ -294,15 +293,15 @@
   let (testsuiteDeps,testsuiteTools) = testsuiteDependencies' pkgDesc
   unpkgedTestDeps <- filterM (notSrcOrInst . RpmHsLib Devel) testsuiteDeps
   let missTestDeps = unpkgedTestDeps \\ map pkgName subpkgs
-  let testable = notNull testsuiteDeps && not standalone && (null missTestDeps || testsuite) && isNothing mwithghc
-  if testable then do
+  let testable = notNull testsuiteDeps && not standalone && null missTestDeps && not notestsuite && isNothing mwithghc
+  if testable
+    then do
     put "%bcond_without tests"
     putNewline
-    else unless (null testsuiteDeps || standalone) $ do
+    else unless (null missTestDeps || standalone) $ do
          put $ "# testsuite missing deps: " ++ unwords (map display missTestDeps)
          putNewline
-  let version = display $ pkgVersion pkgid
-      release = "1"
+  let release = "1"
   revised <-
     if norevision
     then return False
@@ -322,7 +321,7 @@
 
   putHdr "Name" (if binlib then "%{pkg_name}" else basename)
   putHdr "Version" version
-  if autorelease
+  if autorelease && not subpackage
   then putHdr "Release" "%autorelease"
   else do
     when hasSubpkgs $
@@ -388,7 +387,7 @@
     putHdr "Requires" $ "%{name}-common" ++ versionRelease
   when (standalone || subpackage) $ do
     when standalone $
-      putHdr "BuildRequires" "cabal-install > 1.18"
+      putHdr "BuildRequires" "cabal-install"
     unless (null subpkgs || ignoreMissing) $ do
       -- let deptype = if standalone then Devel else Prof
       when (isJust mwithghc) $
@@ -514,7 +513,7 @@
   if standalone then do
     global "cabal_install" "%{_bindir}/cabal"
     put "%cabal_install update"
-    put "%if 0%{?rhel} && 0%{?rhel} < 9"
+    put "%if %{defined rhel} && 0%{?rhel} < 9"
     put "%cabal_install sandbox init"
     -- FIXME support mwithghc?
     put "%cabal_install install"
@@ -531,7 +530,7 @@
   put "# Begin cabal-rpm install"
   if standalone then do
     put "mkdir -p %{buildroot}%{_bindir}"
-    put "%if 0%{?fedora} || 0%{?rhel} >= 9"
+    put "%if %{defined fedora} || 0%{?rhel} >= 9"
     put "%ghc_set_gcc_flags"
     put $ "%cabal_install install" +-+ (if isJust mwithghc then "-w ghc-%{ghc_major}" else "") +-+ "--install-method=copy --enable-executable-stripping --installdir=%{buildroot}%{_bindir}"
     put "%else"
@@ -562,25 +561,16 @@
       execNaming p = let pn = unUnqualComponentName p in
                      if pn == name then "%{name}" else pn
       -- FIXME check for included file
-      maybeGenerateBashCompletion exn = do
-        put $ "outfile=%{buildroot}%{_datadir}/bash-completion/completions" </> exn
-        put "if [ ! -e $outfile ]; then"
-        put $ "  " ++ "%{buildroot}%{_bindir}" </> exn +-+ "--bash-completion-script" +-+ exn +-+ "| sed s/filenames/default/ > $outfile"
-        put "else"
-        put "  echo \"$outfile exists!\"; exit 1"
-        put "fi"
+      maybeGenerateBashCompletion exn =
+        put $ "%{buildroot}%{_bindir}" </> exn +-+ "--bash-completion-script" +-+ exn +-+ "| sed s/filenames/default/ >" +-+ "%{buildroot}%{bash_completions_dir}" </> exn
       -- FIXME check for included file
-      maybeGenerateManpage exn = do
-        put $ "outfile=%{buildroot}%{_mandir}/man1" </> exn <.> "1"
-        put "if [ ! -e $outfile ]; then"
-        put $ "  help2man --no-info %{buildroot}%{_bindir}" </> exn +-+ "> $outfile"
-        put "else"
-        put "  echo \"$outfile exists!\"; exit 1"
-        put "fi"
+      maybeGenerateManpage exn =
+        put $ "help2man --no-info %{buildroot}%{_bindir}" </> exn +-+ ">" +-+ "%{buildroot}%{_mandir}/man1" </> exn <.> "1"
 
   when usesOptparse $ do
     putNewline
-    put "mkdir -p %{buildroot}%{_datadir}/bash-completion/completions/"
+    put "set noclobber"
+    put "mkdir -p %{buildroot}%{bash_completions_dir}"
     -- FIXME convert to for loop
     mapM_ (maybeGenerateBashCompletion . execNaming) execs
     putNewline
@@ -594,6 +584,8 @@
   when testable $ do
     put "%check"
     put "%if %{with tests}"
+    when hasExec $
+      put "PATH=%{buildroot}%{_bindir}:$PATH"
     put "%cabal_test"
     put "%endif"
     sectionNewline
@@ -613,7 +605,7 @@
     unless (common || null datafiles) $
       put $ "%{_datadir}" </> pkgver
     when usesOptparse $ do
-      mapM_ (put . ("%{_datadir}/bash-completion/completions" </>) . execNaming) execs
+      mapM_ (put . ("%{bash_completions_dir}" </>) . execNaming) execs
       mapM_ (put . (\e -> "%{_mandir}/man1" </> e <.> "1*") . execNaming) execs
     put "# End cabal-rpm files"
     sectionNewline
@@ -677,8 +669,8 @@
 createSpecFile_ :: Bool -> Verbosity -> Flags -> Bool -> Bool -> PackageType
                 -> Maybe (Maybe Stream) -> Maybe V.Version
                 -> Maybe PackageVersionSpecifier -> IO ()
-createSpecFile_ ignoreMissing verbose flags testsuite force pkgtype subpkgStream mwithghc mpvs =
-  void (createSpecFile ignoreMissing verbose flags False testsuite force pkgtype subpkgStream mwithghc Nothing mpvs)
+createSpecFile_ ignoreMissing verbose flags notestsuite force pkgtype subpkgStream mwithghc mpvs =
+  void (createSpecFile ignoreMissing verbose flags False notestsuite force pkgtype subpkgStream mwithghc Nothing mpvs)
 
 isBuildable :: Executable -> Bool
 isBuildable exe = buildable $ buildInfo exe
diff --git a/src/Commands/Update.hs b/src/Commands/Update.hs
--- a/src/Commands/Update.hs
+++ b/src/Commands/Update.hs
@@ -29,12 +29,12 @@
 import SimpleCabal (customFieldsPD, package,
                     PackageIdentifier (..), showVersion)
 import SimpleCmd
-import SimpleCmd.Git (gitBool, grepGitConfig, rwGitDir)
+import SimpleCmd.Git (grepGitConfig, rwGitDir)
 #if !MIN_VERSION_base(4,8,0)
 import Control.Applicative ((<$>))
 #endif
 import Control.Monad.Extra
-import Data.List
+import Data.List.Extra
 import Data.Maybe
 import Distribution.Text (display)
 import Distribution.Verbosity (silent)
@@ -46,14 +46,14 @@
 -- FIXME check kerberos before new-sources
 update :: Maybe Stream -> Maybe PackageVersionSpecifier -> IO ()
 update moldstream mpvs = do
-  pkgdata <- pkgSpecPkgData [] (pvsPackage =<< mpvs)
+  pkgdata <- pkgSpecPkgData [] Nothing (pvsPackage =<< mpvs)
   case specFilename pkgdata of
     Nothing -> error' "No (unique) .spec file in directory."
     Just spec -> do
       let pkgDesc = packageDesc pkgdata
           oldPkgId = package pkgDesc
           name = pkgName oldPkgId
-          wasrevised = isJust $ lookup "x-revision" (customFieldsPD pkgDesc)
+          oldrev = read <$> lookup "x-revision" (customFieldsPD pkgDesc)
       (newPkgId, mstream) <-
         case mpvs of
           Nothing -> do
@@ -91,12 +91,13 @@
         newrev <- getRevisedCabal newPkgId
         when (newver == oldver) $
           putStrLn "already latest version"
-        when (newrev || updated) $ do
+        let revchange = oldrev /= newrev
+        when (revchange || updated) $ do
           putStrLn $ display oldPkgId +-+ "current"
           subpkg <- grep_ "%{subpkgs}" spec
           -- FIXME should not update subpackage versions
-          curspec <- createSpecVersion oldPkgId spec wasrevised (if subpkg then Just moldstream else Nothing)
-          newspec <- createSpecVersion newPkgId spec True (if subpkg then Just mstream else Nothing)
+          curspec <- createSpecVersion oldPkgId spec (isJust oldrev) (if subpkg then Just moldstream else Nothing)
+          newspec <- createSpecVersion newPkgId spec (isJust newrev) (if subpkg then Just mstream else Nothing)
           currel <- getSpecField "Release" spec
           let suffix = "%{?dist}"
               defrelease = "1"
@@ -132,9 +133,9 @@
               when subpkg $ do
                 shell_ $ "cat sources >>" +-+ "sources.cblrpm"
                 renameFile "sources.cblrpm" "sources"
-              when wasrevised $
+              when (isJust oldrev) $
                 cmd_ "git" ["rm", display oldPkgId <.> "cabal"]
-              when newrev $
+              when (isJust newrev) $
                 cmd_ "git" ["add", display newPkgId <.> "cabal"]
               cmd_ "git" ["commit", "-a", "-m",
                           if autochangelog
@@ -142,11 +143,11 @@
                                ++ display newPkgId ++ "/changelog"
                           else "update to" +-+ showVersion newver]
               else
-              when newrev $ do
-              if wasrevised
-                then cmd_ "git" ["commit", "-a", "-m", "refresh .cabal revision"]
-                else
-                unlessM (gitBool "diff-index" ["--quiet", "HEAD"]) $ do
+              when revchange $ do
+              putStrLn $ "revised:" +-+ show oldrev +-+ "->" +-+ show newrev
+              if isJust oldrev
+              then cmd_ "git" ["commit", "-a", "-m", "refresh .cabal revision"]
+              else do
                 cmd_ "git" ["add", display newPkgId <.> "cabal"]
                 cmd_ "git" ["commit", "-a", "-m", "revise .cabal file"]
           rpmbuild True Prep spec
@@ -168,5 +169,5 @@
     else
     when (last krb == "(Expired)") $ do
       putStrLn $ unwords krb
-      cmd_ "kinit" [head krb]
+      cmd_ "fkinit" []
       putStrLn ""
diff --git a/src/Dependencies.hs b/src/Dependencies.hs
--- a/src/Dependencies.hs
+++ b/src/Dependencies.hs
@@ -128,18 +128,22 @@
   let libsuffix = if lib64 then "64" else ""
   let lib_path = "/usr/lib" ++ libsuffix ++ "/lib" ++ lib <.> "so"
   libInst <- doesFileExist lib_path
-  if libInst
+  mresult <-
+    if libInst
     then rpmqueryFile Rpm lib_path
     else do
-    putStrLn $ "Running repoquery for" +-+ lib_path
-    rpmqueryFile Repoquery lib_path
+      putStrLn $ "Running repoquery for" +-+ lib_path
+      rpmqueryFile Repoquery lib_path
+  when (isNothing mresult) $
+    warning $ "could not resolve dependency" +-+ lib
+  return mresult
 
 -- use repoquery or rpm -q to query which package provides file
 rpmqueryFile :: QueryBackend -> FilePath -> IO (Maybe String)
 rpmqueryFile backend file = do
-  let args =  ["-q", "--qf=%{name}", "-f"]
+  let args =  ["--qf=%{name}", "--whatprovides"]
   out <- if backend == Rpm
-         then cmd "rpm" (args ++ [file])
+         then cmd "rpm" ("-q" : args ++ [file])
          else repoquery args file
   let pkgs = nub $ words out
   -- EL5 repoquery can return "No package provides <file>"
@@ -166,10 +170,8 @@
     let (deps, setup, tools', clibs', pkgcfgs) = dependencies pkgDesc
         excludedTools n = n `notElem` ["ghc", "hsc2hs", "perl"]
         tools = filter excludedTools $ nub $ map mapTools tools'
-    clibsWithErrors <- mapM resolveLib clibs'
-
-    when (any isNothing clibsWithErrors) $
-      warning "could not resolve all clib dependencies"
+    -- nothing provides libpthread.so
+    clibsWithErrors <- mapM resolveLib $ delete "pthread" clibs'
     let clibs = catMaybes clibsWithErrors
     let showPkgCfg p = "pkgconfig(" ++ p ++ ")"
     return $ PackageDepends deps setup tools (nub clibs) (map showPkgCfg pkgcfgs)
@@ -226,7 +228,8 @@
 notSrcOrInst :: RpmPackage -> IO Bool
 notSrcOrInst pkg = do
   src <- doesDirectoryExist (".." </> showRpm (baseLibPackage pkg))
-  if src then return False
+  if src
+    then return False
     else notInstalled pkg
   where
     baseLibPackage :: RpmPackage -> RpmPackage
@@ -267,7 +270,7 @@
 
 pkgInstallMissing :: Flags -> Maybe PackageVersionSpecifier -> IO [PackageName]
 pkgInstallMissing flags mpvs = do
-  pkgdata <- prepare flags mpvs
+  pkgdata <- prepare flags Nothing mpvs
   pkgInstallMissing' pkgdata
 
 pkgInstallMissing' :: PackageData -> IO [PackageName]
@@ -342,7 +345,7 @@
       if pkg `elem` map (pkgName . fst) already
       then return ([], Nothing)
       else do
-        pkgdata <- prepare flags (streamPkgToPVS mstream (Just (unversionedPkgId pkg)))
+        pkgdata <- prepare flags Nothing (streamPkgToPVS mstream (Just (unversionedPkgId pkg)))
         let pkgdesc = packageDesc pkgdata
         missdeps <- missingPackages pkgdesc >>= filterM notAvail
         let pid = package pkgdesc
@@ -367,7 +370,7 @@
 
 packageDeps :: Flags -> PackageIdentifier -> IO [PackageName]
 packageDeps flags pid = do
-  pkgdata <- prepare flags (Just $ PVPackageId pid)
+  pkgdata <- prepare flags Nothing (Just $ PVPackageId pid)
   let pkgDesc = packageDesc pkgdata
       (deps, setup, _, _, _) = dependencies pkgDesc
   return $ nub $ (deps ++ setup) \\ [pkgName pid]
diff --git a/src/FileUtils.hs b/src/FileUtils.hs
--- a/src/FileUtils.hs
+++ b/src/FileUtils.hs
@@ -31,7 +31,7 @@
 #endif
 import Control.Exception (bracket)
 import Control.Monad (when)
-import Data.List
+import Data.List.Extra
 import Data.Maybe (isJust)
 import SimpleCmd
 import System.Directory (listDirectory,
diff --git a/src/Main.hs b/src/Main.hs
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -16,7 +16,7 @@
 -- the Free Software Foundation, either version 3 of the License, or
 -- (at your option) any later version.
 
-module Main where
+module Main (main) where
 
 #if !MIN_VERSION_base(4,13,0)
 import Control.Applicative ((<|>)
@@ -30,7 +30,8 @@
 import Distribution.Text (simpleParse)
 import Distribution.Verbosity (normal, silent)
 #if !MIN_VERSION_simple_cmd_args(0,1,7)
-import Options.Applicative (maybeReader)
+-- allows building with 0.1.6
+--import Options.Applicative (maybeReader)
 #endif
 import System.IO (BufferMode(LineBuffering), hSetBuffering, stdout)
 
@@ -62,7 +63,7 @@
       <$> ignoreMissing
       <*> quietOpt
       <*> flags
-      <*> testsuite
+      <*> notestsuite
       <*> force
       <*> pkgtype
       <*> fmap toSubpkgStream subpackage
@@ -152,8 +153,8 @@
     quietRpmbuild = switchWith 'q' "quiet" "Quiet rpmbuild output"
     verboseRpmbuild = flagWith True False 'v' "verbose" "Verbose rpmbuild output"
 
-    testsuite :: Parser Bool
-    testsuite = switchWith 'T' "tests" "Force enabling the test-suite (even if deps missing)"
+    notestsuite :: Parser Bool
+    notestsuite = switchWith 'T' "no-tests" "Disable test-suite (even if deps available)"
 
     force :: Parser Bool
     force = switchWith 'F' "force" "Force overwriting existing of any .spec file"
diff --git a/src/PackageUtils.hs b/src/PackageUtils.hs
--- a/src/PackageUtils.hs
+++ b/src/PackageUtils.hs
@@ -38,6 +38,7 @@
   readGlobalMacro
   ) where
 
+import Data.Ord (comparing, Down(Down))
 import FileUtils (assertFileNonEmpty, filesWithExtension, fileWithExtension,
                   listDirectory', withTempDirectory)
 import SimpleCabal (finalPackageDescription, licenseFiles, mkPackageName,
@@ -96,7 +97,8 @@
         licenseNames = ["copying", "licence", "license"]
         likely :: [String] -> String -> Bool
         likely names name = any (`isPrefixOf` lower name) names
-        unlikely name = not $ any (`isSuffixOf` name) ["~", ".cabal"]
+        unlikely name = not $ any (`isSuffixOf` name)
+                        ["~", ".cabal", ".hs", ".hi", ".o"]
 
 bringTarball :: PackageIdentifier -> Maybe FilePath -> IO ()
 bringTarball pkgid mspec = do
@@ -173,26 +175,37 @@
       then getCurrentDirectory
       else fromJust <$> rpmEval "%{_sourcedir}"
 
-getBuildDir :: IO FilePath
-getBuildDir =
-  fromJust <$> rpmEval "%{_builddir}"
+getBuildDir :: Maybe String -> IO FilePath
+getBuildDir mnv = do
+  builddir <- fromMaybe "" <$> rpmEval "%{_builddir}"
+  rpmver <- dropPrefix "RPM version " <$> cmd "rpm" ["--version"]
+  return $ builddir </>
+    case mnv of
+      Just nv ->
+        if readVersion rpmver >= readVersion "4.19.91"
+        then nv ++ "-build"
+        else ""
+      Nothing -> ""
 
-getRevisedCabal :: PackageIdentifier -> IO Bool
+getRevisedCabal :: PackageIdentifier -> IO (Maybe Int)
 getRevisedCabal pkgid = do
   let file = display (pkgName pkgid) <.> "cabal"
+  srcdir <- getSourceDir
   withTempDirectory $ do
     -- FIXME use cabal-file
     dl <- cmdBool "wget" ["--quiet", "https://hackage.haskell.org/package" </> display pkgid </> file]
     if not dl
-      then return False
+      then return Nothing
       else do
-      revised <- grep_ "^x-revision:" file
-      when revised $ do
-        dir <- getSourceDir
-        createDirectoryIfMissing True dir
-        -- renameFile can fail across fs devices
-        copyFile file $ dir </> display pkgid <.> "cabal"
-      return revised
+      revised <- listToMaybe <$> grep "^x-revision:" file
+      case fmap word1 revised of
+        Nothing -> return Nothing
+        Just (_,rev) -> do
+          when (isJust revised) $ do
+            createDirectoryIfMissing True srcdir
+            -- renameFile can fail across fs devices
+            copyFile file $ srcdir </> display pkgid <.> "cabal"
+          return $ Just (read rev)
 
 data RpmStage = Binary | Source | Prep
   deriving Eq
@@ -205,14 +218,14 @@
 rpmbuild :: Bool -> RpmStage -> FilePath -> IO ()
 rpmbuild quiet mode spec = do
   let rpmCmd = case mode of
-        Binary -> "a"
-        Source -> "s"
-        Prep -> "p"
+        Binary -> 'a'
+        Source -> 's'
+        Prep -> 'p'
   cwd <- getCurrentDirectory
   gitDir <- isGitDir "."
   let rpmdirs_override =
         [ "--define="++ mcr +-+ cwd | gitDir, mcr <- ["_sourcedir"]]
-  let args = ["-b" ++ rpmCmd] ++ ["--nodeps" | mode == Prep] ++
+  let args = ["-b" ++ singleton rpmCmd] ++ ["--nodeps" | mode == Prep] ++
              rpmdirs_override ++ [spec]
   if not quiet then
     cmd_ "rpmbuild" args
@@ -231,6 +244,11 @@
           rest = dropWhile (not . (prefix `isPrefixOf`)) ls
       in unlines (if null rest then tail ls else tail rest)
 
+#if !MIN_VERSION_base(4,15,0)
+    singleton :: Char -> String
+    singleton c = [c]
+#endif
+
 cabalUpdate :: IO ()
 cabalUpdate = do
   home <- getEnv "HOME"
@@ -267,9 +285,9 @@
   cmd_ "cabal" (c:args)
 
 
-tryUnpack :: PackageIdentifier -> IO FilePath
-tryUnpack pkgid = do
-  builddir <- getBuildDir
+tryUnpack :: Maybe String -> PackageIdentifier -> IO FilePath
+tryUnpack mnv pkgid = do
+  builddir <- getBuildDir mnv
   let dir = builddir </> display pkgid
   isdir <- doesDirectoryExist dir
   if isdir
@@ -333,23 +351,25 @@
     [] -> return Nothing
     _ -> error' "more than one cabal file found!"
 
-checkForPkgCabalFile :: PackageIdentifier -> IO (Maybe FilePath)
-checkForPkgCabalFile pkgid = do
+checkForPkgCabalFile :: Maybe String -> PackageIdentifier
+                     -> IO (Maybe FilePath)
+checkForPkgCabalFile mnv pkgid = do
   let pkg = pkgName pkgid
       cabalfile = display pkg <.> "cabal"
   pkgcabal <- doesFileExist cabalfile
   if pkgcabal
     then return $ Just cabalfile
     else do
-    builddir <- getBuildDir
+    builddir <- getBuildDir mnv
     let dir = builddir </> display pkgid
     exists <- doesDirectoryExist dir
     if exists
       then fileWithExtension dir ".cabal"
       else return Nothing
 
-pkgSpecPkgData :: Flags -> Maybe PackageName -> IO PackageData
-pkgSpecPkgData flags mpkg = do
+pkgSpecPkgData :: Flags -> Maybe String -> Maybe PackageName
+               -> IO PackageData
+pkgSpecPkgData flags mnv mpkg = do
   mspec <- checkForSpecFile mpkg
   case mspec of
     Just spec -> specPackageData spec
@@ -361,12 +381,12 @@
           return $ PackageData Nothing docs licenses pkgDesc
         Nothing ->
           case mpkg of
-            Just pkg -> prepStreamPkg flags Nothing defaultLTS pkg
+            Just pkg -> prepStreamPkg flags mnv Nothing defaultLTS pkg
             Nothing -> do
               cwd <- getCurrentDirectory
               case simpleParse (takeFileName cwd) of
                 Just pdir ->
-                  prepare flags (streamPkgToPVS Nothing (Just pdir))
+                  prepare flags mnv (streamPkgToPVS Nothing (Just pdir))
                 Nothing -> error' "package not found for directory"
   where
     specPackageData :: FilePath -> IO PackageData
@@ -380,26 +400,28 @@
         cabalFromSpec specFile = do
           -- FIXME handle ghcX.Y
           havePkgname <- grep_ "%{pkg_name}" specFile
-          -- handle bin packages starting with ghc, like "ghc-tags"
-          namever <- (if havePkgname then removePrefix "ghc-" else id) . head
-            <$> rpmspec ["--srpm"] (Just "%{name}-%{version}") specFile
+          -- FIXME handle bin packages starting with ghc, like "ghc-tags"
+          nv <- head
+                     <$> rpmspec ["--srpm"] (Just "%{name}-%{version}") specFile
+          let namever = (if havePkgname then removePrefix "ghc-" else id) nv
           case simpleParse namever of
             Nothing -> error' $ "pkgid could not be parsed:" +-+ namever
-            Just pkgid -> bringTarball pkgid (Just specFile)
-          builddir <- getBuildDir
-          let pkgsrcdir = builddir </> namever
-          dExists <- doesDirectoryExist pkgsrcdir
-          if dExists
-            then do
-            specTime <- modificationTime <$> getFileStatus specFile
-            dirTime <- accessTime <$> getFileStatus pkgsrcdir
-            when (specTime > dirTime) $ do
-              rpmbuild True Prep specFile
-              dExists' <- doesDirectoryExist pkgsrcdir
-              when dExists' $ cmd_ "touch" [pkgsrcdir]
-            else
-            rpmbuild True Prep specFile
-          tryFindPackageDesc pkgsrcdir
+            Just pkgid -> do
+              bringTarball pkgid (Just specFile)
+              builddir <- getBuildDir $ Just nv
+              let pkgsrcdir = builddir </> namever
+              dExists <- doesDirectoryExist pkgsrcdir
+              if dExists
+                then do
+                specTime <- modificationTime <$> getFileStatus specFile
+                dirTime <- accessTime <$> getFileStatus pkgsrcdir
+                when (specTime > dirTime) $ do
+                  rpmbuild True Prep specFile
+                  dExists' <- doesDirectoryExist pkgsrcdir
+                  when dExists' $ cmd_ "touch" [pkgsrcdir]
+                else
+                rpmbuild True Prep specFile
+              tryFindPackageDesc pkgsrcdir
 
 -- findSpecFile :: PackageDescription -> RpmFlags -> IO (FilePath, Bool)
 -- findSpecFile pkgDesc flags = do
@@ -415,39 +437,42 @@
               , packageDesc :: PackageDescription
               }
 
-prepPkgId :: Flags -> Maybe FilePath -> PackageIdentifier -> IO PackageData
-prepPkgId flags mspec pkgid = do
+prepPkgId :: Flags -> Maybe String -> Maybe FilePath
+          -> PackageIdentifier -> IO PackageData
+prepPkgId flags mnv mspec pkgid = do
   void $ getRevisedCabal pkgid
-  cabalfile <- tryUnpack pkgid
+  cabalfile <- tryUnpack mnv pkgid
   (pkgDesc, docs, licenses) <- simplePackageDescription flags cabalfile
   return $ PackageData mspec docs licenses pkgDesc
 
-prepStreamPkg :: Flags -> Maybe FilePath -> Stream -> PackageName
-              -> IO PackageData
-prepStreamPkg flags mspec stream pkg = do
+prepStreamPkg :: Flags -> Maybe String -> Maybe FilePath -> Stream
+              -> PackageName -> IO PackageData
+prepStreamPkg flags mnv mspec stream pkg = do
   pkgid <- latestPackage (Just stream) pkg
-  mcabal <- checkForPkgCabalFile pkgid
+  mcabal <- checkForPkgCabalFile mnv pkgid
   case mcabal of
     Just cabalfile -> do
       (pkgDesc, docs, licenses) <- simplePackageDescription flags cabalfile
       return $ PackageData mspec docs licenses pkgDesc
-    Nothing -> prepPkgId flags mspec pkgid
+    Nothing -> prepPkgId flags mnv mspec pkgid
 
--- Nothing means package in cwd
-prepare :: Flags -> Maybe PackageVersionSpecifier -> IO PackageData
-prepare flags Nothing = pkgSpecPkgData flags Nothing
+prepare :: Flags -> Maybe String
+        -- Nothing means package in cwd
+        -> Maybe PackageVersionSpecifier
+        -> IO PackageData
+prepare flags mnv Nothing = pkgSpecPkgData flags mnv Nothing
 -- Something implies either new packaging or some existing spec file in dir
-prepare flags (Just pvs) =
+prepare flags mpkgid (Just pvs) =
   case pvs of
-    PVPackageName pkg -> pkgSpecPkgData flags (Just pkg)
+    PVPackageName pkg -> pkgSpecPkgData flags mpkgid (Just pkg)
     PVPackageId pkgid -> do
       mspec <- checkForSpecFile $ Just (pkgName pkgid)
-      mcabal <- checkForPkgCabalFile pkgid
+      mcabal <- checkForPkgCabalFile mpkgid pkgid
       case mcabal of
         Just cabalfile -> do
           (pkgDesc, docs, licenses) <- simplePackageDescription flags cabalfile
           return $ PackageData mspec docs licenses pkgDesc
-        Nothing -> prepPkgId flags mspec pkgid
+        Nothing -> prepPkgId flags mpkgid mspec pkgid
     PVStreamPackage stream Nothing -> do
       mspec <- checkForSpecFile Nothing
       case mspec of
@@ -456,14 +481,14 @@
           let trydir = simpleParse (takeFileName cwd)
           case trydir of
             Just pdir | pkgVersion pdir == nullVersion ->
-                          prepare flags (streamPkgToPVS (Just stream) trydir)
+                          prepare flags mpkgid (streamPkgToPVS (Just stream) trydir)
             _ -> error' "package not found"
         Just spec -> do
           let pkg = mkPackageName $ removePrefix "ghc-" $ takeBaseName spec
-          prepStreamPkg flags (Just spec) stream pkg
+          prepStreamPkg flags mpkgid (Just spec) stream pkg
     PVStreamPackage stream (Just pkg) -> do
       mspec <- checkForSpecFile (Just pkg)
-      prepStreamPkg flags mspec stream pkg
+      prepStreamPkg flags mpkgid mspec stream pkg
 
 -- redundant mdir was earlier for update
 patchSpec :: Bool -> Maybe FilePath -> FilePath -> FilePath -> IO ()
@@ -473,7 +498,7 @@
     putStrLn diff
     unless dryrun $ do
       putStrLn ""
-      out <- cmdIgnoreErr "patch" opts diff
+      out <- cmdIgnoreErr "patch" opts (diff ++ "\n")
       putStrLn out
   where
     opts = ["--fuzz=1"] ++ ["-p" ++ show n | let n = count '/' (removePrefix ".Cblrpm/" newspec)] ++ maybe [] (\ d -> ["-d", d]) mdir
@@ -499,7 +524,8 @@
 repoquery :: [String] -> String -> IO String
 repoquery args key = do
   havednf <- optionalProgram "dnf"
-  let (prog, subcmd) = if havednf then ("dnf", ["repoquery", "-q"]) else ("repoquery", [])
+  -- --quiet needed to silence dnf5 unwanted stdout
+  let (prog, subcmd) = if havednf then ("dnf", ["repoquery", "--quiet"]) else ("repoquery", [])
   sudo prog (subcmd ++ args ++ [key])
 
 rpmInstall :: Bool -> [String] -> IO ()
@@ -523,23 +549,27 @@
 getSymbolicPath = id
 #endif
 
-dependencySortCabals :: Maybe FilePath -> [PackageIdentifier]
-                     -> IO [PackageIdentifier]
-dependencySortCabals _ [] = return []
-dependencySortCabals mspec pkgids = do
+-- FIXME for rpm 4.20 %{builddir}
+dependencySortCabals :: String -> Maybe FilePath
+                     -> [PackageIdentifier] -> IO [PackageIdentifier]
+dependencySortCabals _ _ [] = return []
+dependencySortCabals nv mspec pkgids = do
   cabalsort <- optionalProgram "cabal-sort"
   if cabalsort
     then do
-    forM_ pkgids $ prepare [] . Just . PVPackageId
-    builddir <- getBuildDir
+    forM_ pkgids $ prepare [] (Just nv) . Just . PVPackageId
+    builddir <- getBuildDir (Just nv)
     withCurrentDirectory builddir $ do
       -- pre-sort to stabilize sorting
-      sorted <- cmdLines "cabal-sort" (map (\pid -> showPkgId pid </> display (pkgName pid) <.> "cabal") $ sort pkgids)
+      sorted <- cmdLines "cabal-sort" (map (\pid -> showPkgId pid </> display (pkgName pid) <.> "cabal") $ reverseSort pkgids)
       --print sorted
       return $ mapMaybe (simpleParse . takeDirectory) sorted
     else do
-    mapM_ (`bringTarball` mspec) pkgids
+    mapM_ (`bringTarball` mspec) pkgids -- FIXME ?
     return pkgids
+  where
+    reverseSort :: Ord a => [a] -> [a]
+    reverseSort = sortBy (comparing Down)
 
 readGlobalMacro :: String -> FilePath -> IO (Maybe String)
 readGlobalMacro macro spec = do
diff --git a/src/Stackage.hs b/src/Stackage.hs
--- a/src/Stackage.hs
+++ b/src/Stackage.hs
@@ -44,7 +44,7 @@
 import Types
 
 defaultLTS :: Stream
-defaultLTS = LTS 21
+defaultLTS = LTS 22
 
 streamToMajorVer :: Stream -> MV.MajorVer
 streamToMajorVer (LTS n) = MV.LTS n
diff --git a/src/Types.hs b/src/Types.hs
--- a/src/Types.hs
+++ b/src/Types.hs
@@ -32,7 +32,7 @@
   ) where
 
 import Data.Char (isDigit {--, toLower--})
-import Data.List
+import Data.List.Extra
 import Data.Maybe (fromMaybe)
 #if !MIN_VERSION_base(4,11,0)
 import Data.Semigroup ((<>))
