kornelski / cargo-deb

Make Debian packages directly from Rust/Cargo projects
https://lib.rs/cargo-deb
MIT License
408 stars 48 forks source link

Cannot include symbolic link as asset #44

Closed naokiri closed 1 year ago

naokiri commented 2 years ago

As a library developer, I want to build an lib*-dev.deb package.

Steps to reproduce

$ cargo deb --version
1.38.4
  1. Create symlinks
    # mkdir -p tmp_asset
    # cd tmp_asset
    # ln -sf libfoo.so.0 libfoo.so.0.7.0
    # ln -sf libfoo.so libfoo.so.0.7.0
  2. Add these into assets configuration
[package.metadata.deb]
assets = [["tmp_asset/lib*", "/usr/local/lib/", "777"]]
preserve-symlinks = true
  1. Run cargo deb

Expected

symbolic link is included in the deb package

Actual

cargo-deb: unable to read asset to add to archive: OMIT/libfoo.so

Is there any workaround to make symlinks in deb package?

kornelski commented 1 year ago

I've changed symlinks behavior in v1.41.0-beta.1. Please test it.

patlkli commented 1 year ago

I believe 02ee084aa6d5b23cfac51eea253db10745b7c57f might have broken symlink assets in a different way.

In Config::resolve_assets, glob::glob is always used to resolve asset source paths, even for non-glob patterns. Unfortunately glob::glob also always tries to follow symlinks and has no option to disable that (see rust-lang/glob#63). So if you try to package a dangling symlink (in the source tree that is), you will get an AssetFileNotFound error.

Should I submit a PR to just skip globbing if preserve_symlinks is enabled and the source is a symlink?