Comments (6)
Generally speaking, TOML can accept "here-document". My app also accept it. Please specify script as follows:
[package.metadata.generate-rpm]
pre_install_script = """
echo some command > /dev/null
echo another command > /dev/null
"""
from cargo-generate-rpm.
Thanks.
And if I want the script to be a file outside of Cargo.toml? I'd rather not put lots of Bash script into my Cargo.toml.
Ximon
Update: Hmm, I suppose I could use the here-doc approach to enable me to both execute and remove a script placed in /tmp/
as a workaround.
from cargo-generate-rpm.
Like RPM native spec file format, scriptlets shall be written Cargo.toml directly. It is not really intended to be huge scripts with more than hundred lines long.
IMHO, considering the transparency for users, it is better to leave the large script stored in a separated file such as /usr/share/foobar/rpm/install-script.sh so that they can refer to it later.
from cargo-generate-rpm.
Thanks for the advice. I do not want scriptlets in Cargo.toml, I don't want it to become cluttered and to mix purposes and languages together like that. However I hadn't thought about using assets under /usr/share
, I will try that as indeed it is good if the scripts invoked are available on the host post (successful or failed) install.
from cargo-generate-rpm.
So we realized that the workaround of specifying a command that runs a script file doesn't work for post_uninstall_script
as by the time it is run the script has been removed from disk.
Still not wanting to pollute my Cargo.toml
with Bash scripts I'm now trying to see if the new --set-metadata
functionality can help here, with:
cargo generate-rpm --set-metadata "post_uninstall_script = \"\"\"$(cat pkg/rpm/postuninst)\"\"\""
This looks fine when the created package is inspected:
$ rpm -qp --scripts target/generate-rpm/routinator-0.12.0-dev-1.x86_64.rpm
postinstall scriptlet:
/usr/share/routinator/rpm/postinst $*
preuninstall scriptlet:
/usr/share/routinator/rpm/preuninst $*
postuninstall scriptlet:
#!/bin/bash -e
# Script based on the RPM %systemd_postun scriptlet. See:
# - https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_systemd
# - https://cgit.freedesktop.org/systemd/systemd/tree/src/core/macros.systemd.in
systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
systemctl try-restart routinator.service >/dev/null 2>&1 || :
fi
from cargo-generate-rpm.
Since it is up to an RPM specification, these scripts should be defined using a multi-string string, such as #17 (comment). Of course, you can use escaped linefeed \n
in a basic string instead of raw string in a multi-line basic string (see also: https://toml.io/en/v1.0.0#string ).
from cargo-generate-rpm.
Related Issues (20)
- Keep basename of source when it is a file and dest is directory
- Release Binaries HOT 1
- mc cannot read resulting rpm file HOT 4
- Missing Cargo.lock HOT 4
- Getting SIGSEGV: invalid memory reference for `config::test::test_table_to_dependencies` HOT 2
- Support for `summary` silently dropped HOT 2
- Missing field: package.metadata HOT 2
- Support for `license-file` HOT 2
- setting `CARGO_TARGET_DIR` and using auto-req results in malformed RPM
- Reproducible builds HOT 5
- Future-incompatibilities warning HOT 2
- Script parameters should accept path to files, not script intself HOT 6
- error: unpacking of archive failed on file /lib/systemd/system/xxx.service;6496c577: cpio: Digest mismatch HOT 3
- Feature Request: allow not replacing config files HOT 5
- RPM is not readable by rpmlint HOT 4
- Could not generate generate-rpm in case of --target specified HOT 2
- Failed dependencies: libc.so.6(GLIBC_2.29)(64bit) is needed when install generated .rpm package HOT 1
- Issue with generate RPM not matching the PowerPC64 LE architecture HOT 3
- [Feature-Request] Add `%pretrans %posttrans`? HOT 1
- Building rpm for `foo-bar` package means `foo-bar/Cargo.toml` must exists? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cargo-generate-rpm.