bdcs 0.6.0 → 0.6.1
raw patch · 7 files changed
+41/−134 lines, 7 filessetup-changed
Files
- ChangeLog.md +6/−0
- Dockerfile.build +1/−4
- Makefile +3/−4
- Setup.hs +3/−104
- bdcs.cabal +14/−8
- tests/test_export.sh +12/−12
- tests/test_import.sh +2/−2
ChangeLog.md view
@@ -1,3 +1,9 @@+## 0.6.1++* Only support building with cabal-2.x. This is needed for private scope+ support on executables, which is needed for packaging.+* Update URLs to RPMs used in testing.+ ## 0.6.0 * Use the typed-process module instead of process.
Dockerfile.build view
@@ -1,9 +1,6 @@ FROM welder/fedora:latest -# workaround for https://github.com/bos/math-functions/issues/52-RUN dnf -y install cabal-install wget diffutils beakerlib \- https://kojipkgs.fedoraproject.org//packages/ghc-vector-th-unbox/0.2.1.6/1.fc26/x86_64/ghc-vector-th-unbox-0.2.1.6-1.fc26.x86_64.rpm \- https://kojipkgs.fedoraproject.org//packages/ghc-vector-th-unbox/0.2.1.6/1.fc26/x86_64/ghc-vector-th-unbox-devel-0.2.1.6-1.fc26.x86_64.rpm && \+RUN dnf -y install cabal-install wget diffutils beakerlib ghc-vector-th-unbox-devel && \ dnf clean all ENV PATH /root/.cabal/bin:$PATH
Makefile view
@@ -45,10 +45,9 @@ fi; \ cd ${d}/api-rpms; \ wget -c http://mirror.centos.org/centos/7/os/x86_64/Packages/basesystem-10.0-7.el7.centos.noarch.rpm \- http://mirror.centos.org/centos/7/os/x86_64/Packages/filesystem-3.2-21.el7.x86_64.rpm \- http://mirror.centos.org/centos/7/os/x86_64/Packages/httpd-2.4.6-67.el7.centos.x86_64.rpm \- http://mirror.centos.org/centos/7/os/x86_64/Packages/bash-4.2.46-28.el7.x86_64.rpm \- http://mirror.centos.org/centos/7/updates/x86_64/Packages/bash-4.2.46-29.el7_4.x86_64.rpm+ http://mirror.centos.org/centos/7/os/x86_64/Packages/filesystem-3.2-25.el7.x86_64.rpm \+ http://mirror.centos.org/centos/7/os/x86_64/Packages/httpd-2.4.6-80.el7.centos.x86_64.rpm \+ http://mirror.centos.org/centos/7/os/x86_64/Packages/bash-4.2.46-30.el7.x86_64.rpm \ sudo docker volume create -d local --name api-test-mddb-volume sudo docker run -v ${d}/api-mddb:/mddb:z -v ${d}/api-rpms:/rpms:z,ro --security-opt="label:disable" welder/bdcs-import-img
Setup.hs view
@@ -1,4 +1,4 @@--- Copyright (C) 2016-2017 Red Hat, Inc.+-- Copyright (C) 2018 Red Hat, Inc. -- -- This library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public@@ -13,106 +13,5 @@ -- You should have received a copy of the GNU Lesser General Public -- License along with this library; if not, see <http://www.gnu.org/licenses/>. -{-# LANGUAGE CPP #-}--module Main(main)- where--import Data.List(isPrefixOf)-import Distribution.PackageDescription(Executable(..), GenericPackageDescription(..), HookedBuildInfo, PackageDescription(..))-import Distribution.Simple(defaultMainWithHooks, simpleUserHooks)-import Distribution.Simple.InstallDirs(InstallDirs(..), fromPathTemplate, toPathTemplate)-import Distribution.Simple.LocalBuildInfo(LocalBuildInfo(..))-import Distribution.Simple.UserHooks(UserHooks(..))-import System.FilePath((</>))--#if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(2, 0, 0)-import Distribution.Types.UnqualComponentName(unUnqualComponentName)-import Distribution.Types.ExecutableScope(ExecutableScope(..))-import Distribution.Simple.Setup(ConfigFlags)-#else-import Distribution.Simple.Install(install)-import Distribution.Simple.Setup(ConfigFlags, CopyFlags)-#endif--main :: IO ()-main = defaultMainWithHooks bdcsHooks---- Handle the libexec paths, and differences between Cabal-1.x and Cabal-2.x.------ On Cabal-2.x, we can specify a scope of "private" on libexec executables.--- This can be done directly in the .cabal file when we remove support for Cabal < 2.0.-#if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(2, 0, 0)-bdcsHooks :: UserHooks-bdcsHooks = simpleUserHooks { confHook = bdcsConf }--bdcsConf :: (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo-bdcsConf (descr, hbi) flags = do- lbi <- confHook simpleUserHooks (descr, hbi) flags-- -- Modify the executable list to change the scope of the libexec executables- let localDesc = localPkgDescr lbi- scopedLbi = lbi { localPkgDescr = localDesc { executables = map mangleExec (executables localDesc) } }-- -- Add weldr/ to the libexecdir- return $ addLibexecWeldr scopedLbi- where- mangleExec :: Executable -> Executable- mangleExec exe =- if isSubcommand (unUnqualComponentName $ exeName exe) then exe{exeScope = ExecutablePrivate}- else exe--#else--- On Cabal-1.x, change the destination directory of subcomponents during the copy step-bdcsHooks :: UserHooks-bdcsHooks = simpleUserHooks { confHook = bdcsConf,- copyHook = bdcsCopy }--bdcsConf :: (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo-bdcsConf (descr, hbi) flags = addLibexecWeldr <$> confHook simpleUserHooks (descr, hbi) flags--bdcsCopy :: PackageDescription -> LocalBuildInfo -> UserHooks -> CopyFlags -> IO ()-bdcsCopy pkg lbi _ flags = do- -- First, install everything that's not a subcommand. That is almost everything- -- listed in the cabal file.- let (mainPkg, mainLbi) = extractMainComponents pkg lbi- install mainPkg mainLbi flags-- -- Second, install only the subcommands into $prefix/libexec/weldr.- let (subPkg, subLbi) = extractSubComponents pkg lbi- install subPkg subLbi flags--extractMainComponents :: PackageDescription -> LocalBuildInfo -> (PackageDescription, LocalBuildInfo)-extractMainComponents pkg lbi = let- pkg' = pkg { executables = filter (not . isSubcommand . exeName)- (executables pkg) }- in- (pkg', lbi)--extractSubComponents :: PackageDescription -> LocalBuildInfo -> (PackageDescription, LocalBuildInfo)-extractSubComponents pkg lbi = let- dest = libexecdir (installDirTemplates lbi)-- pkg' = pkg { executables = filter (isSubcommand . exeName)- (executables pkg) }- lbi' = lbi { installDirTemplates = (installDirTemplates lbi) { bindir = dest } }- in- (pkg', lbi')--#endif--isSubcommand :: String -> Bool-isSubcommand s = "inspect-" `isPrefixOf` s || "bdcs-" `isPrefixOf` s---- Make sure $libexecdir gets "weldr/" appended to it. This will affect both the installation location--- for anything that should go into $libexecdir (like our subcommand programs) as well as the auto--- generated Paths_bdcs.hs file.------ This also means if you pass --libexecdir= to "cabal configure" or any other program, you should not--- add "weldr/" to it. Otherwise you'll get it in there twice.-addLibexecWeldr :: LocalBuildInfo -> LocalBuildInfo-addLibexecWeldr lbi =- let dest = mangle $ libexecdir $ installDirTemplates lbi- in lbi { installDirTemplates = (installDirTemplates lbi) { libexecdir = dest } }- where- mangle = toPathTemplate . (</> "weldr") . fromPathTemplate+import Distribution.Simple+main = defaultMain
bdcs.cabal view
@@ -1,5 +1,5 @@ name: bdcs-version: 0.6.0+version: 0.6.1 synopsis: Tools for managing a content store of software packages description: This module provides a library and various tools for managing a content store and metadata database. These store the contents of software packages that make up a@@ -12,8 +12,8 @@ maintainer: clumens@redhat.com license: LGPL-2.1 license-file: LICENSE-build-type: Custom-cabal-version: >= 1.10+build-type: Simple+cabal-version: >= 2.0 data-files: schema.sql, data/*.conf@@ -33,11 +33,6 @@ src/tests/BDCS/RPM/*.hs, tests/*.sh -custom-setup- setup-depends: base,- Cabal >= 1.10 && < 2.1,- filepath- source-repository head type: git location: https://github.com/weldr/bdcs@@ -158,6 +153,7 @@ pkgconfig-depends: ostree-1 >= 2017.8 + autogen-modules: Paths_bdcs other-modules: Paths_bdcs default-language: Haskell2010 @@ -167,6 +163,7 @@ main-is: bdcs.hs hs-source-dirs: src/tools + autogen-modules: Paths_bdcs other-modules: Utils.GetOpt, Utils.Subcommands, Paths_bdcs@@ -187,6 +184,7 @@ executable bdcs-import main-is: import.hs+ scope: private hs-source-dirs: src/tools other-modules: Utils.GetOpt@@ -206,9 +204,11 @@ executable bdcs-inspect main-is: inspect.hs+ scope: private hs-source-dirs: src/tools/inspect, src/tools + autogen-modules: Paths_bdcs other-modules: Utils.GetOpt, Utils.IO, Utils.Subcommands,@@ -230,6 +230,7 @@ executable inspect-groups main-is: groups.hs+ scope: private hs-source-dirs: src/tools/inspect/subcommands, src/tools/inspect, src/tools@@ -257,6 +258,7 @@ executable inspect-ls main-is: ls.hs+ scope: private hs-source-dirs: src/tools/inspect/subcommands, src/tools/inspect, src/tools@@ -284,6 +286,7 @@ executable inspect-nevras main-is: nevras.hs+ scope: private hs-source-dirs: src/tools/inspect/subcommands, src/tools/inspect, src/tools@@ -306,6 +309,7 @@ executable bdcs-export main-is: export.hs+ scope: private hs-source-dirs: src/tools other-modules: Utils.GetOpt@@ -325,6 +329,7 @@ executable bdcs-tmpfiles main-is: bdcs-tmpfiles.hs+ scope: private hs-source-dirs: src/tools build-depends: bdcs,@@ -338,6 +343,7 @@ executable bdcs-depsolve main-is: depsolve.hs+ scope: private hs-source-dirs: src/tools other-modules: Utils.GetOpt
tests/test_export.sh view
@@ -79,15 +79,15 @@ rlPhaseStartSetup rlRun "sqlite3 $METADATA_DB < ./schema.sql" # filesystem package is required by the exporter- rlRun -t -c "wget http://mirror.centos.org/centos/7/os/x86_64/Packages/filesystem-3.2-21.el7.x86_64.rpm"- rlRun "$BDCS import $METADATA_DB $CS_REPO file://`pwd`/filesystem-3.2-21.el7.x86_64.rpm"+ rlRun -t -c "wget http://mirror.centos.org/centos/7/os/x86_64/Packages/filesystem-3.2-25.el7.x86_64.rpm"+ rlRun "$BDCS import $METADATA_DB $CS_REPO file://`pwd`/filesystem-3.2-25.el7.x86_64.rpm" # setup package is required since 5834760- rlRun -t -c "wget http://mirror.centos.org/centos/7/os/x86_64/Packages/setup-2.8.71-7.el7.noarch.rpm"- rlRun "$BDCS import $METADATA_DB $CS_REPO file://`pwd`/setup-2.8.71-7.el7.noarch.rpm"+ rlRun -t -c "wget http://mirror.centos.org/centos/7/os/x86_64/Packages/setup-2.8.71-9.el7.noarch.rpm"+ rlRun "$BDCS import $METADATA_DB $CS_REPO file://`pwd`/setup-2.8.71-9.el7.noarch.rpm" - rlRun -t -c "wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-rhn-plugin-2.0.1-9.el7.noarch.rpm"- rlRun "$BDCS import $METADATA_DB $CS_REPO file://`pwd`/yum-rhn-plugin-2.0.1-9.el7.noarch.rpm"+ rlRun -t -c "wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-rhn-plugin-2.0.1-10.el7.noarch.rpm"+ rlRun "$BDCS import $METADATA_DB $CS_REPO file://`pwd`/yum-rhn-plugin-2.0.1-10.el7.noarch.rpm" # these two packages both provide /usr/lib64/libcmpiCppImpl.so # normally libcmpiCppImpl0 lives in the @conflicts group@@ -103,7 +103,7 @@ rlPhaseEnd rlPhaseStartTest "When exporting a non-existing package returns an error"- OUTPUT=`$BDCS export $METADATA_DB $CS_REPO -d $EXPORT_DIR -t directory filesystem-3.2-21.el7.x86_64 NON-EXISTING`+ OUTPUT=`$BDCS export $METADATA_DB $CS_REPO -d $EXPORT_DIR -t directory filesystem-3.2-25.el7.x86_64 NON-EXISTING` rlAssertNotEquals "On error exit code should not be zero" $? 0 rlAssertEquals "On error output is as expected" "$OUTPUT" '"No such group NON-EXISTING"' @@ -112,16 +112,16 @@ rlPhaseStartTest "When exporting existing package exported contents match what's inside the RPM"- rlRun "$BDCS export $METADATA_DB $CS_REPO -d $EXPORT_DIR -t directory filesystem-3.2-21.el7.x86_64 setup-2.8.71-7.el7.noarch yum-rhn-plugin-2.0.1-9.el7.noarch"- compare_with_rpm $EXPORT_DIR filesystem-3.2-21.el7.x86_64.rpm setup-2.8.71-7.el7.noarch.rpm yum-rhn-plugin-2.0.1-9.el7.noarch.rpm+ rlRun "$BDCS export $METADATA_DB $CS_REPO -d $EXPORT_DIR -t directory filesystem-3.2-25.el7.x86_64 setup-2.8.71-9.el7.noarch yum-rhn-plugin-2.0.1-10.el7.noarch"+ compare_with_rpm $EXPORT_DIR filesystem-3.2-25.el7.x86_64.rpm setup-2.8.71-9.el7.noarch.rpm yum-rhn-plugin-2.0.1-10.el7.noarch.rpm sudo rm -rf $EXPORT_DIR rlPhaseEnd rlPhaseStartTest "When exporting existing package into .tar image untarred contents match the contents of RPM"- rlRun "$BDCS export $METADATA_DB $CS_REPO -d exported.tar -t tar filesystem-3.2-21.el7.x86_64 setup-2.8.71-7.el7.noarch yum-rhn-plugin-2.0.1-9.el7.noarch"+ rlRun "$BDCS export $METADATA_DB $CS_REPO -d exported.tar -t tar filesystem-3.2-25.el7.x86_64 setup-2.8.71-9.el7.noarch yum-rhn-plugin-2.0.1-10.el7.noarch" mkdir tar_contents && pushd tar_contents/ && tar xf ../exported.tar && popd- compare_with_rpm tar_contents/ filesystem-3.2-21.el7.x86_64.rpm setup-2.8.71-7.el7.noarch.rpm yum-rhn-plugin-2.0.1-9.el7.noarch.rpm+ compare_with_rpm tar_contents/ filesystem-3.2-25.el7.x86_64.rpm setup-2.8.71-9.el7.noarch.rpm yum-rhn-plugin-2.0.1-10.el7.noarch.rpm sudo rm -rf tar_contents/ exported.tar rlPhaseEnd @@ -132,7 +132,7 @@ # in tog-pegasus-libs: # libcmpiCppImpl.so is a symlink to libcmpiCppImpl.so.1- OUTPUT=`$BDCS export $METADATA_DB $CS_REPO -d $EXPORT_DIR -t directory filesystem-3.2-21.el7.x86_64 setup-2.8.71-7.el7.noarch libcmpiCppImpl0-2.0.3-5.el7.x86_64 tog-pegasus-libs-2:2.14.1-5.el7.x86_64`+ OUTPUT=`$BDCS export $METADATA_DB $CS_REPO -d $EXPORT_DIR -t directory filesystem-3.2-25.el7.x86_64 setup-2.8.71-9.el7.noarch libcmpiCppImpl0-2.0.3-5.el7.x86_64 tog-pegasus-libs-2:2.14.1-5.el7.x86_64` rlAssertNotEquals "On error exit code should not be zero" $? 0 rlAssertEquals "On error output is as expected" "$OUTPUT" '"Unable to add /usr/lib64/libcmpiCppImpl.so, symlink already added at this location"'
tests/test_import.sh view
@@ -25,8 +25,8 @@ # rlPhaseEnd rlPhaseStartTest "Can import a single RPM from local disk"- rlRun -t -c "wget http://mirror.centos.org/centos/7/os/x86_64/Packages/setup-2.8.71-7.el7.noarch.rpm"- rlRun -t -c "$BDCS import $METADATA_DB $CENTOS_REPO file://`pwd`/setup-2.8.71-7.el7.noarch.rpm"+ rlRun -t -c "wget http://mirror.centos.org/centos/7/os/x86_64/Packages/setup-2.8.71-9.el7.noarch.rpm"+ rlRun -t -c "$BDCS import $METADATA_DB $CENTOS_REPO file://`pwd`/setup-2.8.71-9.el7.noarch.rpm" rlPhaseEnd rlPhaseStartTest "Can import a single RPM from HTTPS URL"