You are not logged in.

#1 2016-06-02 09:25:47

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 58

[SOLVED] Make package from local source tree

Hi

Is it possible to build a package directly from source tree on local filesystem in simple way? I want use it for development/debug purposes. If no, are there any reasons to not to do this, or just nobody wanted this feature before?
Would it be interesting for anybody if i implement this feature?

Last edited by dimich (2016-06-02 12:11:23)

Offline

#2 2016-06-02 10:36:47

mis
Member
Registered: 2016-03-16
Posts: 234

Re: [SOLVED] Make package from local source tree

You could just use a PKGBUILD and 'makepkg --noextract'

For example

pkgname=new-app
pkgver=0.1
pkgrel=1
pkgdesc=""
arch=('i686' 'x86_64')
license=('GPL')
url=""
source=()
md5sums=('SKIP')

build() {
  cd $pkgname-$pkgver
  make
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
}

This should work if the sources are in ./src/new-app-0.1/ where ./ is the directory that contains the PKGBUILD.
Then build a package with 'makepkg --noextract'

Last edited by mis (2016-06-02 11:03:18)

Offline

#3 2016-06-02 12:12:57

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 58

Re: [SOLVED] Make package from local source tree

mis wrote:

You could just use a PKGBUILD and 'makepkg --noextract'

Thank you! I knew this option but didn't guess to use it with empty "source" array.

Offline

#4 2016-06-02 12:30:53

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 25,106
Website

Re: [SOLVED] Make package from local source tree

Even easier, there is no need to make those subdirs with the pkgver in the name.  Just drop the following in your top-level project folder.  This one assumes there is just a Makefile, but it'd work fine with any other build system:

pkgname=prog
pkgver=1
pkgrel=1
pkgdesc="Your description here"
arch=('x86_64' 'i686')
license=('GPL3')
depends=()

build() {
	cd ..
	make
}

package() {
	cd ..
	make PREFIX=/usr DESTDIR="${pkgdir}" install
}

Then just "makepkg -ef" whenever you want to update the tar.xz.

If you already have a subdirectory "src" with your source files in it, this will not change anything in that directory.  If you don't, it will create an empty "src" directory which you can just ignore or delete as desired.

It will, of course, create a "pkg" directory in the top level folder.  If you happen to keep packaging-related files in a folder called "pkg" you will need to move them as this will overwrite that folder if it exists.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2016-06-02 15:01:39

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 58

Re: [SOLVED] Make package from local source tree

Trilby wrote:

Just drop the following in your top-level project folder.

Excellent! smile How did I miss this solution...

Offline

#6 2016-06-02 15:29:30

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 25,106
Website

Re: [SOLVED] Make package from local source tree

Well it is a bit of a hack.  The "cd .." at the start of the functions is rather odd.  But as of a somewhat recent update, the build and package functions are assured to start in the $srcdir which - notwithstanding unusual configuration - will be ./src relative to the starting directory.

I'd not feel so good about including such odd hakery in something that would be distributed and would need to work on any system.  But for a local build, why not.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2016-06-02 15:47:44

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 58

Re: [SOLVED] Make package from local source tree

Well, I just "cd" to absolute path of source tree and it pretty works for me. The only little disadvantage is to copy package-related files to src/ manually once.
Thank you all for ideas.

Offline

#8 2016-06-02 16:32:44

eschwartz
Trusted User/Bug Wrangler
Registered: 2014-08-08
Posts: 3,936

Re: [SOLVED] Make package from local source tree

You could also use a git+file:/// source url to a local git repository.


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

Offline

#9 2016-06-02 16:34:21

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 58

Re: [SOLVED] Make package from local source tree

Eschwartz wrote:

You could also use a git+file:/// source url to a local git repository.

This solution requires to commit changes to local repository every time before package build.

Offline

Board footer

Powered by FluxBB