You are not logged in.

#1 2015-11-24 01:53:44

gps1539
Member
From: Los Gatos, CA
Registered: 2013-11-06
Posts: 133

Need help with my 1st package

I'm trying to create a AUR package for a python script I wrote and pushed to github.  I could do with some help on what I'm doing wrong in the PKGBUILD below, thanks in advance.

# Maintainer: Graham Smith <gps1539 at gmail dot com>

pkgname=stock_quote
pkgver=0.1
pkgrel=1
pkgdesc="python script for getting stock quotes from yahoo and calculting gains and losses"
arch=('any')
license=('MIT')
url='https://github.com/gps1539/stock_quote'
depends=('python')
makedepends=('git')
source=("https://github.com/gps1539/stock_quote.git")
md5sums=('SKIP')

pkgver() {
   cd "$pkgname"
   printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

package()
{
      install -d "$pkgdir/usr/bin/"
      install -m755 "$srcdir/$pkgname/src/"{stock_quote.py} "$pkgdir/usr/bin"
}

When I test it with makepkg it seems to pull from git, but then fails.

makepkg
==> Making package: stock_quote 0.1-1 (Mon Nov 23 17:55:41 PST 2015)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Found stock_quote.git
==> Validating source files with md5sums...
    stock_quote.git ... Skipped
==> Extracting sources...
==> Starting pkgver()...
/home/grahams/temp/stock_quote/PKGBUILD: line 16: cd: stock_quote: No such file or directory
==> Removing existing $pkgdir/ directory...
==> Entering fakeroot environment...
==> Starting package()...
install: cannot stat ‘/home/grahams/temp/stock_quote/src/stock_quote/src/{stock_quote.py}’: No such file or directory
==> ERROR: A failure occurred in package().
    Aborting...

Last edited by gps1539 (2015-11-24 01:57:27)

Offline

#2 2015-11-24 02:21:28

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

Re: Need help with my 1st package

What's with the braces?

Offline

#3 2015-11-24 04:08:14

gps1539
Member
From: Los Gatos, CA
Registered: 2013-11-06
Posts: 133

Re: Need help with my 1st package

Thanks for the reply.

The braces are copied from an example I found, my error, what should I use? Doesn't it fail before that at line 16?

I'm a packaging rookie. Are there simple examples of how to create a package from git that extract the binary and install it?

Offline

#4 2015-11-24 04:11:38

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Need help with my 1st package

Two things.

1) You did not specify a git protocol. makepkg does not know that an https://github.com url is for cloning.
What happened is that it downloaded https://github.com/gps1539/stock_quote.git as an HTTP resource, and you probably didn't want an HTML page. wink
Instead, use the git:// clone url, or use "git+https://github.com/usernbane/repo"
See: https://wiki.archlinux.org/index.php/VC … CS_sources for more details.

2) Once you fix that, you will need to remove the "src" component of the `install` command -- your repo doesn't have a "src" subdirectory. Additionally, as @Scimmia said, braces will be treated as a literal if they don't expand to multiple files (and you didn't make use of brace expansion).

You are trying to install a file called "repo-dir/src/{stock_quote.py}" when you should be installing a file called "repo-dir/stock_quote.py"

...

Finally, a couple personal nitpicks:
You should use a single `install -Dm755 $src_file $dest_file` instead of splitting it into two actions.
Either use "srcdir" always, or never use it, either way makepkg will start each function in "$srcdir". But don't mix the two conventions in one PKGBUILD.

Last edited by eschwartz (2015-11-24 04:15:20)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#5 2015-11-24 19:55:23

gps1539
Member
From: Los Gatos, CA
Registered: 2013-11-06
Posts: 133

Re: Need help with my 1st package

Many thanks, I now have working package. I'd be grateful for a quick review before I post?

# Maintainer: Graham Smith <gps1539 at gmail dot com>

pkgname=stock_quote
pkgver=0.1
pkgrel=1
pkgdesc="python script for getting stock quotes from yahoo and calculting gains and losses"
arch=('any')
license=('MIT')
url='https://github.com/gps1539/stock_quote'
depends=('python')
makedepends=('git')
source=("https://raw.githubusercontent.com/gps1539/stock_quote/master/stock_quote.py")
md5sums=('9f2ce0a313a88dc6cc7d160abfbfde83')

package()
{
   install -d "$pkgdir/usr/bin/"
   install -m755 "stock_quote.py" "$pkgdir/usr/bin/"
}

Last edited by gps1539 (2015-11-24 20:22:24)

Offline

#6 2015-11-24 20:44:14

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

Re: Need help with my 1st package

You only download 1 single file now, and the package will fail with a validation error whenever you change that file.

Also you should include a license file.

https://wiki.archlinux.org/index.php/Arch_packaging_standards#Licenses wrote:

The MIT, BSD, zlib/libpng and Python licenses are special cases and cannot be included in the 'common' licenses pkg. For the sake of the license variable, it is treated like a common license (license=('BSD'), license=('MIT'), license=('ZLIB') or license=('Python')) but for the sake of the filesystem, it is a custom license, because each one has its own copyright line. Each MIT, BSD, zlib/libpng or Python licensed package should have its unique license stored in /usr/share/licenses/$pkgname/.


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 2015-11-25 02:07:36

gps1539
Member
From: Los Gatos, CA
Registered: 2013-11-06
Posts: 133

Re: Need help with my 1st package

Thanks @Lone_Wolf

I see very few examples of adding a license file. If I went with GPL (I'm the author), do I need to add it or just use

 license=('GPL') 

Last edited by gps1539 (2015-11-25 02:08:16)

Offline

#8 2015-11-25 02:26:25

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Need help with my 1st package

Because many packages are licensed under one of the common licenses, they only require the license=('some_license').

But the MIT is not a common license, since each one is slightly different.

Either include your license with:

install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

Or use a "common" license.


Either way, your GitHub repo doesn't mention a license at all.



EDIT: This is all mentioned in the Wiki link from above...

Last edited by eschwartz (2015-11-25 02:29:06)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#9 2015-11-25 05:28:42

gps1539
Member
From: Los Gatos, CA
Registered: 2013-11-06
Posts: 133

Re: Need help with my 1st package

Using GPLv3 and added that to my github repo

Thanks for everyone's help on losing my packaging virginity

Offline

Board footer

Powered by FluxBB