You are not logged in.

#1 2017-10-06 18:19:27

dr34m
Member
Registered: 2016-07-28
Posts: 42

PKGBUILD with prompt script installation

Hi there,

i want to create a pkgbuild for bukubrow: https://github.com/SamHH/bukubrow (The web-extension for buku, the bookmarks manager)

For working (like pass) the extension need a bin on system; https://github.com/SamHH/bukubrow/releases distributed with a .sh install.

The shell script is this:

https://github.com/SamHH/bukubrow/blob/ … install.sh

how i handle with it? the problem is: need a user prompt.

Plus i don't want to edit the script, the package need to be upgradable.

any advice?

Thanks

Offline

#2 2017-10-06 18:28:27

HalosGhost
Member
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 1,516
Website

Re: PKGBUILD with prompt script installation

Honestly, this is a bit of a packaging nightmare because upstream decided to do non-standard and annoying things.

My primary recommendation is to contribute code to them to make their install process sane (e.g., use a Makefile; that shell script is roughly trivial).

However, if you are not willing to pursue that, ignore the script wholesale, do the appropriate installation commands yourself in the package() function so files are put where they need to be. When upstream doesn't provide sane packaging systems, that's the option you're left with, I'm afraid.

All the best,

-HG


"All errors are ᴘᴇʙᴋᴀᴄ errors—It's just a matter of narrowing down which keyboard and chair." -Trilby
\ldots

Offline

#3 2017-10-06 18:35:47

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 3,813
Website

Re: PKGBUILD with prompt script installation

Isn't there a Linux command to send "fake" user input into an interactive script?

...there it is, it's called "expect". But according to here you can also simply do "echo 1 > install.sh".

Of course, if you do something like that, it will be up to the AUR user to modify the PKGBUILD file to select the web browser of choice.

Offline

#4 2017-10-06 18:38:48

Scimmia
Bug Wrangler
Registered: 2012-09-01
Posts: 6,181

Re: PKGBUILD with prompt script installation

You'd have to modify the script, anyway, it's total crap and unusable for packaging.

Offline

#5 2017-10-06 19:31:55

Trilby
Forum Fellow
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 17,260
Website

Re: PKGBUILD with prompt script installation

drcouzelis wrote:

Isn't there a Linux command to send "fake" user input into an interactive script?

You're probably thinking of `expect`.  But that would not be needed here at all as the only input is a single `read` command.

I second the warning that that script is unusable, and I also second the suggestion to just install the files properly in the package function, but if one wanted to run this script without requiring user input it would be as easy as `echo 3 | /path/to/script` for firefox.

Offline

#6 2017-10-09 12:28:56

dr34m
Member
Registered: 2016-07-28
Posts: 42

Re: PKGBUILD with prompt script installation

Hi all
thank you very much for your replies and I apologize for my late response.

Following your advice, I decided to create the browser-based package (Firefox first) so I do not put the "solved" tag on the discussion because it will almost certainly need your help for the pkgbuild.

Thanks again and I will make an update with a first version of the package

Offline

#7 2017-10-09 17:53:09

Eschwartz
Bug Wrangler
Registered: 2014-08-08
Posts: 1,176

Re: PKGBUILD with prompt script installation

drcouzelis wrote:

Isn't there a Linux command to send "fake" user input into an interactive script?

...there it is, it's called "expect". But according to here you can also simply do "echo 1 > install.sh".

Of course, if you do something like that, it will be up to the AUR user to modify the PKGBUILD file to select the web browser of choice.

I thoroughly approve of this. big_smile

After overwriting the contents of the file with the text "1", you'll have no choice but to reimplement the script yourself, which is easy, because it is a really simple script.
Also the script never actually installs the messaging hosts binary AFAICT and assumes it will be used from the github checkout. sad sad

mkdir -p "$pkgdir"/usr/lib/mozilla/native-messaging-hosts
sed "s@%%replace%%@/path/to/bukobrow/binary@" browser-hosts/firefox.json  > "$pkgdir"/usr/lib/mozilla/native-messaging-hosts/com.samhh.bukubrow.json
install -Dm755 bukobrow/binary "$pkgdir"/path/to/bukobrow/binary

I suggest using e.g. /usr/lib/bukubrow/bukubrow-messaging as the install path.

...

I did something similar with the AUR package "lastpass", which also uses a native messaging host for chrome and chromium.

Last edited by Eschwartz (2017-10-09 18:00:35)

Offline

#8 2017-10-09 21:56:52

dr34m
Member
Registered: 2016-07-28
Posts: 42

Re: PKGBUILD with prompt script installation

Eschwartz wrote:
drcouzelis wrote:

Isn't there a Linux command to send "fake" user input into an interactive script?

...there it is, it's called "expect". But according to here you can also simply do "echo 1 > install.sh".

Of course, if you do something like that, it will be up to the AUR user to modify the PKGBUILD file to select the web browser of choice.

I thoroughly approve of this. big_smile

After overwriting the contents of the file with the text "1", you'll have no choice but to reimplement the script yourself, which is easy, because it is a really simple script.
Also the script never actually installs the messaging hosts binary AFAICT and assumes it will be used from the github checkout. sad sad

mkdir -p "$pkgdir"/usr/lib/mozilla/native-messaging-hosts
sed "s@%%replace%%@/path/to/bukobrow/binary@" browser-hosts/firefox.json  > "$pkgdir"/usr/lib/mozilla/native-messaging-hosts/com.samhh.bukubrow.json
install -Dm755 bukobrow/binary "$pkgdir"/path/to/bukobrow/binary

I suggest using e.g. /usr/lib/bukubrow/bukubrow-messaging as the install path.

...

I did something similar with the AUR package "lastpass", which also uses a native messaging host for chrome and chromium.


Thanks man!

Before you post i made my PKGBUILD, so please look it and give me a review:

(be kind, it's my second aur package)

pkgname=bukubrow-bin-firefox-git
pkgver=r57.
pkgrel=1
pkgdesc="Bukubrow is a WebExtension for Buku, a command-line bookmark manager"
arch=('x86_64')
url="https://github.com/SamHH/bukubrow"
license=('GPL')
depends=('firefox' 'go' 'zip' )
source=("git://github.com/SamHH/bukubrow")
md5sums=('SKIP') 

pkgver() {
  cd bukubrow
  ( set -o pipefail
    git describe --long 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "r%s.%s" "$(git rev-list --count HEAD)"
  )
}

build() {
  cd "$srcdir/bukubrow"
  make binary-linux-x64 
}

package() {
   cd "$srcdir/bukubrow/release"
   unzip binary-linux-x64.zip
   install -Dm755 bukubrow-linux-x64 "${pkgdir}/usr/bin/bukubrow"
   sed -i -e "s+%%replace%%+/usr/bin/bukubrow+" firefox-host.json
   install -Dm755 firefox-host.json "${pkgdir}/usr/lib/mozilla/native-messaging-hosts/com.samhh.bukubrow.json"
   chmod o+r ${pkgdir}/usr/lib/mozilla/native-messaging-hosts/com.samhh.bukubrow.json
   install -D -m644 $srcdir/bukubrow/LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
   printf ""
   printf "Please install the firefox extension at  https://addons.mozilla.org/en-US/firefox/addon/bukubrow/ "
   printf ""
}

Offline

#9 2017-10-09 22:21:10

slithery
Member
Registered: 2013-12-01
Posts: 1,850

Re: PKGBUILD with prompt script installation

The pkgdesc field shouldn't contain the package name...
https://wiki.archlinux.org/index.php/Pkgbuild#pkgdesc

You shouldn't have those echo commands in package(), For a start they are only called when building the package not installing which I think is what you were trying to do. Things like this should be in a separate .install file.

Last edited by slithery (2017-10-09 22:25:09)


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan

aur - dotfiles

Offline

#10 2017-10-09 22:32:44

Eschwartz
Bug Wrangler
Registered: 2014-08-08
Posts: 1,176

Re: PKGBUILD with prompt script installation

1) printf "r%s.%s" "$(git rev-list --count HEAD)" # missing the second part as per https://wiki.archlinux.org/index.php/VC … elines#Git

2) You several times fail to quote "${srcdir}" and "${pkgdir}" which means you will get errors if you try to build from a directory with spaces in the name, e.g. "~/AUR packages/"

3) install -Dm755 already sets o+r on the file, but that json file does not need to be executable AFAIK.

4) That printf message is wrong, if you really really need to tell the user that, it should be done as a post_install message in an install script. That being said, if you look at my "lastpass" package which I referenced above, you'll see that you can actually install the firefox extension as part of the PKGBUILD into /usr/lib/firefox/browser/extensions/ and just name the installed extension after its internal id which as a webextension will be in manifest.json -- a quick check tells me it is "bukubrow@samhh.com".

5) That Makefile is once again a thing of appalling horror. It hardcodes the 64-bit executable as a call to `env GOOS=linux GOARCH=amd64 go build -i binary/bukubrow.go` but you can simply run that yourself, and while I am no expert on golang, according to the Go package guidelines you shouldn't have to use GOARCH at all. I didn't think golang was stupid enough to require setting cross-compilation variables when building for the current architecture, and it appears I was right. smile

This would allow you to supply both the i686 and x86_64 versions, while simplifying the build since you don't have to allow the Makefile to create a ridiculous zipfile containing the binary. smile

6) You don't need to install the LICENSE file, unless the license is a nonstandard one. See https://wiki.archlinux.org/index.php/PKGBUILD#license
GPL is one of the common licenses provided in the "licenses" package. Note however that "GPL" is a link to the GPL license, and is typically used to refer to GPLv2+. You should use "GPL3" and not bother installing the license file.

7) The pkgname is kind of weird. I suggest using "firefox-extension-bukubrowser-git" as this is not a bin package (bin packages mean upstream precompiled binaries), and to match the typical names of firefox extension PKGBUILDs e.g. "firefox-extension-https-everywhere".

8) Please use "git+https://github.com/SamHH/bukubrow" as the clone url since this takes advantage of the cacerts system to verify the domain name and SSL certificate.
You must add makedepends=('git')

Offline

#11 2017-10-10 19:22:15

dr34m
Member
Registered: 2016-07-28
Posts: 42

Re: PKGBUILD with prompt script installation

Last night I went to sleep thinking I had done a good job with the package, I woke up this morning and found out I was wrong big_smile big_smile big_smile

But let us go into detail:

slithery wrote:

The pkgdesc field shouldn't contain the package name...
https://wiki.archlinux.org/index.php/Pkgbuild#pkgdesc

Thanks, done.

Eschwartz wrote:

1) printf "r%s.%s" "$(git rev-list --count HEAD)" # missing the second part as per https://wiki.archlinux.org/index.php/VC … elines#Git

Fixed

Eschwartz wrote:

2) You several times fail to quote "${srcdir}" and "${pkgdir}" which means you will get errors if you try to build from a directory with spaces in the name, e.g. "~/AUR packages/"

I don't understand this, I quoted every "srcdir" and "pkgdir", please show me where I'm wrong.

Eschwartz wrote:

3) install -Dm755 already sets o+r on the file, but that json file does not need to be executable AFAIK.

Thanks, deleted.

Eschwartz wrote:

4) That printf message is wrong, if you really really need to tell the user that, it should be done as a post_install message in an install script. That being said, if you look at my "lastpass" package which I referenced above, you'll see that you can actually install the firefox extension as part of the PKGBUILD into /usr/lib/firefox/browser/extensions/ and just name the installed extension after its internal id which as a webextension will be in manifest.json -- a quick check tells me it is "bukubrow@samhh.com".

I don't like to install the web-extension for two reason:

1) I prefer to install, manage and update firefox extensions on firefox addon section and not via system package (like gnome-shell)

2) the build of web-extension needs other package (npm, nodejs-webpack) and gives errors on compile.
Plus the author said "not trying to build from (repo) source. I don't think the repo folder structure would work by default."

https://github.com/SamHH/bukubrow/issue … -319081082

Eschwartz wrote:

5) That Makefile is once again a thing of appalling horror. It hardcodes the 64-bit executable as a call to `env GOOS=linux GOARCH=amd64 go build -i binary/bukubrow.go` but you can simply run that yourself, and while I am no expert on golang, according to the Go package guidelines you shouldn't have to use GOARCH at all. I didn't think golang was stupid enough to require setting cross-compilation variables when building for the current architecture, and it appears I was right. smile

Thanks, fixed. Now I call myself the build command.

Eschwartz wrote:

This would allow you to supply both the i686 and x86_64 versions, while simplifying the build since you don't have to allow the Makefile to create a ridiculous zipfile containing the binary. smile

I put "x86" in the "arch" section

Eschwartz wrote:

6) You don't need to install the LICENSE file, unless the license is a nonstandard one. See https://wiki.archlinux.org/index.php/PKGBUILD#license
GPL is one of the common licenses provided in the "licenses" package. Note however that "GPL" is a link to the GPL license, and is typically used to refer to GPLv2+. You should use "GPL3" and not bother installing the license file.

Thanks, fixed

Eschwartz wrote:

7) The pkgname is kind of weird. I suggest using "firefox-extension-bukubrowser-git" as this is not a bin package (bin packages mean upstream precompiled binaries), and to match the typical names of firefox extension PKGBUILDs e.g. "firefox-extension-https-everywhere".

Thanks, fixed

Eschwartz wrote:

8) Please use "git+https://github.com/SamHH/bukubrow" as the clone url since this takes advantage of the cacerts system to verify the domain name and SSL certificate.
You must add makedepends=('git')

Thanks again, fixed


The pkgbuild updated:


# Maintainer: dr34m/KarlFiabeschi 1984itsnow[at]gmail[dot]com

pkgname=firefox-extension-bukubrowser-git
pkgver=r57.
pkgrel=1
pkgdesc="WebExtension for Buku, a command-line bookmark manager"
arch=('x86_64')
url="https://github.com/SamHH/bukubrow"
license=('GPL3')
makedepends=('git')
depends=('firefox' 'go' 'buku')
source=("git+https://github.com/SamHH/bukubrow")
md5sums=('SKIP') 

pkgver() {
  cd bukubrow
  ( set -o pipefail
    git describe --long 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "r%s.%s" "$(git rev-list --count HEAD)"  "$(git rev-parse --short HEAD)"
  )
}

build() {
  cd "$srcdir/bukubrow"
  go build -i binary/bukubrow.go
}

package() {
  cd "$srcdir/bukubrow/"
  install -Dm755 "$srcdir/bukubrow/bukubrow" "${pkgdir}/usr/bin/bukubrow"
  sed -i -e "s+%%replace%%+/usr/bin/bukubrow+" "$srcdir/bukubrow/binary/browser-hosts/firefox.json"
  install -Dm755 "$srcdir/bukubrow/binary/browser-hosts/firefox.json" "${pkgdir}/usr/lib/mozilla/native-messaging-hosts/com.samhh.bukubrow.json"
}

please let me know if i made other mistakes and thank you very much for your suggestions

Offline

#12 2017-10-10 19:32:15

slithery
Member
Registered: 2013-12-01
Posts: 1,850

Re: PKGBUILD with prompt script installation

AFAIK the go package only needs to be in makedepends instead of depends, as once it's compiled it's a self-contained executable.

On an OCD note you should keep the variables in the same order as they appear here (I mean switching the depends and makedepends lines) - but this has no effect on the functionality and can be put down to me being a bit of a d**k smile

Last edited by slithery (2017-10-10 19:44:05)


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan

aur - dotfiles

Offline

#13 2017-10-10 20:11:04

progandy
Member
Registered: 2012-05-17
Posts: 2,359

Re: PKGBUILD with prompt script installation

That looks good, but I would change the description a bit since you do not install the webextension, something like

Messaging Host for the WebExtension for Buku, a command-line bookmark manager

or matching to the description on addons.mozilla.org:

Native binary for the WebExtension for Buku, a command-line bookmark manager

Edit: What do you think about providing the json files for all supported browsers and adding them as optdepends instead of dependencies? In that case you could call the package bukubrowser-messaging-host or something like that.

Edit: It may be also possible to install the bububrow binary as e.g. /usr/lib/bukubrow/bukubrow if running it from a shell is unwanted.

Last edited by progandy (2017-10-10 20:18:04)

Offline

#14 2017-10-10 22:32:04

dr34m
Member
Registered: 2016-07-28
Posts: 42

Re: PKGBUILD with prompt script installation

slithery wrote:

AFAIK the go package only needs to be in makedepends instead of depends, as once it's compiled it's a self-contained executable.

right!

On an OCD note you should keep the variables in the same order as they appear here (I mean switching the depends and makedepends lines) - but this has no effect on the functionality and can be put down to me being a bit of a d**k smile

fixed, and no problem, I'm here to learn

progandy wrote:

That looks good, but I would change the description a bit since you do not install the webextension, something like

Messaging Host for the WebExtension for Buku, a command-line bookmark manager

or matching to the description on addons.mozilla.org:

Native binary for the WebExtension for Buku, a command-line bookmark manager

make sense, modified.

Edit: What do you think about providing the json files for all supported browsers and adding them as optdepends instead of dependencies? In that case you could call the package bukubrowser-messaging-host or something like that.

Sounds good:

# Maintainer: dr34m/KarlFiabeschi 1984itsnow[at]gmail[dot]com

pkgname=bukubrow-messaging-host
pkgver=r57.f48ae47
pkgrel=1
pkgdesc="Native binary for the WebExtension for Buku, a command-line bookmark manager"
arch=('x86' 'x86_64')
url="https://github.com/SamHH/bukubrow"
license=('GPL3')
depends=('go' 'buku')
makedepends=('git' 'unzip')
optdepends=('firefox' 'chrome' 'chronium')
source=("git+https://github.com/SamHH/bukubrow")
md5sums=('SKIP') 

pkgver() {
  cd bukubrow
  ( set -o pipefail
    git describe --long 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "r%s.%s" "$(git rev-list --count HEAD)"  "$(git rev-parse --short HEAD)"
  )
}

build() {
  cd "$srcdir/bukubrow"
  go build -i binary/bukubrow.go
}

package() {
  install -Dm755 "$srcdir/bukubrow/bukubrow" "${pkgdir}/usr/bin/bukubrow"
  #sed
  sed -i -e "s+%%replace%%+/usr/bin/bukubrow+" "$srcdir/bukubrow/binary/browser-hosts/firefox.json"
  sed -i -e "s+%%replace%%+/usr/bin/bukubrow+" "$srcdir/bukubrow/binary/browser-hosts/chrome.json"
  #Firefox
  install -Dm755 "$srcdir/bukubrow/binary/browser-hosts/firefox.json" "${pkgdir}/usr/lib/mozilla/native-messaging-hosts/com.samhh.bukubrow.json"
  #Chrome
  install -Dm755 "$srcdir/bukubrow/binary/browser-hosts/chrome.json" "${pkgdir}/etc/opt/chrome/native-messaging-hosts/com.samhh.bukubrow.json"
  #Chromium
  install -Dm755 "$srcdir/bukubrow/binary/browser-hosts/chrome.json" "${pkgdir}/etc/chromium/native-messaging-hosts/com.samhh.bukubrow.json"
}

my question is: i need to put a "if cycle" like "if chrome dir exist then install else do nothing"?

Edit: It may be also possible to install the bububrow binary as e.g. /usr/lib/bukubrow/bukubrow if running it from a shell is unwanted.

I understand your propose but the other package with go binary i saw have a simple install in /usr/bin, why this is different? (just curiosity)

Offline

#15 2017-10-11 07:23:51

progandy
Member
Registered: 2012-05-17
Posts: 2,359

Re: PKGBUILD with prompt script installation

my question is: i need to put a "if cycle" like "if chrome dir exist then install else do nothing"?

You don't have to. It simply clutters up your filesystem a bit with two unneeded files when the browsers are not installed. If you don't like that, then separate packages might be better.

I understand your propose but the other package with go binary i saw have a simple install in /usr/bin, why this is different? (just curiosity)

As I understand, bukubrow is only started by the browser, so it is not necessary for the binary to be visible in $PATH. There is no other difference, if you prefer /usr/bin, then keep it that way smile

Offline

#16 2017-10-11 20:35:43

Eschwartz
Bug Wrangler
Registered: 2014-08-08
Posts: 1,176

Re: PKGBUILD with prompt script installation

dr34m wrote:

Last night I went to sleep thinking I had done a good job with the package, I woke up this morning and found out I was wrong big_smile big_smile big_smile

Haha. tongue The important thing is that as a new PKGBUILD author you did the right thing and asked for the advice of more experienced individuals, and thereby learned useful tips. smile

dr34m wrote:
Eschwartz wrote:

2) You several times fail to quote "${srcdir}" and "${pkgdir}" which means you will get errors if you try to build from a directory with spaces in the name, e.g. "~/AUR packages/"

I don't understand this, I quoted every "srcdir" and "pkgdir", please show me where I'm wrong.

Well, you did if you look more closely, but it is fixed in your latest PKGBUILD smile:

   chmod o+r ${pkgdir}/usr/lib/mozilla/native-messaging-hosts/com.samhh.bukubrow.json
   install -D -m644 $srcdir/bukubrow/LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
dr34m wrote:
Eschwartz wrote:

4) That printf message is wrong, if you really really need to tell the user that, it should be done as a post_install message in an install script. That being said, if you look at my "lastpass" package which I referenced above, you'll see that you can actually install the firefox extension as part of the PKGBUILD into /usr/lib/firefox/browser/extensions/ and just name the installed extension after its internal id which as a webextension will be in manifest.json -- a quick check tells me it is "bukubrow@samhh.com".

I don't like to install the web-extension for two reason:

1) I prefer to install, manage and update firefox extensions on firefox addon section and not via system package (like gnome-shell)

2) the build of web-extension needs other package (npm, nodejs-webpack) and gives errors on compile.
Plus the author said "not trying to build from (repo) source. I don't think the repo folder structure would work by default."

https://github.com/SamHH/bukubrow/issue … -319081082

As for #1, I suppose that is a personal choice, I prefer managing them in pacman. Granted it won't autoupdate, but I keep on top of updating through pacman, and it makes sure the extension is available in all Firefox profiles for all users, automatically.

As for #2, you would be downloading the copy from addons.mozilla.org rather than building your own, anyway.

dr34m wrote:
Eschwartz wrote:

This would allow you to supply both the i686 and x86_64 versions, while simplifying the build since you don't have to allow the Makefile to create a ridiculous zipfile containing the binary. smile

I put "x86" in the "arch" section

The correct architecture is i686, not x86. See https://wiki.archlinux.org/index.php/PKGBUILD#arch

By the way:

dr34m wrote:
slithery wrote:

AFAIK the go package only needs to be in makedepends instead of depends, as once it's compiled it's a self-contained executable.

right!

This is not fixed...

Also given that you no longer use unzip (because instead of using the Makefile you run go build directly), you can drop the makedepends.

Last edited by Eschwartz (2017-10-11 20:42:56)

Offline

#17 2017-10-12 15:43:18

dr34m
Member
Registered: 2016-07-28
Posts: 42

Re: PKGBUILD with prompt script installation

progandy wrote:

You don't have to. It simply clutters up your filesystem a bit with two unneeded files when the browsers are not installed. If you don't like that, then separate packages might be better.

I'am not sure of what is the best solution sad

As I understand, bukubrow is only started by the browser, so it is not necessary for the binary to be visible in $PATH. There is no other difference, if you prefer /usr/bin, then keep it that way smile

Maybe you are right, what is the "Arch linux standard" path for something like this? usr/lib? but it's not a lib.


As for #1, I suppose that is a personal choice, I prefer managing them in pacman. Granted it won't autoupdate, but I keep on top of updating through pacman, and it makes sure the extension is available in all Firefox profiles for all users, automatically.

As for #2, you would be downloading the copy from addons.mozilla.org rather than building your own, anyway.

Yep, maybe it's personal choice but as i sad before what is the "Arch linux standard" for this? (if exist)

The correct architecture is i686, not x86. See https://wiki.archlinux.org/index.php/PKGBUILD#arch

Fixed, thanks!

This is not fixed...

now is big_smile

Also given that you no longer use unzip (because instead of using the Makefile you run go build directly), you can drop the makedepends.

Yes.

Update version:

# Maintainer: dr34m/KarlFiabeschi 1984itsnow[at]gmail[dot]com

pkgname=bukubrow-messaging-host
pkgver=r57.f48ae47
pkgrel=1
pkgdesc="Native binary for the WebExtension for Buku, a command-line bookmark manager"
arch=('i686' 'x86_64')
url="https://github.com/SamHH/bukubrow"
license=('GPL3')
depends=('buku')
makedepends=('git' 'go' 'go-sqlite3')
optdepends=('firefox' 'chrome' 'chromium')
source=("git+https://github.com/SamHH/bukubrow")
md5sums=('SKIP') 

pkgver() {
  cd bukubrow
  ( set -o pipefail
    git describe --long 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "r%s.%s" "$(git rev-list --count HEAD)"  "$(git rev-parse --short HEAD)"
  )
}

build() {
  cd "$srcdir/bukubrow"
  go build -i binary/bukubrow.go
}

package() {
  install -Dm755 "$srcdir/bukubrow/bukubrow" "${pkgdir}/usr/bin/bukubrow"
  #sed
  sed -i -e "s+%%replace%%+/usr/bin/bukubrow+" "$srcdir/bukubrow/binary/browser-hosts/firefox.json"
  sed -i -e "s+%%replace%%+/usr/bin/bukubrow+" "$srcdir/bukubrow/binary/browser-hosts/chrome.json"
  #Firefox
  install -Dm755 "$srcdir/bukubrow/binary/browser-hosts/firefox.json" "${pkgdir}/usr/lib/mozilla/native-messaging-hosts/com.samhh.bukubrow.json"
  #Chrome
  install -Dm755 "$srcdir/bukubrow/binary/browser-hosts/chrome.json" "${pkgdir}/etc/opt/chrome/native-messaging-hosts/com.samhh.bukubrow.json"
  #Chromium
  install -Dm755 "$srcdir/bukubrow/binary/browser-hosts/chrome.json" "${pkgdir}/etc/chromium/native-messaging-hosts/com.samhh.bukubrow.json"
}

By the way i found a dependency problem.

for proper compilation of bukubrow it need a go dependency: go-sqlite3 (https://github.com/mattn/go-sqlite3)

So i build a pkgbuild as well (reading https://wiki.archlinux.org/index.php/Go … guideline), but i have a problem on package section: i don't know golang so i can't understand if the "go get" command must produce a bin or the src,pkg directory is the only one needing for package.

Thanks for your tips.

# Maintainer: dr34m/KarlFiabeschi 1984itsnow[at]gmail[dot]com

pkgname=go-sqlite3
pkgver=1
pkgrel=1
pkgdesc="sqlite3 driver for go that using database/sql"
arch=('x86_64' 'i686')
url="https://github.com/mattn/go-sqlite3"
license=('MIT')
depends=('go')
makedepends=('git')
options=('!strip' '!emptydirs')
_gourl='github.com/mattn/go-sqlite3'


build() {
  GOPATH="$srcdir" go get -fix -v -x ${_gourl}
}

package() {

  #is this necessary?
  # mkdir -p "$pkgdir/usr/bin"
  # install -p -m755 "$srcdir/bin/go-sqlite3" "$pkgdir/usr/bin"

  mkdir -p "$pkgdir/$GOPATH"
  cp -Rv --preserve=timestamps "$srcdir/"{src,pkg} "$pkgdir/$GOPATH"

  # Package license (if available)
  for f in LICENSE COPYING LICENSE.* COPYING.*; do
    if [ -e "$srcdir/src/$_gourl/$f" ]; then
      install -Dm644 "$srcdir/src/$_gourl/$f" \
        "$pkgdir/usr/share/licenses/$pkgname/$f"
    fi
  done
}

Last edited by dr34m (2017-10-12 15:45:53)

Offline

#18 2017-10-15 03:26:50

Eschwartz
Bug Wrangler
Registered: 2014-08-08
Posts: 1,176

Re: PKGBUILD with prompt script installation

dr34m wrote:
progandy wrote:

You don't have to. It simply clutters up your filesystem a bit with two unneeded files when the browsers are not installed. If you don't like that, then separate packages might be better.

I'am not sure of what is the best solution sad

They are small files, just include them.

dr34m wrote:

As I understand, bukubrow is only started by the browser, so it is not necessary for the binary to be visible in $PATH. There is no other difference, if you prefer /usr/bin, then keep it that way smile

Maybe you are right, what is the "Arch linux standard" path for something like this? usr/lib? but it's not a lib.

This is technically what the libexec directory is for, but Arch uses a unified /usr/lib for that, so just use /usr/lib/bukubrow/bukubrow

dr34m wrote:

As for #1, I suppose that is a personal choice, I prefer managing them in pacman. Granted it won't autoupdate, but I keep on top of updating through pacman, and it makes sure the extension is available in all Firefox profiles for all users, automatically.

As for #2, you would be downloading the copy from addons.mozilla.org rather than building your own, anyway.

Yep, maybe it's personal choice but as i sad before what is the "Arch linux standard" for this? (if exist)

There is no standard. Some people like using packaged extensions, some don't. But extensions which require a native messaging component are even rarer, and the only other one I know of offhand is lastpass. Again, you can look at the lastpass package if you want to see how I handled this situation. Granted it is somewhat biased in favor of what I think is right, but it is also all the precedent I think you are likely to get.

dr34m wrote:

By the way i found a dependency problem.

for proper compilation of bukubrow it need a go dependency: go-sqlite3 (https://github.com/mattn/go-sqlite3)

So i build a pkgbuild as well (reading https://wiki.archlinux.org/index.php/Go … guideline), but i have a problem on package section: i don't know golang so i can't understand if the "go get" command must produce a bin or the src,pkg directory is the only one needing for package.

Thanks for your tips.

# Maintainer: dr34m/KarlFiabeschi 1984itsnow[at]gmail[dot]com

pkgname=go-sqlite3
pkgver=1
pkgrel=1
pkgdesc="sqlite3 driver for go that using database/sql"
arch=('x86_64' 'i686')
url="https://github.com/mattn/go-sqlite3"
license=('MIT')
depends=('go')
makedepends=('git')
options=('!strip' '!emptydirs')
_gourl='github.com/mattn/go-sqlite3'


build() {
  GOPATH="$srcdir" go get -fix -v -x ${_gourl}
}

package() {

  #is this necessary?
  # mkdir -p "$pkgdir/usr/bin"
  # install -p -m755 "$srcdir/bin/go-sqlite3" "$pkgdir/usr/bin"

  mkdir -p "$pkgdir/$GOPATH"
  cp -Rv --preserve=timestamps "$srcdir/"{src,pkg} "$pkgdir/$GOPATH"

  # Package license (if available)
  for f in LICENSE COPYING LICENSE.* COPYING.*; do
    if [ -e "$srcdir/src/$_gourl/$f" ]; then
      install -Dm644 "$srcdir/src/$_gourl/$f" \
        "$pkgdir/usr/share/licenses/$pkgname/$f"
    fi
  done
}

I don't know a lot about golang, so I have no idea what the correct way to handle it is. But what is $GOPATH defined as in package() and where on earth is it installed to?

The Go package guidelines seem to suggest this as the way to do it though: https://wiki.archlinux.org/index.php/Go … xecutables
So maybe I just don't understand golang.

Offline

Board footer

Powered by FluxBB