cblrepo: minor corrections and questions

Hi, I was going to post the following to the cblrepo github page but I do not have an account and I encountered a problem while trying to create one. Corrections: * srcdir and pkgdir variables should be properly quoted in PKGBUILD output * there is a typo in the help message for the convertdb command: "convert and old" -> "convert an old" Questions: * How can I use cblrepo to generate PKGBUILDs from local Cabal files (i.e. packages that are not on Hackage)? Thanks! Regards, Xyne

On Mon, Sep 23, 2013 at 06:23:14AM +0000, Xyne wrote:
Hi,
I was going to post the following to the cblrepo github page but I do not have an account and I encountered a problem while trying to create one.
Corrections: * srcdir and pkgdir variables should be properly quoted in PKGBUILD output
Issue #20: https://github.com/magthe/cblrepo/issues/20
* there is a typo in the help message for the convertdb command: "convert and old" -> "convert an old"
Issue #21: https://github.com/magthe/cblrepo/issues/21
Questions: * How can I use cblrepo to generate PKGBUILDs from local Cabal files (i.e. packages that are not on Hackage)?
That's not possible at the moment, but there's a ticket related to it (though I suspect I greatly underestimated the amount of work involved when I wrote it): https://github.com/magthe/cblrepo/issues/7 I'd be very grateful for patches. /M -- Magnus Therning OpenPGP: 0xAB4DFBA4 email: magnus@therning.org jabber: magnus@therning.org twitter: magthe http://therning.org/magnus "Sendmail" and "make" are two well known programs that are pretty widely regarded as being debugged into existence. That's why their command languages are so poorly thought out and difficult to learn. It's not just you -- everyone finds them troublesome. -- Peter van der Linden, Expert C Programming, p. 220

Magnus Therning wrote:
Issue #20: https://github.com/magthe/cblrepo/issues/20 Issue #21: https://github.com/magthe/cblrepo/issues/21
Thanks.
That's not possible at the moment, but there's a ticket related to it (though I suspect I greatly underestimated the amount of work involved when I wrote it):
https://github.com/magthe/cblrepo/issues/7
I'd be very grateful for patches.
I'll see what I can do when I have some time. I need to spend some of it orienting myself in the code before I can hope to make any meaningful contribution. Thanks for the quick reply. /X

Here are patches for quoting PKGBUILD variables (issue #20) and correcting the typo the help output (issue #21). The third patch replaces "ArchLinux" with the correct/official name "Arch Linux". Xyne (3): Replace "ArchLinux" with "Arch Linux". Fix "convert and old" typo in help message. Quote PKGBUILD variables to prevent word expansion. README.md | 8 ++++---- cblrepo.cabal | 9 +++++---- src/Main.hs | 2 +- src/Util/Translation.hs | 36 ++++++++++++++++++------------------ 4 files changed, 28 insertions(+), 27 deletions(-) -- 1.8.4

--- README.md | 8 ++++---- cblrepo.cabal | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a27250c..e21079b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # What is cblrepo? -The goal of `cblrepo` is to aid in maintaining a consistent set of Haskell packages, e.g. for a Linux distribution. Currently it's heavily influenced by the work required to maintain Haskell packages for [ArchLinux](http://www.archlinux.org/), but it's proven useful also for other distributions. +The goal of `cblrepo` is to aid in maintaining a consistent set of Haskell packages, e.g. for a Linux distribution. Currently it's heavily influenced by the work required to maintain Haskell packages for [Arch Linux](http://www.archlinux.org/), but it's proven useful also for other distributions. # Building it @@ -62,7 +62,7 @@ The *add* command is used to update packages as well. ## Generating PKGBUILDs for packages -Use the *pkgbuild* command to generate the source ArchLinux package. +Use the *pkgbuild* command to generate the source Arch Linux package. $ cblrepo pkgbuild yesod @@ -70,11 +70,11 @@ Use the *pkgbuild* command to generate the source ArchLinux package. In some, hopefully rare, cases the packages found on Hackage require patching in order to work properly. There are three types of patches used by `cblrepo` at the moment: -*Cabal patches* -- A patch `<patch dir>/<pkg name>.cabal` is applied to the CABAL file before it's use. It's also included in the ArchLinux source package created with the `pkgbuild` command. +*Cabal patches* -- A patch `<patch dir>/<pkg name>.cabal` is applied to the CABAL file before it's use. It's also included in the Arch Linux source package created with the `pkgbuild` command. *Pkgbuild patches* -- A patch `<patch dir>/<pkg name>.pkgbuild` is applied to the generated PKGBUILD when executing the `pkgbuild` command. -*Source patches* -- A patch `<patch dir>/<pkg name>.source` is included in the ArchLinux source package created with the `pkgbuild` command. +*Source patches* -- A patch `<patch dir>/<pkg name>.source` is included in the Arch Linux source package created with the `pkgbuild` command. The default location for patches is the dir `./patches`, but `cblrepo` can be told to look elsewhere by using the `--patchdir=` flag. diff --git a/cblrepo.cabal b/cblrepo.cabal index 136aaa8..7f16b84 100644 --- a/cblrepo.cabal +++ b/cblrepo.cabal @@ -11,11 +11,12 @@ bug-reports: mailto:magnus@therning.org synopsis: Tool to maintain a database of CABAL packages and their dependencies description: Helper tool for people maintaining a set of CABAL packages for their - distribution. It maintains a database of packages and verifies - dependencies of the entire set as packages are added or updated. It also - makes it trivial to track packages as new versions are released on Hackage. + distribution. It maintains a database of packages and verifies dependencies + of the entire set as packages are added or updated. It also makes it trivial + to track packages as new versions are released on Hackage. - It can also be used to build source packages for the ArchLinux distribution. + It can also be used to build source packages for the Arch Linux + distribution. category: Utils, Distribution build-type: Custom -- 1.8.4

--- src/Main.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Main.hs b/src/Main.hs index 828e55c..12d377f 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -101,7 +101,7 @@ cmdConvertDbOpts = CmdConvertDb <$> strOption (short 'i' <> long "indb" <> value "cblrepo.db" <> help "old database") <*> strOption (short 'o' <> long "outdb" <> value "new-cblrepo.db" <> help "new database") cmdConvertDbCmd = command "convertdb" (info (helper <*> cmdConvertDbOpts) - (fullDesc <> progDesc "convert and old database to the new format")) + (fullDesc <> progDesc "convert an old database to the new format")) cmdRemovePkgOpts = CmdRemovePkg <$> arguments1 Just (metavar "PKGNAME ...") -- 1.8.4

--- src/Util/Translation.hs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Util/Translation.hs b/src/Util/Translation.hs index 98b62bd..93d035f 100644 --- a/src/Util/Translation.hs +++ b/src/Util/Translation.hs @@ -173,15 +173,15 @@ instance Pretty ArchPkg where where libBuildFunction = text "build() {" <> nest 4 (empty <$> - text "cd ${srcdir}/${_hkgname}-${pkgver}" <$> + text "cd \"${srcdir}/${_hkgname}-${pkgver}\"" <$> maybe empty (\ _ -> - text $ "patch " ++ shVarValue hkgName ++ ".cabal ${srcdir}/cabal.patch ") + text $ "patch " ++ shVarValue hkgName ++ ".cabal \"${srcdir}/cabal.patch\" ") cabalPatchFile <$> maybe empty (\ _ -> - text $ "patch -p4 < ${srcdir}/source.patch") + text $ "patch -p4 < \"${srcdir}/source.patch\"") buildPatchFile <$> nest 4 (text "runhaskell Setup configure -O -p --enable-split-objs --enable-shared \\" <$> - text "--prefix=/usr --docdir=/usr/share/doc/${pkgname} \\" <$> + text "--prefix=/usr --docdir=\"/usr/share/doc/${pkgname}\" \\" <$> text "--libsubdir=\\$compiler/site-local/\\$pkgid" <> confFlags) <$> text "runhaskell Setup build" <$> text "runhaskell Setup haddock" <$> @@ -192,14 +192,14 @@ instance Pretty ArchPkg where char '}' exeBuildFunction = text "build() {" <> - nest 4 (empty <$> text "cd ${srcdir}/${_hkgname}-${pkgver}" <$> + nest 4 (empty <$> text "cd \"${srcdir}/${_hkgname}-${pkgver}\"" <$> maybe empty - (\ _ -> text $ "patch " ++ shVarValue hkgName ++ ".cabal ${srcdir}/cabal.patch ") + (\ _ -> text $ "patch " ++ shVarValue hkgName ++ ".cabal \"${srcdir}/cabal.patch\" ") cabalPatchFile <$> maybe empty (\ _ -> - text $ "patch -p4 < ${srcdir}/source.patch") + text $ "patch -p4 < \"${srcdir}/source.patch\"") buildPatchFile <$> - text "runhaskell Setup configure -O --prefix=/usr --docdir=/usr/share/doc/${pkgname}" <> confFlags <$> + text "runhaskell Setup configure -O --prefix=/usr --docdir=\"/usr/share/doc/${pkgname}\"" <> confFlags <$> text "runhaskell Setup build" ) <$> char '}' @@ -211,20 +211,20 @@ instance Pretty ArchPkg where libPackageFunction = text "package() {" <> nest 4 (empty <$> - text "cd ${srcdir}/${_hkgname}-${pkgver}" <$> - text "install -D -m744 register.sh ${pkgdir}/usr/share/haskell/${pkgname}/register.sh" <$> - text "install -m744 unregister.sh ${pkgdir}/usr/share/haskell/${pkgname}/unregister.sh" <$> - text "install -d -m755 ${pkgdir}/usr/share/doc/ghc/html/libraries" <$> - text "ln -s /usr/share/doc/${pkgname}/html ${pkgdir}/usr/share/doc/ghc/html/libraries/${_hkgname}" <$> - text "runhaskell Setup copy --destdir=${pkgdir}" <$> - (maybe empty (\ _ -> text "install -D -m644 ${_licensefile} ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" <$> - text "rm -f ${pkgdir}/usr/share/doc/${pkgname}/${_licensefile}") licenseFile) + text "cd \"${srcdir}/${_hkgname}-${pkgver}\"" <$> + text "install -D -m744 register.sh \"${pkgdir}/usr/share/haskell/${pkgname}/register.sh\"" <$> + text "install -m744 unregister.sh \"${pkgdir}/usr/share/haskell/${pkgname}/unregister.sh\"" <$> + text "install -d -m755 \"${pkgdir}/usr/share/doc/ghc/html/libraries\"" <$> + text "ln -s \"/usr/share/doc/${pkgname}/html\" \"${pkgdir}/usr/share/doc/ghc/html/libraries/${_hkgname}\"" <$> + text "runhaskell Setup copy --destdir=\"${pkgdir}\"" <$> + (maybe empty (\ _ -> text "install -D -m644 \"${_licensefile}\" \"${pkgdir}/usr/share/licenses/${pkgname}/LICENSE\"" <$> + text "rm -f \"${pkgdir}/usr/share/doc/${pkgname}/${_licensefile}\"") licenseFile) ) <$> char '}' exePackageFunction = text "package() {" <> - nest 4 (empty <$> text "cd ${srcdir}/${_hkgname}-${pkgver}" <$> - text "runhaskell Setup copy --destdir=${pkgdir}" + nest 4 (empty <$> text "cd \"${srcdir}/${_hkgname}-${pkgver}\"" <$> + text "runhaskell Setup copy --destdir=\"${pkgdir}\"" ) <$> char '}' -- 1.8.4

On 2013-09-26 00:19 +0000 Xyne wrote:
Here are patches for quoting PKGBUILD variables (issue #20) and correcting the typo the help output (issue #21). The third patch replaces "ArchLinux" with the correct/official name "Arch Linux".
Xyne (3): Replace "ArchLinux" with "Arch Linux". Fix "convert and old" typo in help message. Quote PKGBUILD variables to prevent word expansion.
README.md | 8 ++++---- cblrepo.cabal | 9 +++++---- src/Main.hs | 2 +- src/Util/Translation.hs | 36 ++++++++++++++++++------------------ 4 files changed, 28 insertions(+), 27 deletions(-)
-- 1.8.4
No comments?

On Thu, Sep 26, 2013 at 12:19:41AM +0000, Xyne wrote:
Here are patches for quoting PKGBUILD variables (issue #20) and correcting the typo the help output (issue #21). The third patch replaces "ArchLinux" with the correct/official name "Arch Linux".
Xyne (3): Replace "ArchLinux" with "Arch Linux". Fix "convert and old" typo in help message. Quote PKGBUILD variables to prevent word expansion.
README.md | 8 ++++---- cblrepo.cabal | 9 +++++---- src/Main.hs | 2 +- src/Util/Translation.hs | 36 ++++++++++++++++++------------------ 4 files changed, 28 insertions(+), 27 deletions(-)
Both #20 and #21 have already been addressed: https://github.com/magthe/cblrepo/commit/93056a82c353e12962818ded6d8b736648e... https://github.com/magthe/cblrepo/commit/1bbd39b1110c14ed8d97eb47f8eee61fd73... Hopefully I didn't miss anything in fixing them, but if I did I'd love fixes for it. Would you please rebase on top of the current tip of master, so I don't need to do any merging? /M -- Magnus Therning OpenPGP: 0xAB4DFBA4 email: magnus@therning.org jabber: magnus@therning.org twitter: magthe http://therning.org/magnus When the people fear their government, there is tyranny; when the government fears the people, there is liberty. -- Thomas Jefferson

Here are the rebased patches as requested. My previous patch added quotes to all variables in the PKGBUILD functions. After the rebase, the patch now only adds quotes to "controlled" variables which should never be word-expanded. Nevertheless, I think it is good form to quote these as well to future-proof the code. Xyne (2): Replace "ArchLinux" with "Arch Linux". Quote PKGBUILD variables to prevent word expansion. README.md | 8 ++++---- cblrepo.cabal | 9 +++++---- src/Util/Translation.hs | 8 ++++---- 3 files changed, 13 insertions(+), 12 deletions(-) -- 1.8.4

--- README.md | 8 ++++---- cblrepo.cabal | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a27250c..e21079b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # What is cblrepo? -The goal of `cblrepo` is to aid in maintaining a consistent set of Haskell packages, e.g. for a Linux distribution. Currently it's heavily influenced by the work required to maintain Haskell packages for [ArchLinux](http://www.archlinux.org/), but it's proven useful also for other distributions. +The goal of `cblrepo` is to aid in maintaining a consistent set of Haskell packages, e.g. for a Linux distribution. Currently it's heavily influenced by the work required to maintain Haskell packages for [Arch Linux](http://www.archlinux.org/), but it's proven useful also for other distributions. # Building it @@ -62,7 +62,7 @@ The *add* command is used to update packages as well. ## Generating PKGBUILDs for packages -Use the *pkgbuild* command to generate the source ArchLinux package. +Use the *pkgbuild* command to generate the source Arch Linux package. $ cblrepo pkgbuild yesod @@ -70,11 +70,11 @@ Use the *pkgbuild* command to generate the source ArchLinux package. In some, hopefully rare, cases the packages found on Hackage require patching in order to work properly. There are three types of patches used by `cblrepo` at the moment: -*Cabal patches* -- A patch `<patch dir>/<pkg name>.cabal` is applied to the CABAL file before it's use. It's also included in the ArchLinux source package created with the `pkgbuild` command. +*Cabal patches* -- A patch `<patch dir>/<pkg name>.cabal` is applied to the CABAL file before it's use. It's also included in the Arch Linux source package created with the `pkgbuild` command. *Pkgbuild patches* -- A patch `<patch dir>/<pkg name>.pkgbuild` is applied to the generated PKGBUILD when executing the `pkgbuild` command. -*Source patches* -- A patch `<patch dir>/<pkg name>.source` is included in the ArchLinux source package created with the `pkgbuild` command. +*Source patches* -- A patch `<patch dir>/<pkg name>.source` is included in the Arch Linux source package created with the `pkgbuild` command. The default location for patches is the dir `./patches`, but `cblrepo` can be told to look elsewhere by using the `--patchdir=` flag. diff --git a/cblrepo.cabal b/cblrepo.cabal index 136aaa8..7f16b84 100644 --- a/cblrepo.cabal +++ b/cblrepo.cabal @@ -11,11 +11,12 @@ bug-reports: mailto:magnus@therning.org synopsis: Tool to maintain a database of CABAL packages and their dependencies description: Helper tool for people maintaining a set of CABAL packages for their - distribution. It maintains a database of packages and verifies - dependencies of the entire set as packages are added or updated. It also - makes it trivial to track packages as new versions are released on Hackage. + distribution. It maintains a database of packages and verifies dependencies + of the entire set as packages are added or updated. It also makes it trivial + to track packages as new versions are released on Hackage. - It can also be used to build source packages for the ArchLinux distribution. + It can also be used to build source packages for the Arch Linux + distribution. category: Utils, Distribution build-type: Custom -- 1.8.4

--- src/Util/Translation.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Util/Translation.hs b/src/Util/Translation.hs index b89a694..93d035f 100644 --- a/src/Util/Translation.hs +++ b/src/Util/Translation.hs @@ -181,7 +181,7 @@ instance Pretty ArchPkg where text $ "patch -p4 < \"${srcdir}/source.patch\"") buildPatchFile <$> nest 4 (text "runhaskell Setup configure -O -p --enable-split-objs --enable-shared \\" <$> - text "--prefix=/usr --docdir=/usr/share/doc/${pkgname} \\" <$> + text "--prefix=/usr --docdir=\"/usr/share/doc/${pkgname}\" \\" <$> text "--libsubdir=\\$compiler/site-local/\\$pkgid" <> confFlags) <$> text "runhaskell Setup build" <$> text "runhaskell Setup haddock" <$> @@ -199,7 +199,7 @@ instance Pretty ArchPkg where maybe empty (\ _ -> text $ "patch -p4 < \"${srcdir}/source.patch\"") buildPatchFile <$> - text "runhaskell Setup configure -O --prefix=/usr --docdir=/usr/share/doc/${pkgname}" <> confFlags <$> + text "runhaskell Setup configure -O --prefix=/usr --docdir=\"/usr/share/doc/${pkgname}\"" <> confFlags <$> text "runhaskell Setup build" ) <$> char '}' @@ -215,9 +215,9 @@ instance Pretty ArchPkg where text "install -D -m744 register.sh \"${pkgdir}/usr/share/haskell/${pkgname}/register.sh\"" <$> text "install -m744 unregister.sh \"${pkgdir}/usr/share/haskell/${pkgname}/unregister.sh\"" <$> text "install -d -m755 \"${pkgdir}/usr/share/doc/ghc/html/libraries\"" <$> - text "ln -s /usr/share/doc/${pkgname}/html \"${pkgdir}/usr/share/doc/ghc/html/libraries/${_hkgname}\"" <$> + text "ln -s \"/usr/share/doc/${pkgname}/html\" \"${pkgdir}/usr/share/doc/ghc/html/libraries/${_hkgname}\"" <$> text "runhaskell Setup copy --destdir=\"${pkgdir}\"" <$> - (maybe empty (\ _ -> text "install -D -m644 ${_licensefile} \"${pkgdir}/usr/share/licenses/${pkgname}/LICENSE\"" <$> + (maybe empty (\ _ -> text "install -D -m644 \"${_licensefile}\" \"${pkgdir}/usr/share/licenses/${pkgname}/LICENSE\"" <$> text "rm -f \"${pkgdir}/usr/share/doc/${pkgname}/${_licensefile}\"") licenseFile) ) <$> char '}' -- 1.8.4

On Sat, Sep 28, 2013 at 11:50:59PM +0000, Xyne wrote:
Here are the rebased patches as requested. My previous patch added quotes to all variables in the PKGBUILD functions. After the rebase, the patch now only adds quotes to "controlled" variables which should never be word-expanded. Nevertheless, I think it is good form to quote these as well to future-proof the code.
Xyne (2): Replace "ArchLinux" with "Arch Linux". Quote PKGBUILD variables to prevent word expansion.
README.md | 8 ++++---- cblrepo.cabal | 9 +++++---- src/Util/Translation.hs | 8 ++++---- 3 files changed, 13 insertions(+), 12 deletions(-)
Both have been applied and pushed. /M -- Magnus Therning OpenPGP: 0xAB4DFBA4 email: magnus@therning.org jabber: magnus@therning.org twitter: magthe http://therning.org/magnus Hard work may not kill me, but why take the chance.
participants (2)
-
Magnus Therning
-
Xyne