Giter Site home page Giter Site logo

cabal-rpm's Introduction

I like functional programming with algebraic data types.

cabal-rpm's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cabal-rpm's Issues

Build failure with ghc 8.4

Cabal 2.2, in particular

[ 7 of 16] Compiling PackageUtils     ( src/PackageUtils.hs, dist/build/cabal-rpm/cabal-rpm-tmp/PackageUtils.o )

src/PackageUtils.hs:68:1: error:
    Could not find module ‘Distribution.PackageDescription.Parse’
    Perhaps you meant
      Distribution.PackageDescription.Parsec (from Cabal-2.2.0.0)
      Distribution.PackageDescription.Check (from Cabal-2.2.0.0)
      Distribution.PackageDescription.Quirks (from Cabal-2.2.0.0)
    Use -v to see a list of the files searched for.
   |
68 | import Distribution.PackageDescription.Parse (readPackageDescription)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

RFE: cabal-rpm should package documentation

To build packages which installs documentation I have to patch cabal-rpm generated spec like this

@@ -125,6 +125,8 @@
%files -f %{name}.files
%defattr(-,root,root,-)
%doc LICENSE
+%docdir /usr/share/%{pkg_name}-%{version}
+/usr/share/%{pkg_name}-%{version}

because otherwise the build fails.

Since the change is generic and independent of the actual package it can be generated by cabal-rpm to start with. Also cabal can generate those few lines in the most correct and canonical way.

Sure, some packages have documentation and some not. However, it is easier to delete pre-generated spec lines than it is to add them.

Also I think it preferable to support documented packages out of the box and require manual intervention on undocumented packages rather than the other way around.

missingdeps mishandles pkgconfig deps

$ cblrpm missingdeps gtksourceview3
gtksourceview3 misses: pkgconfig(gtksourceview-3.0)
cabal: The file does not exist 'pkgconfig(gtksourceview-3.0)'.
cblrpm: cblrpm.cKwR4jvySc: getDirectoryContents: does not exist (No such file or directory)

Build failure with GHC 7.10

Some of the output is:

Unpacking to cabal-rpm-0.9.5/
Resolving dependencies...
Configuring cabal-rpm-0.9.5...
Building cabal-rpm-0.9.5...
Preprocessing executable 'cblrpm' for cabal-rpm-0.9.5...
[ 1 of 13] Compiling SysCmd           ( src/SysCmd.hs, dist/build/cblrpm/cblrpm-tmp/SysCmd.o )

src/SysCmd.hs:34:1: Warning:
    The import of ‘Data.Functor’ is redundant
      except perhaps to import instances from ‘Data.Functor’
    To import instances alone, use: import Data.Functor()
[ 2 of 13] Compiling FileUtils        ( src/FileUtils.hs, dist/build/cblrpm/cblrpm-tmp/FileUtils.o )

src/FileUtils.hs:27:1: Warning:
    The import of ‘Control.Applicative’ is redundant
      except perhaps to import instances from ‘Control.Applicative’
    To import instances alone, use: import Control.Applicative()
[ 3 of 13] Compiling Paths_cabal_rpm  ( dist/build/autogen/Paths_cabal_rpm.hs, dist/build/cblrpm/cblrpm-tmp/Paths_cabal_rpm.o )
[ 4 of 13] Compiling Setup            ( src/Setup.hs, dist/build/cblrpm/cblrpm-tmp/Setup.o )
[ 5 of 13] Compiling PackageUtils     ( src/PackageUtils.hs, dist/build/cblrpm/cblrpm-tmp/PackageUtils.o )

src/PackageUtils.hs:40:1: Warning:
    The import of ‘Control.Applicative’ is redundant
      except perhaps to import instances from ‘Control.Applicative’
    To import instances alone, use: import Control.Applicative()
[ 6 of 13] Compiling Dependencies     ( src/Dependencies.hs, dist/build/cblrpm/cblrpm-tmp/Dependencies.o )

src/Dependencies.hs:28:1: Warning:
    The import of ‘Control.Applicative’ is redundant
      except perhaps to import instances from ‘Control.Applicative’
    To import instances alone, use: import Control.Applicative()
[ 7 of 13] Compiling Commands.Spec    ( src/Commands/Spec.hs, dist/build/cblrpm/cblrpm-tmp/Commands/Spec.o )

Build with Cabal-3.2.0

In 19e2a02b924, Cabal ≥ 3.2.0 was forbidden, even though the fix is simple:

--- Commands/Spec.hs.orig
+++ Commands/Spec.hs
@@ -27,28 +27,26 @@
 import Header (headerOption, withSpecHead)
 import PackageUtils (bringTarball, latestPackage, PackageData (..), prepare)
 import SimpleCabal (buildable, mkPackageName, PackageDescription (..),
                     PackageIdentifier(..), PackageName, showVersion)
 import SimpleCmd ((+-+), grep_, removePrefix)
 import Stackage (defaultLTS)
-import Types
+import Types (Flags, LibPkgType(Base, Devel, Doc, Prof, Static),
+              PackageType(BinaryPkg, SpecFile, StandalonePkg),
+              PackageVersionSpecifier(PVPackageId), pvsStream,
+              RpmPackage(RpmHsLib), showRpm, showStream, Stream)
 
 import Control.Monad    (filterM, forM_, unless, void, when, (>=>))
 
-#if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,8,0))
-#else
---import Control.Applicative ((<$>))
-#endif
-
 import Data.Char        (toUpper)
 import Data.List        (groupBy, intercalate, intersect, isPrefixOf,
                          nub, sort, (\\))
 import Data.Maybe       (isJust, fromMaybe, fromJust)
 import Data.Time.Clock  (getCurrentTime)
 import Data.Time.Format (formatTime)
-import qualified Data.Version as V
+import qualified Data.Version as V (showVersion)
 
 import Distribution.Text (display)
 import Distribution.License  (License (..)
 #if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(2,2,0)
                              , licenseFromSPDX
 #endif
@@ -77,12 +75,14 @@
 import System.Locale (defaultTimeLocale)
 #endif
 import System.FilePath (takeBaseName, (</>), (<.>))
 
 import qualified Paths_cabal_rpm (version)
 
+import qualified Distribution.Utils.ShortText as ST (fromShortText)
 
 rstrip :: (Char -> Bool) -> String -> String
 rstrip p = reverse . dropWhile p . reverse
 
 #if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(2,0,0)
 #else
@@ -179,25 +179,25 @@
   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])
   put "# https://docs.fedoraproject.org/en-US/packaging-guidelines/Haskell/"
   putNewline
 
   -- Some packages conflate the synopsis and description fields.  Ugh.
-  let syn = synopsis pkgDesc
+  let syn = ST.fromShortText $ synopsis pkgDesc
   when (null syn) $
     warn verbose "this package has no synopsis."
   let initialCapital (c:cs) = toUpper c:cs
       initialCapital [] = []
   let syn' = if null syn
              then "Haskell" +-+ name +-+ "package"
              else (unwords . lines . initialCapital) syn
   let summary = rstrip (== '.') syn'
   when (length ("Summary     : " ++ syn') > 79) $
     warn verbose "this package has a long synopsis."
 
-  let descr = description pkgDesc
+  let descr = ST.fromShortText $ description pkgDesc
   when (null descr) $
     warn verbose "this package has no description."
   let descLines = (formatParagraphs . initialCapital . filterSymbols . finalPeriod) $ if null descr then syn' else descr
       finalPeriod cs = if last cs == '.' then cs else cs ++ "."
       filterSymbols (c:cs) =
         if c `notElem` "@\\" then c: filterSymbols cs

The above patch builds successfully on my system:

cabal-rpm --version
#2.0.5

ghc --numeric-version
#8.10.1

Moreover, to avoid a warning on GHC ≥ 8.10.1, the patch below could be applied:

--- Types.hs.orig
+++ Types.hs
@@ -29,13 +29,13 @@
   streamPkgToPVS,
   unversionedPkgId,
   Verbose(..)
   ) where
 
 import Data.Char (isDigit {--, toLower--})
-import Data.List
+import Data.List (groupBy, isPrefixOf, stripPrefix)
 import Data.Maybe (fromMaybe)
 #if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,11,0))
 #else
 import Data.Semigroup ((<>))
 #endif
 import Distribution.Text (display)

mktemp: illegal option -- -

$ cblrpm rpm hadoop-tools
mktemp: illegal option -- -
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
mktemp [-d] [-q] [-u] -t prefix
cblrpm: readProcess: mktemp "-d" "--tmpdir" "cblrpm.XXXXXXXXXX" (exit 1): failed

Add deps version bounds to generated specs

At the moment, build dependencies are added without version and runtime dependencies are added automatically due to shared library linkage. Additionally, something gets hashed into the library name causing them to be unique across all builds (even rpm revision bumps.)

I assume one of the reasons for the lack of versions is that Haskell packages usually supply both a minimum and a maximum which has not been supported in rpm. However, rust packages do a similar thing and those packagers either implemented or are going to make use of a recently implemented update to rpm that accepts multiple version specifications.

If lack of version constraints is one of the reasons here, it'd probably be good to look at what the Rust people do as these constant rebuilds are a really big holdup with updating Haskell things.

Left-over file under /usr/share/licenses/<package>/LICENSE breaks rpmbuild

According to this log:
https://copr-be.cloud.fedoraproject.org/results/@weldr/bdcs/fedora-27-x86_64/00728213-bdcs/build.log.gz

BUILDSTDERR:     Installed (but unpackaged) file(s) found:
BUILDSTDERR:    /usr/share/licenses/bdcs/LICENSE

Here's my copr build:
https://copr.fedorainfracloud.org/coprs/g/weldr/bdcs/build/728213/

and the dist git log:
http://copr-dist-git.fedorainfracloud.org/cgit/@weldr/bdcs/bdcs.git/commit/?id=92bf206711747b7286033779731f3dac6a7287a6

I see a changelog entry - put license files in lib subpackage but nothing else related to this. Are we supposed to somehow modify the existing Haskell package or not ?

Support rpmautospec

If a spec is using rpmautospec (%autorelease and %autochangelog), then this will be ignored and cabal-rpm update will reset Release to 1 and add an entry to the %changelog.

In this case, neither change should happen as the changelog will transfer from the commit message (which cabal-rpm already creates).

BuildRequires generated 2x same dep

%global pkg_name HsOpenSSL

%bcond_with tests

Name:           ghc-%{pkg_name}
Version:        0.11.1.1
Release:        0
Summary:        Partial OpenSSL binding for Haskell
Group:          System/Libraries

License:        SUSE-Public-Domain
Url:            https://hackage.haskell.org/package/%{pkg_name}
Source0:        https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

BuildRequires:  ghc-Cabal-devel
BuildRequires:  ghc-rpm-macros
# Begin cabal-rpm deps:
BuildRequires:  ghc-bytestring-devel
BuildRequires:  ghc-network-devel
BuildRequires:  ghc-old-locale-devel
BuildRequires:  ghc-time-devel
BuildRequires:  libopenssl-devel
BuildRequires:  libopenssl-devel
%if %{with tests}
BuildRequires:  ghc-HUnit-devel
BuildRequires:  ghc-test-framework-devel
BuildRequires:  ghc-test-framework-hunit-devel
%endif
# End cabal-rpm deps

BuildRequires: libopenssl-devel 2x in pkg

cabal-rpm should package data

Hello,

I have been hit by issue #47 once more so I looked more into it and the problem is this:

The vty cabal package adds (incorrectly) documentation as data, and cagal-rpm (incorrectly) ignores data and does not package it in the rpm spec resulting in build error.

--- vty-5.15/vty.cabal~ 2017-01-24 20:46:18.000000000 +0100
+++ vty-5.15/vty.cabal 2017-02-06 14:01:40.771392638 +0100
@@ -26,7 +26,7 @@
© Jonathan Daugherty; BSD3 license.
cabal-version: >= 1.18
build-type: Simple
-data-files: README.md,
+extra-doc-files: README.md,
AUTHORS,
CHANGELOG.md,
LICENSE

missing BuildRequires: pkg-config in packages using BuildRequires : pkgconfig(lib)

for example

%global pkg_name Xauth

Name:           ghc-%{pkg_name}
Version:        0.1
Release:        0
Summary:        A binding to the X11 authentication library
Group:          System/Libraries

License:        BSD-3-Clause
Url:            https://hackage.haskell.org/package/%{pkg_name}
Source0:        https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

BuildRequires:  ghc-Cabal-devel
BuildRequires:  ghc-rpm-macros
# Begin cabal-rpm deps:
BuildRequires:  pkgconfig(xau)
# End cabal-rpm deps

%description
A Haskell binding to the X11 authentication library.


%package devel
Summary:        Haskell %{pkg_name} library development files
Group:          Development/Libraries/Other
Requires:       ghc-compiler = %{ghc_version}
Requires(post): ghc-compiler = %{ghc_version}
Requires(postun): ghc-compiler = %{ghc_version}
Requires:       %{name} = %{version}-%{release}
# Begin cabal-rpm deps:
Requires:       pkgconfig(xau)
# End cabal-rpm deps

Error building haskell-gi

The build process fails on this line of the generated spec file, because the file does not exist:

mv %{buildroot}%{_ghcdocdir}/{,ghc-}%{name}

Simply removing this line makes it succeed. It's easy to see where it gets emitted, but I don't see how to fix it in such a way as to not break other things. Otherwise I'd attach a PR. Sorry.

I'll add the build log, or at least the part at the end where if fails.

cabal-rpm.1.md: SYNOPSIS is a single paragraph, a subject to reflow

This file is a markdown source. What the tool should be used to generate man page?

In case of pandoc there is a bug in SYNOPSIS section. The source code looks like:

# SYNOPSIS
cabal-rpm [*options*] spec [*path-or-pkg*]
cabal-rpm [*options*] local [*path-or-pkg*]
cabal-rpm [*options*] srpm [*path-or-pkg*]
...

All these command lines look ok in markdown, but this is a single paragraph, a subject to reflow. Being processed by pandoc and man (groff), it will look like

SYNOPSIS
    cabal-rpm   [options]  spec  [path-or-pkg]  cabal-rpm  [options]  local
    [path-or-pkg] cabal-rpm [options]  srpm  [path-or-pkg]  cabal-rpm  [op-
    tions]  prep  [path-or-pkg]  cabal-rpm [options] builddep [path-or-pkg]
    cabal-rpm [options] install [path-or-pkg] cabal-rpm  [options]  depends
    [path-or-pkg] cabal-rpm [options] requires [path-or-pkg] cabal-rpm [op-
    tions] missingdeps [path-or-pkg] cabal-rpm [options] diff [path-or-pkg]
    cabal-rpm  [options]  update  [path-or-pkg] cabal-rpm [options] refresh
    [path-or-pkg]

Hard linebreaks must be used to avoid such mess:

# SYNOPSIS
cabal-rpm [*options*] spec [*path-or-pkg*] \
cabal-rpm [*options*] local [*path-or-pkg*] \
...
cabal-rpm [*options*] update [*path-or-pkg*] \
cabal-rpm [*options*] refresh [*path-or-pkg*]

The last line should not have linebreak.

`cabal-rpm-0.13.3 local lens-family`: getDirectoryContents:openDirStream: does not exist (No such file or directory)

$ cabal-rpm lens-family
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.IVsD8k
+ umask 022
+ cd /home/ryan/rpmbuild/BUILD
+ cd /home/ryan/rpmbuild/BUILD
+ rm -rf lens-family-1.2.3
+ /usr/bin/gzip -dc /home/ryan/rpmbuild/SOURCES/lens-family-1.2.3.tar.gz
+ /usr/bin/tar -xof -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd lens-family-1.2.3
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
cabal-rpm: lens-family-1.2.3: getDirectoryContents:openDirStream: does not exist (No such file or directory)
$ cabal-rpm --version
0.13.3
$ 

Do not write empty spec file when error occurs.

Do not write empty spec file when error occurs.

yac@deathstar % ./dist/build/cblrpm/cblrpm spec xmobar
Warning: The package list for 'hackage.haskell.org' is 40 days old.
Run 'cabal update' to get the latest list of available packages.
xmobar.spec exists: creating xmobar.spec.cblrpm
cblrpm: user error (repoquery: command not found)
yac@deathstar % cat xmobar.spec
yac@deathstar %

`cabal-rpm builddep` repeats looking up missing package version

$ cblrpm builddep dhall
:
:
Running repoquery for cborg lens-family-core parsers prettyprinter prettyprinter-ansi-terminal repline serialise
Unavailable dependencies:
cborg
lens-family-core
parsers
prettyprinter
prettyprinter-ansi-terminal
repline
serialise
cborg-0.2.1.0 in Stackage lts-13
Running repoquery for half
Unavailable dependencies:
half
half-0.3 in Stackage lts-13
lens-family-core-1.2.3 in Stackage lts-13
parsers-0.12.10 in Stackage lts-13
prettyprinter-1.2.1 in Stackage lts-13
prettyprinter-ansi-terminal-1.1.1.2 in Stackage lts-13
Running repoquery for prettyprinter
Unavailable dependencies:
prettyprinter
prettyprinter-1.2.1 in Stackage lts-13
repline-0.2.1.0 in Stackage lts-13
Running repoquery for fail
Unavailable dependencies:
fail
fail-4.9.0.0 in Stackage lts-13
serialise-0.2.1.0 in Stackage lts-13
Running repoquery for cborg half
Unavailable dependencies:
cborg
half
cborg-0.2.1.0 in Stackage lts-13
Running repoquery for half
Unavailable dependencies:
half
half-0.3 in Stackage lts-13
half-0.3 in Stackage lts-13

Will not build against Cabal >= 1.20.

Cabal 1.20 apparently introduces an interface change in the function Distribution.Simple.Util.findPackageDesc that breaks this code. Therefore, the dependency range specified in the .cabal file is not actually correct.

`cabal-rpm spec` should error out / ask user when (Build)Requires is behind a conditional

cabal-rpm spec should blow up / ask user when (Build)Requires is behind a conditional

example: cabal-rpm spec transformers-compat will depend just on transformers.

However, I'm building against ghc 7.8.3 so that's not optimal.

I'd like to have a configuration option (xdg config) for cabal-rpm to say to always either error out or ask me which of the conditionals to use if possible.

reuse of existing spec filename

cabal-rpm spec xmonad
cabal-rpm spec cabal-rpm

Results into xmonad.spec first time and then xmonad.spec.cblrpm second time where xmonad.spac.cblrpm is generated for the cabal-rpm package

Crash on fromJust if no library is specified

If the project uses no library (or a sub-library instead of a library), the code crashes with

cabal-rpm: Maybe.fromJust: Nothing

triggered by https://github.com/juhp/cabal-rpm/blob/master/src/Commands/Spec.hs#L344

I'm not intimately familiar with the internals, so I can't say what the right cause of action is. Either the README.md should document that a libraryis mandatory, or it should consult sub libraries as well. Why does this need a library at all?

handle packages that start with ghc-

Currently cabal-rpm has problems handling Haskell packages that start with "ghc-",
since this is the common prefix we use for Haskell packages built with ghc.

An example is the ghc-tags package.

Using a Package type may help to keep better track of Haskell package names,
though that may not be sufficient.

autopatch for hackage revisions

Sometimes a newer revision of a .cabal is available on Hackage, it would be better for cabal-rpm to include such revision updates automatically as a patch. eg to build current mtl-2.2.1 for ghc8.

cblrpm no longer supports tarball argument

Seeing this when trying to package a local .tar.gz of a nonpublished cabal package:

ricky@t520 ⚡53% ~/haskellspecs$ ls | grep rcbot-1.0.0
rcbot-1.0.0.tar.gz

ricky@t520 ⚡53% ~/haskellspecs$ cblrpm srpm rcbot-1.0.0.tar.gz
cabal: The file does not exist 'rcbot-1.0.0.tar.gz'.
cblrpm: user error ("cabal unpack -v0 rcbot-1.0.0.tar.gz" failed with status 1)

handling missing haskell system packages

happens with my project that depends on gi-gst that dnf builddep *.spec coughs up:

[1/2] STEP 10/15: RUN dnf builddep *.spec
Last metadata expiration check: 0:57:18 ago on Fri Mar 25 06:59:31 2022.
Package ghc-Cabal-devel-3.2.1.0-117.fc36.x86_64 is already installed.
No matching package to install: 'ghc-gi-gst-prof'
Package ghc-rpm-macros-2.3.15-1.fc36.noarch is already installed.
Not all dependencies satisfied
Error: Some packages could not be found.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.