generally, I'd execute rpm2cpio $rpm | cpio -idmv but this extracts the exact file paths into the local folder
i.e
./usr/local/mycompany/myapp/bin/app
./usr/local/mycompany/myapp/resource/...
Is it possible to rewrite the file paths during the extract so that they instead extract to
./myapp/bin/app
./myapp/resource/...
GNU
cpiooffers the-roption to interactively rename files during extraction ("copy in"). But I suppose you want something automatic and / or scriptable, and there is no documentedcpiofeature providing for that.But it should be fast and straightforward to just move the subtree you want after the extraction, and then remove the extra, presumably empty parent directories:
That adds a little protection against catastrophe arising from running those commands from the filesystem root as a privileged user, but overall, you should not run it with privilege.