You are not logged in.

#1 2021-08-20 06:51:19

followait
Banned
Registered: 2019-11-01
Posts: 58

[SOLVED] How for `makepkg -i` to ask for password in cmake?

add_custom_target(makepkg_and_install
                  COMMAND cd ${CONFIGURED_FILES_ROOT}/installer/aur/for-cmake
                  COMMAND makepkg -i)

In vscode, error as below

[build] ==> Installing package cppjieba with pacman -U...
[build] sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
[build] sudo: a password is required
[build] ==> WARNING: Failed to install built package(s).

If manually run as in the custom target makepkg_and_install, it freezes after the zst file is genereated.

Question:
Is there anyway for cmake to ask for password just when installing in this case?

BTW, I think OS native pkg manger is the most robust and clean way for installation & uninstallation.
CMake's offical way for uninstallation using `install_manifest.txt` doesn't remove empty folders, and CMAKE_BINARY_DIR tends to change after installation, especially when developing.
Now CMake doesn't provide a universal way for clean uninstallation, so I choose to use aur for archlinux, is there any better alternative?

Last edited by followait (2021-08-21 03:50:17)

Offline

#2 2021-08-20 08:04:14

a821
Member
Registered: 2012-10-31
Posts: 381

Re: [SOLVED] How for `makepkg -i` to ask for password in cmake?

The whole concept sounds to me like a really really bad idea. Would you mind explaining the reason behind?

Offline

#3 2021-08-20 08:24:27

followait
Banned
Registered: 2019-11-01
Posts: 58

Re: [SOLVED] How for `makepkg -i` to ask for password in cmake?

a821 wrote:

The whole concept sounds to me like a really really bad idea. Would you mind explaining the reason behind?

Because I want a clean uninstallation, and it's better not to depend on what's in CMAKE_BINARY_DIR, which is temporary.

I've posted the drawbacks for the cmake offical method (https://gitlab.kitware.com/cmake/commun … with-cmake).

A standalone PKGBUILD works, but it needs a new build.

Last edited by followait (2021-08-20 10:18:07)

Offline

#4 2021-08-20 09:39:23

progandy
Member
Registered: 2012-05-17
Posts: 5,190

Re: [SOLVED] How for `makepkg -i` to ask for password in cmake?

Normally, you set up cmake to install directly into the filesystem, but with an install prefix. then you write a pkgbuild that calls cmake and sets the prefix to the packaging directory.


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#5 2021-08-20 10:25:02

followait
Banned
Registered: 2019-11-01
Posts: 58

Re: [SOLVED] How for `makepkg -i` to ask for password in cmake?

progandy wrote:

Normally, you set up cmake to install directly into the filesystem, but with an install prefix. then you write a pkgbuild that calls cmake and sets the prefix to the packaging directory.

It works, but it can't utilize the already built results, it takes extra time, cpu and disk spaces.
When developing, it is common to install/uninstall a package, clean unstallation and efficient makepkg is more important.

Offline

#6 2021-08-20 10:36:29

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

Re: [SOLVED] How for `makepkg -i` to ask for password in cmake?

It works, but it can't utilize the already built results,

Enabling ccache in makepkg.conf helps a lot with that and works with all build systems, not just cmake .

Also check https://wiki.archlinux.org/title/Makepk … and_tricks .


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 2021-08-20 11:02:52

followait
Banned
Registered: 2019-11-01
Posts: 58

Re: [SOLVED] How for `makepkg -i` to ask for password in cmake?

Lone_Wolf wrote:

It works, but it can't utilize the already built results,

Enabling ccache in makepkg.conf helps a lot with that and works with all build systems, not just cmake .

Also check https://wiki.archlinux.org/title/Makepk … and_tricks .

Good tool, but still needs to call makepkg -i manually.

Offline

#8 2021-08-20 11:33:44

a821
Member
Registered: 2012-10-31
Posts: 381

Re: [SOLVED] How for `makepkg -i` to ask for password in cmake?

calling makepkg -i inside cmake makes no sense

Offline

#9 2021-08-20 13:04:56

progandy
Member
Registered: 2012-05-17
Posts: 5,190

Re: [SOLVED] How for `makepkg -i` to ask for password in cmake?

For development you could write a PKGBUILD that reuses your development tree and remember to call it with the -"e" flag (use a small script to call it?).


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#10 2021-08-20 13:10:12

followait
Banned
Registered: 2019-11-01
Posts: 58

Re: [SOLVED] How for `makepkg -i` to ask for password in cmake?

a821 wrote:

calling makepkg -i inside cmake makes no sense

trying to encapluate it by cmake

Offline

#11 2021-08-20 13:21:17

followait
Banned
Registered: 2019-11-01
Posts: 58

Re: [SOLVED] How for `makepkg -i` to ask for password in cmake?

progandy wrote:

For development you could write a PKGBUILD that reuses your development tree and remember to call it with the -"e" flag (use a small script to call it?).

I have already use configure_file to generate PKGBUILD to utilize things in CMAKE_BINARY_DIR
Do you mean cmake -E? It's mainly for crossplatform command like copy / copy_directory / echo, it might not help.

Last edited by followait (2021-08-20 13:21:35)

Offline

#12 2021-08-20 13:30:20

followait
Banned
Registered: 2019-11-01
Posts: 58

Re: [SOLVED] How for `makepkg -i` to ask for password in cmake?

It seems that cpack supports aur pkg since version 3.16, https://cmake.org/cmake/help/git-stage/ … chive.html, hope .tar.zst in the doc is the same for aur pkg.

Last edited by followait (2021-08-20 14:49:21)

Offline

#13 2021-08-20 15:17:30

loqs
Member
Registered: 2014-03-06
Posts: 17,321

Re: [SOLVED] How for `makepkg -i` to ask for password in cmake?

followait wrote:
progandy wrote:

For development you could write a PKGBUILD that reuses your development tree and remember to call it with the -"e" flag (use a small script to call it?).

I have already use configure_file to generate PKGBUILD to utilize things in CMAKE_BINARY_DIR
Do you mean cmake -E? It's mainly for crossplatform command like copy / copy_directory / echo, it might not help.

Not cmake -e,  makepkg -e so sources are not extracted and prepare is skipped.  build() calls make / ninja which should then only rebuild what has changed.

Offline

#14 2021-08-21 01:15:11

followait
Banned
Registered: 2019-11-01
Posts: 58

Re: [SOLVED] How for `makepkg -i` to ask for password in cmake?

loqs wrote:

makepkg -e so sources are not extracted and prepare is skipped.  build() calls make / ninja which should then only rebuild what has changed.

It is convenient, thanks.

Offline

#15 2021-08-21 01:54:42

followait
Banned
Registered: 2019-11-01
Posts: 58

Re: [SOLVED] How for `makepkg -i` to ask for password in cmake?

A way in cmake is to use CPack External Generator (https://cmake.org/cmake/help/latest/cpa … -generator).
I think it'll save extra build times.

Offline

#16 2021-08-21 02:16:13

thiagowfx
Member
Registered: 2013-07-09
Posts: 586

Re: [SOLVED] How for `makepkg -i` to ask for password in cmake?

It's a bit confusing what you're trying to do, but why do you need to call `makepkg -i`? Did you consider breaking that down into two steps?

1) call `makepkg`
2) call `pacman -U <pkgname>` (or `sudo pacman -U <pkgname>`)

You can't use sudo with `makepkg` but you can with `pacman`.

Still, it seems better (cleaner responsibilities) not to mix and match package manager (pacman) with build system (cmake). I'd say, either:

1) fully use cmake to manage your installation (i.e. `cmake .` then `make` then `make install`)
2) OR use pacman to manage your installation (i.e. `cmake` + `make` in `build()` in your `PKGBUILD` then `make install` in `install()` in the `PKGBUILD`).

Last edited by thiagowfx (2021-08-21 02:16:47)

Offline

#17 2021-08-21 03:47:07

followait
Banned
Registered: 2019-11-01
Posts: 58

Re: [SOLVED] How for `makepkg -i` to ask for password in cmake?

thiagowfx wrote:

It's a bit confusing what you're trying to do, but why do you need to call `makepkg -i`? Did you consider breaking that down into two steps?

1) call `makepkg`
2) call `pacman -U <pkgname>` (or `sudo pacman -U <pkgname>`)

You can't use sudo with `makepkg` but you can with `pacman`.

I've considered breaking `makepkg -i` down, but the <pkgname> varies.

thiagowfx wrote:

Still, it seems better (cleaner responsibilities) not to mix and match package manager (pacman) with build system (cmake). I'd say, either:

1) fully use cmake to manage your installation (i.e. `cmake .` then `make` then `make install`)
2) OR use pacman to manage your installation (i.e. `cmake` + `make` in `build()` in your `PKGBUILD` then `make install` in `install()` in the `PKGBUILD`).

Yes, should not mix. My first idea is to override `cmake --install .`, but it can't be done by interface of cmake, and the native implementation for `cmake --install` might still be executed accidentally, anyway it is always there, I'm going to treat it as an internal function and never for real installation.
I'll try to use CPack External Generator.

Thanks

Last edited by followait (2021-08-21 03:47:21)

Offline

#18 2021-08-25 01:38:44

followait
Banned
Registered: 2019-11-01
Posts: 58

Re: [SOLVED] How for `makepkg -i` to ask for password in cmake?

As a note, a better solution is to use a package manager like conan to solve the problem.

Offline

#19 2021-08-30 12:27:33

followait
Banned
Registered: 2019-11-01
Posts: 58

Re: [SOLVED] How for `makepkg -i` to ask for password in cmake?

The simplest, most robust and most portable way is use -DCMAKE_INSTALL_PREFIX=/opt/mylib when installing,
layout after installation as below

/opt/mylib/include/...
/opt/mylib/lib/...
/opt/mylib/share/...

cmake's sophisticated search path should find it, at least when CMAKE_PREFIX_PATH contains /opt
uninstallation is as easy as delete a folder

Last edited by followait (2021-08-31 05:12:46)

Offline

Board footer

Powered by FluxBB