qm icon indicating copy to clipboard operation
qm copied to clipboard

RFE: how about have a tool qm-is-ostree ?

Open dougsland opened this issue 1 year ago • 6 comments

I am wondering if we can convert this code into a generic tool for qm instead of exclusive for ffi and tests: https://github.com/containers/qm/blob/26ba84b3aaf83af045659aba4b3f71258b072d9b/tests/ffi/common/prepare.sh#L21

Why? I was looking into a way to test if we are into a ostree or not in a spec file and I couldn't easily do it. I am sure in the future, we might face another examples.

WDYT: @Yarboa @aesteve-rh @nsednev @RakeshMK90 @pengshanyu

If this issue get accepted by the maintainers, the engineer assigned could:

  • convert the code from https://github.com/containers/qm/blob/26ba84b3aaf83af045659aba4b3f71258b072d9b/tests/ffi/common/prepare.sh#L21 into a tool and add into the dir tools/ (make sure the previous call use now the tool)
  • make sure it included into rpm like others, see as example: https://github.com/containers/qm/blob/26ba84b3aaf83af045659aba4b3f71258b072d9b/rpm/qm.spec#L138

dougsland avatar Oct 01 '24 04:10 dougsland

Hi, @dougsland we can perhaps do something like this in the spec file?

%pre
# Check if the system is an OSTree-based system
if [ -d /ostree/repo ] || command -v ostree >/dev/null 2>&1; then
    echo "OSTree-based system detected."
    # Perform any specific actions for OSTree systems if needed
else
    echo "Non-OSTree system detected."
    # Perform any actions specific to non-OSTree systems if needed
fi

The %pre scriptlet runs before the package is installed or upgraded

RakeshMK90 avatar Oct 10 '24 22:10 RakeshMK90

Hi, @dougsland we can perhaps do something like this in the spec file?

%pre
# Check if the system is an OSTree-based system
if [ -d /ostree/repo ] || command -v ostree >/dev/null 2>&1; then
    echo "OSTree-based system detected."
    # Perform any specific actions for OSTree systems if needed
else
    echo "Non-OSTree system detected."
    # Perform any actions specific to non-OSTree systems if needed
fi

The %pre scriptlet runs before the package is installed or upgraded

Indeed, it's a possible solution but I would prefer to have a tool available to users and developers as well to also quick go to shell or in a ssh-session and execute something like:

# qm-is-ostree
QM is running on OSTree-based system.

@RakeshMK90 WDYT?

dougsland avatar Oct 10 '24 22:10 dougsland

thanks, @dougsland by tool you mean can we just create a separate bash script qm-is-ostree.sh and make it as an executable?. We are perhaps do this in setup part?

RakeshMK90 avatar Oct 11 '24 02:10 RakeshMK90

@RakeshMK90 no need to call in setup for now, just create a tool, also not required to add the extension .sh in the end as the shebang will help to automatic detect the type of file too. It can be added into the tools dir and in the spec it will deploy in /usr/share/qm/ see: https://github.com/containers/qm/tree/main/tools

dougsland avatar Oct 11 '24 03:10 dougsland

Hi @dougsland created a MR here https://github.com/containers/qm/pull/614

RakeshMK90 avatar Oct 11 '24 16:10 RakeshMK90

Hi @dougsland created a MR here #614

Excellent @RakeshMK90 . Waiting others developers review.

dougsland avatar Oct 12 '24 13:10 dougsland

Resolved.

dougsland avatar Oct 14 '24 12:10 dougsland