You are not logged in.

#1 2018-12-22 07:10:48

junfengqiao
Member
Registered: 2018-07-24
Posts: 4

[SOLVED] Is it possible to generate .INSTALL on the fly?

Hello everyone, I am currently writing my first `PKGBUILD'.

The original software contains a bash script which installs itself in a directory and checks some conditions to make sure it can run smoothly.
I think this script combines what should be done in the `package()' of `PKGBUILD' and `post_install()' of `.INSTALL'.

I want to reuse this bash script, so I have tried the following steps:
  1. write an empty `a.install' file
  2. in `PKGBUILD', write `install=a.install'
  3. `cat' part of the original bash script to the `a.install', in the `prepare()' of `PKGBUILD'

However, in the resulting `.pkg.tar.xz', the `.INSTALL' is still empty, while the content of `a.install' in the `src' directory is what I want.

So, my question is, is it possible to generate the `.INSTALL' file in the `PKGBUILD'?

Directly writing part of the code in `a.install' can make the software functional, but I am just curious.

Thanks in advance!

Last edited by junfengqiao (2018-12-25 15:32:22)

Offline

#2 2018-12-22 07:13:03

Scimmia
Bug Wrangler
Registered: 2012-09-01
Posts: 7,101

Re: [SOLVED] Is it possible to generate .INSTALL on the fly?

Honestly, it doesn't sound like something you should be doing at all.

Offline

#3 2018-12-22 14:44:18

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

Re: [SOLVED] Is it possible to generate .INSTALL on the fly?

junfengqiao wrote:

Directly writing part of the code in `a.install' can make the software functional, but I am just curious.

So you experimented, and now you have your answer.

Besides, even if what you wanted to do could work, it would be silly.  You can create the content of a.install once and be done with it, or you can make it "dyndamically" regenerate the exact same content repeatedly counltess many times on countless many different machines in a ugly, non-conforming, and error-prone way.  Why would you want to do the latter?

But to avoid an X-Y question, what is this software, and what do you think needs to be in the install file?

The reason this failed should be clear, however, from this statement:

junfengqiao wrote:

However, in the resulting `.pkg.tar.xz', the `.INSTALL' is still empty, while the content of `a.install' in the `src' directory is what I want.

The .INSTALL file should not be in the src directory.  That's not where makepkg will look for it when building the package.

Last edited by Trilby (2018-12-22 14:52:31)


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

Offline

#4 2018-12-22 16:52:26

Slithery
Forum Moderator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 3,070

Re: [SOLVED] Is it possible to generate .INSTALL on the fly?

That's a terrible idea. Instead you should translate the provided script into a proper PKGBUILD.

Please tell us what you're trying to install and post the script otherwise we're all just stumbling round in the dark guessing at the best solution.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#5 2018-12-24 02:50:53

junfengqiao
Member
Registered: 2018-07-24
Posts: 4

Re: [SOLVED] Is it possible to generate .INSTALL on the fly?

Hello, many thanks to all your replies.

In fact, the original software is somewhat proprietary, it is distributed by an organization and only licensed users can get a copy of the original install script and binaries from the administrator. So I am afraid that I cannot directly post that install file on the internet.

While I want my `pacman' to manage the software. Besides, this software depends on `ifconfig` in the `net-tools` package, which is not preinstalled in archlinux anymore. I spent quite some time to figure out this dependency because this proprietary software is hard to debug but is necessary when using the services provided by that organization.

So, for license considerations, I think I should not directly copy and paste part of the install script provided by the organization into the `a.install` file. My PKGBUILD contains many `sed` and `tail -n` to convert the original install script into `a.install`, so as to avoid any copy and paste of the install script of the original software.

There are around several thousand users using the services provided by that organization, and in terms of archlinux users in this user group, frankly speaking, I guess maybe no more than a hundred. But I want to share my experience with those archlinux users, help them avoid the struggles I encountered and at the same time avoid any license problems.

Thank you again for all your help, and Happy Holidays and all the best to you in the year to come!

Offline

#6 2018-12-24 03:21:44

eschwartz
Trusted User/Bug Wrangler
Registered: 2014-08-08
Posts: 2,696

Re: [SOLVED] Is it possible to generate .INSTALL on the fly?

It seems odd that even the instructions to install the proprietary software are themselves banned from redistribution.

Question: does all this post-install stuff actually need to be run as root? Is it really doing things that cannot be done better from the package() step of the PKGBUILD itself?

It's difficult to give good advice without even a general understanding of what problem domain the install script is trying to solve.

...

At any rate, makepkg does not look for the install script from the "${srcdir}" but instead looks for it next to the PKGBUILD. You could overwrite the original file, but that's a bit awkward plus results in potentially distributing the wrong thing. Another potential option is to have the PKGBUILD install the script that needs to run, as part of the packaged files, and then have the install script execute this script in turn. This is especially handy if it is something which might need to be run multiple times, or should be run as some user other than root, since you can use:

runuser -u appdaemonuser /usr/share/appname/post-install.sh

or something.


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

Offline

#7 2018-12-25 06:59:08

junfengqiao
Member
Registered: 2018-07-24
Posts: 4

Re: [SOLVED] Is it possible to generate .INSTALL on the fly?

eschwartz wrote:

It seems odd that even the instructions to install the proprietary software are themselves banned from redistribution.

The original install script of this proprietary software is written by a staff in that organization. Maybe I should contact him to know whether I can redistribute the original install script or not. Before I get the permission to redistribute, I want to avoid any copy and paste of their code.

eschwartz wrote:

Question: does all this post-install stuff actually need to be run as root? Is it really doing things that cannot be done better from the package() step of the PKGBUILD itself?

It's difficult to give good advice without even a general understanding of what problem domain the install script is trying to solve.

The post-install step contains one simple task: Changing some files' permissions (these files serve as locks) to ensure every user can access these locks. The package is installed in /opt, but the original install script contains something like this:

LOCK=/tmp/xxx.lock
if [ -f $LOCK ]
then
        chmod 0777 $LOCK
fi

I guess this part of the code is useful only when someone accidentally creates a file with the name 'xxx.lock' in /tmp before installing the package.
In normal case this `chmod` is useless. I just obey the original install script so I put it in the '.install' file.

eschwartz wrote:

...

At any rate, makepkg does not look for the install script from the "${srcdir}" but instead looks for it next to the PKGBUILD. You could overwrite the original file, but that's a bit awkward plus results in potentially distributing the wrong thing. Another potential option is to have the PKGBUILD install the script that needs to run, as part of the packaged files, and then have the install script execute this script in turn. This is especially handy if it is something which might need to be run multiple times, or should be run as some user other than root, since you can use:

runuser -u appdaemonuser /usr/share/appname/post-install.sh

or something.

Wow, the second solution is awesome! This solves my problem as well as satisfies my curiosity, thank you!

Offline

#8 2018-12-25 07:10:03

eschwartz
Trusted User/Bug Wrangler
Registered: 2014-08-08
Posts: 2,696

Re: [SOLVED] Is it possible to generate .INSTALL on the fly?

junfengqiao wrote:
eschwartz wrote:

It seems odd that even the instructions to install the proprietary software are themselves banned from redistribution.

The original install script of this proprietary software is written by a staff in that organization. Maybe I should contact him to know whether I can redistribute the original install script or not. Before I get the permission to redistribute, I want to avoid any copy and paste of their code.

eschwartz wrote:

Question: does all this post-install stuff actually need to be run as root? Is it really doing things that cannot be done better from the package() step of the PKGBUILD itself?

It's difficult to give good advice without even a general understanding of what problem domain the install script is trying to solve.

The post-install step contains one simple task: Changing some files' permissions (these files serve as locks) to ensure every user can access these locks. The package is installed in /opt, but the original install script contains something like this:

LOCK=/tmp/xxx.lock
if [ -f $LOCK ]
then
        chmod 0777 $LOCK
fi

I guess this part of the code is useful only when someone accidentally creates a file with the name 'xxx.lock' in /tmp before installing the package.
In normal case this `chmod` is useless. I just obey the original install script so I put it in the '.install' file.

That's decidedly odd. makepkg should not be creating a package that packages a file called /tmp/xxx.lock, and if it did then the file will be deleted as soon as you reboot.

Is this file something created when the software runs? If so, chmod'ing it in the post-install is simply insufficient, as during the next reboot, the file will be deleted then presumably recreated by the first user to use the software -- who then ends up with an exclusive lock, but only until the next reboot.

I'm taking a stab in the dark here and assuming the software tries to create an exclusive lock on itself to prevent running multiple times. If this is so, it needs to create a lockfile that incorporates the username as well. This may require patching the sources/binaries.


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

Offline

#9 2018-12-25 10:40:10

junfengqiao
Member
Registered: 2018-07-24
Posts: 4

Re: [SOLVED] Is it possible to generate .INSTALL on the fly?

eschwartz wrote:
junfengqiao wrote:
eschwartz wrote:

It seems odd that even the instructions to install the proprietary software are themselves banned from redistribution.

The original install script of this proprietary software is written by a staff in that organization. Maybe I should contact him to know whether I can redistribute the original install script or not. Before I get the permission to redistribute, I want to avoid any copy and paste of their code.

eschwartz wrote:

Question: does all this post-install stuff actually need to be run as root? Is it really doing things that cannot be done better from the package() step of the PKGBUILD itself?

It's difficult to give good advice without even a general understanding of what problem domain the install script is trying to solve.

The post-install step contains one simple task: Changing some files' permissions (these files serve as locks) to ensure every user can access these locks. The package is installed in /opt, but the original install script contains something like this:

LOCK=/tmp/xxx.lock
if [ -f $LOCK ]
then
        chmod 0777 $LOCK
fi

I guess this part of the code is useful only when someone accidentally creates a file with the name 'xxx.lock' in /tmp before installing the package.
In normal case this `chmod` is useless. I just obey the original install script so I put it in the '.install' file.

That's decidedly odd. makepkg should not be creating a package that packages a file called /tmp/xxx.lock, and if it did then the file will be deleted as soon as you reboot.

Is this file something created when the software runs? If so, chmod'ing it in the post-install is simply insufficient, as during the next reboot, the file will be deleted then presumably recreated by the first user to use the software -- who then ends up with an exclusive lock, but only until the next reboot.

I'm taking a stab in the dark here and assuming the software tries to create an exclusive lock on itself to prevent running multiple times. If this is so, it needs to create a lockfile that incorporates the username as well. This may require patching the sources/binaries.

Yes, I totally agree with you. Since I don't have access to the source code, I cannot know the inner intention of this lock.
In all, thanks for your kind help! Now I've got a clearer understanding of PKGBUILD.

Offline

#10 2018-12-25 14:56:36

2ManyDogs
Forum Moderator
Registered: 2012-01-15
Posts: 2,243

Re: [SOLVED] Is it possible to generate .INSTALL on the fly?

junfengqiao wrote:

Wow, the second solution is awesome! This solves my problem as well as satisfies my curiosity, thank you!

Please remember to mark your thread [SOLVED] (edit the title of your first post).

Offline

Board footer

Powered by FluxBB