0

I have been researching PKGBUILD and makepkg, but I cannot seem to figure out how to simply make a package with already built, local executable files. I need to package them up so that I can easily install them on another Linux machine. I am using Arch Linux.

I basically need to take two executable files from a specific directory, make a package with those files, and then be able to install those files on another Arch Linux machine in the same location that pacman would normally install executables. Not use any source code or anything because the apps are already built.

I know to put the files in the source spot in the PKGBUILD file, but what do I put in the package() function, and do I need a .install file? If so, what do I need in there?

EDIT: This question has been resolved. The best answer has been marked.

closed as unclear what you're asking by jasonwryan, Stephen Rauch, hildred, countermode, user34720 Jun 27 '17 at 10:37

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Put the files in the source array in the PKGBUILD. – jasonwryan Jun 27 '17 at 2:18
  • @jasonwryan Thanks for your response. Yes, but then what do I put in the package function, and do I need an install file? If so, what do I need to put in it. – Russmania101 Jun 27 '17 at 2:23
  • You only need an install file (or hook) if you have to run some script pre- or post installation. In the package function, you just install the pkg in the relevant directory (look at some similar packages in the repos for examples). – jasonwryan Jun 27 '17 at 2:40
  • @jasonwryan I appreciate the help. Any advice on finding a good example repo out of the many that are there? – Russmania101 Jun 27 '17 at 2:42
  • Well, I have no idea what it is that you are actually trying to do, so I can't help much more than I have. Any package which installs a simple executable would probably suffice. – jasonwryan Jun 27 '17 at 2:50
1

Packages can ship with arbitrary files that sit in the same directory as the PKGBUILD file. For your purposes, you can do just that. Within the PKGBUILD file's package() function, you can refer to those files as ${srcdir}/my-executable. The end result might look like this:

# snip!
source=(my-executable)
sha256sums=('foo')

package() {
  install -Dm755 "${srcdir}/my-executable" "${pkgdir}/usr/local/bin/my-executable"
}

You can now make a package with:

updpkgsums && mksrcinfo && makepkg

Note that this approach is only really appropriate for homebrew packages. Do not take this approach if uploading packages to the AUR. The files that ship alongside your PKGBUILD should change infrequently - certainly not with every release. And if your executable is a binary, you will be disallowed from uploading your package to the AUR. (Or it'll work, and someone will find it and ban you.)

For a concrete example, check out mkgmap. It installs a simple wrapper script to /usr/bin/mkgmap. Note that I'm using a few anachronisms, like executing cd "${srcdir}/${pkgname}-${pkgver}" at the head of package().

Once you've created a package, there are several tools available for getting those packages to all your hosts. One nice application-specific tool is pacserve. (Thanks to jasonwryan for the tip.)

Also, consider looking in to a tool like Ansible. If you want the package manager to know about these executables, making a package is great. But if you want to place files in user directories like ~/.local/bin/, configuration management systems may serve you better.

  • Thanks for the answer! May I ask what the -Dm755 is? – Russmania101 Jun 27 '17 at 5:04
  • It's a concise way of writing out -D -m 755. For the exact meaning of the options, see install(1). (Run man 1 install, or find the man page online.) – Ichimonji10 Jun 27 '17 at 14:44
  • @jasonwryan Done. – Ichimonji10 Jun 28 '17 at 20:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.