You are not logged in.

#1 2017-09-30 19:37:19

junebug12851
Member
Registered: 2017-09-30
Posts: 3

Is it possible to have a package for a single script?

Hi,

The "npm" team on github does extremely frequent updates so I wrote a simple script that checks your npm version with the latest one online, that is, the latest release version out of beta and thats production ready and if found instructs npm to update itself to that version explicitly. npm does all the work, my script just tells it to update if it finds it needs to. It would also serve the issue where updating npm through the tool yourself puts it in conflict with the npm package from the repository as it can lag behind since updates are so frequent.

Is this possible in a package and one I can eventually upload to AUR, like a package that runs a script to check for any updates to inform the package manager if there is one or not and that runs another script that does the actual upgrading which is simply to tell npm to update to that version explicitly.

I've rummaged around and am very confused, I've never built a linux package before for any distro but this is all I have so far by spending all day looking at different docs:

pkgname=npm-release
pkgver=2017.09.29
pkgrel=1
epoch=0
pkgdesc="Ensures your npm is at the latest full-release version online"
arch=('any')
url=""
license=('Apache')
groups=()
depends=(
    'nodejs'
)
makedepends=()
checkdepends=()
optdepends=()
provides=()
conflicts=()
replaces=(
    'npm'
)
backup=()
options=()
install=
changelog=
source=("check.sh")
noextract=()
md5sums=()
validpgpkeys=()

prepare() {

}

build() {

}

check() {

}

package() {

}

The docs for many of the functions seem to be based on actual code that needs installing or building and stuff like with make but my package isn't any of that as it doesn't do anything itself apart from triggering npm's own update when needed. I found something related to a function for the package version but again it seems very vague, most help I find online provides help if your package has files of its own that it will do something with.

Offline

#2 2017-09-30 20:38:46

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: Is it possible to have a package for a single script?

It is possible. You don't need to use make or other build system. Simply create the install path and install the script to that location with correct permissions.

Here's an example: https://git.archlinux.org/svntogit/comm … ckages/bar

Although, one could argue whether creating a package for such a simple single-file script is worth the effort. You could just upload the script to e.g. github for people to download directly, instead of downloading the source PKGBUILD and building it by hand. But it's up to your decision.

Offline

#3 2017-09-30 20:41:53

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Is it possible to have a package for a single script?

ooo wrote:

Although, one could argue whether creating a package for such a simple single-file script is worth the effort. You could just upload the script to e.g. github for people to download directly, instead of downloading the source PKGBUILD and building it by hand.

This.

But if you do want to create a PKGBUILD, see the guidelines: https://wiki.archlinux.org/index.php/Ar … _standards


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#4 2017-09-30 21:46:06

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

Re: Is it possible to have a package for a single script?

I'd second/third the above - I don't see a point in a PKGBUILD.  But if you make one, get rid of all the empty variables (and functions, but package() should not be empty).  Then set the source to the actual location of where the source can be obtained, not just the filename.


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

Offline

#5 2017-09-30 22:08:33

junebug12851
Member
Registered: 2017-09-30
Posts: 3

Re: Is it possible to have a package for a single script?

I wanted to do an AUR package because I wanted the standard system update to detect the update automatically and include it with the list of other updates, this saves the user from managing separate updates with alternate tools and such and npm is a package so I'd like to keep in managed in the package system.

Theres no source where it can be obtained, its just a script that tells another package to update to a particular version. Do you mean my script as the source?

Thanks for all the replies, they're helping me figure this out

Offline

#6 2017-09-30 22:54:49

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

Re: Is it possible to have a package for a single script?

junebug12851 wrote:

I wanted to do an AUR package because I wanted the standard system update to detect the update automatically

Detect the upate of what automatically?  Your script?  Is you script being editted regularly?

junebug12851 wrote:

Theres no source where it can be obtained, its just a script...

The script must be obtained from somewhere, that's what I'm talking about.  If you make a PKGBUILD, that PKGBUILD must download "check.sh" from somewhere.

Also, you realize AUR packages are not updated with the rest of the system.  They are updated when the user runs makepkg again on that PKGBUILD.

I can't help but suspect what you really want is a pacman hook: something that will run every time another package is updated.  Is that the case?  What exactly is in "check.sh"?

Also, I'm pretty sure your package would not 'replace' npm.  "replaces" in a PKGBUILD means that your package would take the place of npm.

Last edited by Trilby (2017-09-30 22:58:04)


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

Offline

#7 2017-09-30 23:26:51

junebug12851
Member
Registered: 2017-09-30
Posts: 3

Re: Is it possible to have a package for a single script?

The script wouldn't need to be updated very often, it only checks for a new update online and instructs npm to update to that version. So when NPM rolls out a new update which they do really often, weekly, and sometimes daily. I want the system to detect this update and and update npm. I said replace npm because npm doesn't belong in the system package manager, npm is its own package manager, I want the pacman to stop tracking and dealing with npm because if you update npm to the latest it screws up pacman and you get a bunch of "File Exists" errors simply because there are 2 package managers managing the same package.

Since npm is the official package manager for itself, pacman needs to only install it but not keep track of all the internal files so it can be uninstalled through pacman but not upgradable through pacman leaving upgrades to npm who would do it better since an upgrade may cause other npm packages to be downloaded which pacman wouldn't know anything about.

Honestly this whole thing has gotten more complicated than I initially planned, but I didn't consider a pacman hook which is a good idea but it would only create probelsm as stated above where using npm to upgrade itself natively throws off pacman because you have 2 package managers managing the same package. So I would need to replace the npm package with my own that would install npm with a special update script and not register the files with pacman so it wouldn't track the specific npm files and, wow, this has gotten complicated.

Thank you for all your help though, its my first time posting but the community has been super helpful.

Offline

#8 2017-09-30 23:38:17

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

Re: Is it possible to have a package for a single script?

junebug12851 wrote:

pacman needs to only install it but not keep track of all the internal files so it can be uninstalled through pacman...

This can't work.  Either you manage it through pacman or not.  If npm is "uninstalled through pacman" then it is gone, it is no more, it has ceased to be, it is an ex-package-manager.

In any case, "replaces" is still wrong.  You could list npm under "conflicts" though that's not strictly correct either.


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

Offline

#9 2017-10-02 18:14:50

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

Re: Is it possible to have a package for a single script?

It sounds like what you really want is a dummy package that "provides" and "conflicts" npm for packages that need npm to run, but which, instead of containing npm itself only contains your script which installs or updates npm. Although personally I don't see why a package manager shouldn't be managed via a package manager, given that pacman manages pacman as well, and even npm is still managed by, well, npm.


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

Offline

Board footer

Powered by FluxBB