Closed qwandor closed 2 years ago
Yes, it's very likely confusion of the current dir vs workspace.
I'll try and take a look at this when I get time.
Hey guys,
Thank you for the work you've been doing, the crate works great. I'm currently facing this issue, is there any known workaround I might use in the meanwhile?
I guess the workaround is to cd to crate's directory instead of workspace root. If that doesn't help, then it needs code fixed.
I'll try and take a look at this when I get time.
Well, that didn't happen... sorry about that.
I've taken a quick look tonight and pushed PR kornelski/cargo-deb#11 which I think helps, it would be good to know if @qwandor or @federico-terzi can confirm that.
It would help if cargo-deb had a debug logging level as well as info and warning, and if the maintainer script and unit file lookup process could log at debug level the paths it checks so that it is easier to diagnose why files are not being picked up. That's something I could add if wanted.
Thanks guys!
I guess the workaround is to cd to crate's directory instead of workspace root. If that doesn't help, then it needs code fixed.
@kornelski Interesting... I did try doing this on my project (Espanso), but it didn't work. At this point, it's very likely I made some mistakes :) I'll investigate further
@ximon18 Thanks! I'll make sure to test it out once ready :)
So, for the https://github.com/alsuren/mijia-homie project by @qwandor:
Without PR:
$ cargo deb -p mijia-homie -v 2>&1 | grep -i augmenting
With PR:
$ ~/src/3rd-party/cargo-deb-fork/target/release/cargo-deb -p mijia-homie -v 2>&1 | grep -i augmenting
info: Augmenting maintainer script /home/ximon/src/3rd-party/mijia-homie/mijia-homie/debian-scripts/postinst
info: Augmenting maintainer script /home/ximon/src/3rd-party/mijia-homie/mijia-homie/debian-scripts/postrm
FYI the PR is now ready for review, and below you can see how the systemd support causes code blocks to be injected into the generated DEB package control files:
$ ~/src/3rd-party/cargo-deb-fork/target/release/cargo-deb -p mijia-homie -v
$ dpkg-deb -e target/debian/mijia-homie_0.2.4_amd64.deb
$ for F in postinst postrm prerm; do P="DEBIAN/$F"; echo -e "\n::: $P :::\n===================="; cat $P; done
::: DEBIAN/postinst :::
====================
#!/bin/sh
set -e
if [ "$1" = "configure" ] ; then
touch /etc/mijia-homie/sensor-names.toml
adduser --system --no-create-home --home /etc/mijia-homie mijia-homie
adduser mijia-homie bluetooth
chown mijia-homie /etc/mijia-homie/mijia-history-influx.toml
chown mijia-homie /etc/mijia-homie/mijia-homie.toml
fi
# Automatically added by cargo-deb
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask mijia-homie.service >/dev/null || true
# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled mijia-homie.service; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable mijia-homie.service >/dev/null || true
else
# Update the statefile to add new symlinks (if any), which need to be
# cleaned up on purge. Also remove old symlinks.
deb-systemd-helper update-state mijia-homie.service >/dev/null || true
fi
fi
# End automatically added section
# Automatically added by cargo-deb
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
if [ -n "$2" ]; then
_dh_action=restart
else
_dh_action=start
fi
deb-systemd-invoke $_dh_action mijia-homie.service >/dev/null || true
fi
fi
# End automatically added section
::: DEBIAN/postrm :::
====================
#!/bin/sh
set -e
# Automatically added by cargo-deb
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
fi
# End automatically added section
# Automatically added by cargo-deb
if [ "$1" = "remove" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper mask mijia-homie.service >/dev/null || true
fi
fi
if [ "$1" = "purge" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper purge mijia-homie.service >/dev/null || true
deb-systemd-helper unmask mijia-homie.service >/dev/null || true
fi
fi
# End automatically added section
if [ "$1" = "purge" ] ; then
rm -f /etc/mijia-homie/sensor_names.conf
rm -f /etc/mijia-homie/sensor-names.toml
fi
::: DEBIAN/prerm :::
====================
#!/bin/sh
set -e
# Automatically added by cargo-deb
if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
deb-systemd-invoke stop mijia-homie.service >/dev/null || true
fi
# End automatically added section
@kornelski released the fix. Please test if you can then we can close this issue.
It looks like it works for me. I'm updating to the latest version in https://github.com/alsuren/mijia-homie/pull/189.
For a workspace with a crate named my-crate, where
my-crate/Cargo.toml
containsmaintainer-scripts = "debian"
, runningcargo deb
undermy-crate
works as expected, while runningcargo deb -p my-crate
in the top level directory appears to work fine, but ignores the postinst/preinst &c. scripts undermy-crate/debian
.Everything else works as expected relative to the correct directory, and it even correctly gets systemd service files from
my-crate/debian
.Maybe this is related to #105?