You are not logged in.

#1 2013-03-18 02:19:25

Tae
Member
Registered: 2010-08-31
Posts: 32

[SOLVED] Can't understand how `install` command works

Hi there:

I'm trying to make a PKGBUILD for pgModeler, which comes pre-compiled, so I think what I should do is to move the application directory completely to /opt/pgmodeler and make a symbolic link from /usr/bin to the /opt/pgmodeler/start-pgmodeler.sh script. So, i just wrote this:

pkgname=pgmodeler
pkgver=0.4.1
pkgrel=1
pkgdesc="An open source tool for modeling PostgreSQL databases"
arch=('x86_64')
url="http://pgmodeler.com.br"
license=('GPL3')
source=("http://www.pgmodeler.com.br/releases/$pkgname-$pkgver-linux64.tar.gz" "pgmodeler.desktop")
md5sums=('574887c35bc9e0a1bc65f8d4494200bb' '1f3ebda62e941ea7ea17cfb609cc392e')
depends=(libpqxx)

package() {
    install -Dm644 "$srcdir/$pkgname-$pkgver-linux64" "$pkgdir/opt/$pkgname"
    install -Dm644 "$srcdir/$pkgname.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"
    install -Dm644 "$srcdir/$pkgname-$pkgver-linux64/pgmodeler_logo.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"
    chmod 755 "$pkgdir/opt/$pkgname/start-pgmodeler.sh"
    ln -s "$pkgdir/opt/$pkgname/start-pgmodeler.sh" "$pkgdir/usr/bin/$pkgname"
}

But it fails in the first line of the package() function:

[tae@localhost pgmodeler]$ makepkg -s
==> Making package: pgmodeler 0.4.1-1 (Sun Mar 17 23:03:08 CLST 2013)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving Sources...
  -> Found pgmodeler-0.4.1-linux64.tar.gz
  -> Found pgmodeler.desktop
==> Validating source files with md5sums...
    pgmodeler-0.4.1-linux64.tar.gz ... Passed
    pgmodeler.desktop ... Passed
==> Extracting Sources...
  -> Extracting pgmodeler-0.4.1-linux64.tar.gz with bsdtar
==> Removing existing pkg/ directory...
==> Entering fakeroot environment...
==> Starting package()...
install: omitting directory ‘/home/tae/GitHub/pgmodeler/src/pgmodeler-0.4.1-linux64’
==> ERROR: A failure occurred in package().
    Aborting...

This is my first PKGBUILD and I'm trying to decipher how to make it by looking at this files: https://aur.archlinux.org/packages/dr/dropbox/PKGBUILD and https://aur.archlinux.org/packages/op/opcion/PKGBUILD and I never used the install command before so I'm pretty lost.

Thanks beforehand.

Last edited by Tae (2013-03-19 12:44:45)

Offline

#2 2013-03-18 03:13:26

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,130

Re: [SOLVED] Can't understand how `install` command works

install -d "$pkgdir/opt"

and so on?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#3 2013-03-18 03:40:50

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,466

Re: [SOLVED] Can't understand how `install` command works

install doesn't work on entire directories, only individual files. In this case, I would probably just forget install and use cp -r.

The advantage to install is that it can create all of the directories, copy the files, and set the permissions all at once. cp is fine, you just have to do everything yourself.

Last edited by Scimmia (2013-03-18 03:46:36)

Offline

#4 2013-03-18 13:38:26

Snowman
Developer/Forum Fellow
From: Montreal, Canada
Registered: 2004-08-20
Posts: 5,212

Re: [SOLVED] Can't understand how `install` command works

BTW, your symlink is wrong. It should be:
ln -s "/opt/$pkgname/start-pgmodeler.sh" "$pkgdir/usr/bin/$pkgname"

Offline

#5 2013-03-18 13:58:57

SanskritFritz
Member
From: Budapest, Hungary
Registered: 2009-01-08
Posts: 1,923
Website

Re: [SOLVED] Can't understand how `install` command works

Scimmia wrote:

install doesn't work on entire directories, only individual files. In this case, I would probably just forget install and use cp -r.

That is not true. For example firehol PKGBUILD contains the following line:

install -D -m644 examples/*.conf "$pkgdir/etc/firehol/examples/"

you just have to finish the target path with a slash and specify a wildcard for the source.


zʇıɹɟʇıɹʞsuɐs AUR || Cycling in Budapest with a helmet camera || Revised log levels proposal: "FYI" "WTF" and "OMG" (John Barnette)

Offline

#6 2013-03-18 14:05:00

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,868

Re: [SOLVED] Can't understand how `install` command works

SanskritFritz wrote:
Scimmia wrote:

install doesn't work on entire directories, only individual files. In this case, I would probably just forget install and use cp -r.

That is not true. For example firehol PKGBUILD contains the following line:

install -D -m644 examples/*.conf "$pkgdir/etc/firehol/examples/"

you just have to finish the target path with a slash and specify a wildcard for the source.

That command will install all *.conf files in the source, NOT the directory or any subdirectories.

In short, install can work with multiple individual files, not directories.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#7 2013-03-18 14:20:08

tdy
Member
From: Sacremende
Registered: 2008-12-14
Posts: 440

Re: [SOLVED] Can't understand how `install` command works

In fact the trailing slash is irrelevant here because the "$pkgdir/etc/firehol/examples" directory has to exist beforehand in order for the `install -D' command to work properly.

Last edited by tdy (2013-03-18 15:28:48)

Offline

#8 2013-03-18 15:20:38

SanskritFritz
Member
From: Budapest, Hungary
Registered: 2009-01-08
Posts: 1,923
Website

Re: [SOLVED] Can't understand how `install` command works

@Lone_Wolf: True, you're right.
@tdy: Oops, wow, you're right!


zʇıɹɟʇıɹʞsuɐs AUR || Cycling in Budapest with a helmet camera || Revised log levels proposal: "FYI" "WTF" and "OMG" (John Barnette)

Offline

#9 2013-03-18 23:49:10

Tae
Member
Registered: 2010-08-31
Posts: 32

Re: [SOLVED] Can't understand how `install` command works

Thanks to all. I learned a couple of stuff, but I still have no luck. This is what I've tried:

  • I wrote install -d "$pkgdir/opt" in the first line of the package() function before ask, but it didn't make any difference. In fact, I'm not sure what it does (from its man page: treat all arguments as directory names; create all components of the specified directories).

  • I modified the function with all your suggestions, and now it looks:

    package() {
    	cp -R "$srcdir/$pkgname-$pkgver-linux64" "$pkgdir/opt/$pkgname"
    	chmod 644 "$pkgdir/opt/$pkname/"
    	chmod 755 "$pkgdir/opt/$pkgname/start-pgmodeler.sh"
    	install -Dm644 "$srcdir/$pkgname.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"
    	install -Dm644 "$pkgdir/opt/$pkgname/pgmodeler_logo.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"
    	ln -s "/opt/$pkgname/start-pgmodeler.sh" "$pkgdir/usr/bin/$pkgname/"
    }

    but I get:

    $ makepkg -s
    ==> Making package: pgmodeler 0.4.1-1 (lun mar 18 20:33:53 CLST 2013)
    ==> Checking runtime dependencies...
    ==> Checking buildtime dependencies...
    ==> Retrieving Sources...
      -> Found pgmodeler-0.4.1-linux64.tar.gz
      -> Found pgmodeler.desktop
    ==> Validating source files with md5sums...
        pgmodeler-0.4.1-linux64.tar.gz ... Passed
        pgmodeler.desktop ... Passed
    ==> Extracting Sources...
      -> Extracting pgmodeler-0.4.1-linux64.tar.gz with bsdtar
    ==> Removing existing pkg/ directory...
    ==> Entering fakeroot environment...
    ==> Starting package()...
    cp: cannot create directory ‘/home/tae/GitHub/pgModeler/pkg/opt/pgmodeler’: No such file or directory
    ==> ERROR: A failure occurred in package().
        Aborting...

    Here I can't understand why it tries to create /opt/pgmodeler inside the pkg/ directory. For what I found in other PKGBUILDs and from the $pkgdir definition of the PKGBUILD man page (This contains the directory where makepkg bundles the installed package (this directory will become the root directory of your built package)) I though it will be the root directory.

  • So I removed all the $pkgdir from the function and now I get this error:

    mkdir: cannot create directory ‘/opt/pgmodeler/’: Permission denied

:'(

Offline

#10 2013-03-19 00:25:50

tdy
Member
From: Sacremende
Registered: 2008-12-14
Posts: 440

Re: [SOLVED] Can't understand how `install` command works

green = new
red = delete (not sure why you're 644'ing a dir?)
blue = modified (trailing slash here is wrong)

package() {
  install -dm755 "$pkgdir"/{opt,usr/{bin,share/pixmaps}}
  cp -R "$srcdir/$pkgname-$pkgver-linux64" "$pkgdir/opt/$pkgname"
  #chmod 644 "$pkgdir/opt/$pkgname/"
  chmod 755 "$pkgdir/opt/$pkgname/start-pgmodeler.sh"
  install -Dm644 "$srcdir/$pkgname.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"
  install -Dm644 "$pkgdir/opt/$pkgname/pgmodeler_logo.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"
  ln -s "/opt/$pkgname/start-pgmodeler.sh" "$pkgdir/usr/bin/$pkgname"
}

Last edited by tdy (2013-03-19 00:27:00)

Offline

#11 2013-03-19 01:10:20

Tae
Member
Registered: 2010-08-31
Posts: 32

Re: [SOLVED] Can't understand how `install` command works

That worked big_smile So, the trick is to set-up the dirs with install? (install -dm755 "$pkgdir"/{opt,usr/{bin,share/pixmaps}}).

Offline

#12 2013-03-19 02:08:33

tdy
Member
From: Sacremende
Registered: 2008-12-14
Posts: 440

Re: [SOLVED] Can't understand how `install` command works

In this case, yes. The peculiarities of `cp' and `install' are somewhat hard to explain (at least for me).

In short, you don't need to prep a dir if you're installing a single file with the `install -D' command. In all other cases (that I can recall), you need to setup the directories.

Note that /usr/share/applications didn't have to be created beforehand (and now that I look more closely, /usr/share/pixmaps could also be excluded).

Last edited by tdy (2013-03-19 02:09:41)

Offline

Board footer

Powered by FluxBB