Code Monkey home page Code Monkey logo

cargo-rpm's People

Contributors

anupdhml avatar dalance avatar dansondergaard avatar filips123 avatar jamessewell avatar l4l avatar lenardhess avatar mthebridge avatar roccodev avatar rubdos avatar saidsay-so avatar shella avatar stevenroose avatar tarcieri avatar tony-iqlusion avatar uberjay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cargo-rpm's Issues

Build with different bin dir throws errors

So I encountered an error message when trying to install a binary in a directory other than /usr/bin/ or /usr/sbin/. I tried creating this package metadata in the Cargo.toml

[package.metadata.rpm.targets]
foo = { path = "/usr/bin/foo" }
bar = { path = "/etc/foo/bar" }

I think this line of code is to blame:
https://github.com/RustRPM/cargo-rpm/blob/a92ab8ce23575384fee4e5f4b8857681fa8d3bec/src/commands/init.rs#L139

I think it would be great to be able to specify other paths for installing binaries.

Support custom directory for spec file location

Right now, cargo-rpm expects the spec file to be at .rpm directory in project root. It would be nice to support reads (as well as initial write) of the spec file from a user-defined location in the project.


Thinking of an --output arg to cargo rpm init, to specify the directory where the spec file would be written to (if the arg is not supplied, spec would still be written to current default .rpm).

As part of init, the directory would also be included as a new entry in Cargo.toml's [package.metadata.rpm], from which cargo rpm build can pick up the spec file. Example layout:

[package.metadata.rpm]
config-dir = "packaging/rpm"

This would also make it clear from configuration that cargo-rpm relies on the assets in config-dir.

If this proposal makes sense, I would be happy to work on a PR to add it.

Suggestions are welcome!

Error running build command, No such file or directory (os error 2)

Hello,
I'm trying to use this library to create an rpm package, but I keep getting the same error. I have already run cargo rpm init however whenever I try to run cargo rpm build, I get the following error.

cargo rpm build -vvv
     Running cargo build --release
    Finished release [optimized] target(s) in 0.05s
    Creating release archive: keysync-3.0.2.tar.gz
error: rpmbuild error: error running rpmbuild: No such file or directory (os error 2)

Spec file (default values)

%define __spec_install_post %{nil}
%define __os_install_post %{_dbpath}/brp-compress
%define debug_package %{nil}

Name: keysync
Summary: A utility to sync local authorized_keys file updated with your with Github, Gitlab, and Launchpad public keys
Version: @@VERSION@@
Release: @@RELEASE@@%{?dist}
License: GPLv3+
Group: Applications/System
Source0: %{name}-%{version}.tar.gz
URL: https://github.com/budde25/ssh-key-sync

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

%description
%{summary}

%prep
%setup -q

%install
rm -rf %{buildroot}
mkdir -p %{buildroot}
cp -a * %{buildroot}

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
%{_bindir}/*

and Cargo.toml (default vales)

[package.metadata.rpm]
package = "keysync"

[package.metadata.rpm.cargo]
buildflags = ["--release"]

[package.metadata.rpm.targets]
keysync = { path = "/usr/bin/keysync" }

Thanks!

Error running the build command, No file or directory

Hello,
I'm trying to use this library to create an rpm package, but I keep getting the same error. I have already run cargo rpm init however whenever I try to run cargo rpm build, I get the following error.

cargo rpm build -vvv
     Running cargo build --release
    Finished release [optimized] target(s) in 0.05s
    Creating release archive: keysync-3.0.2.tar.gz
error: rpmbuild error: error running rpmbuild: No such file or directory (os error 2)

Spec file (default values)

%define __spec_install_post %{nil}
%define __os_install_post %{_dbpath}/brp-compress
%define debug_package %{nil}

Name: keysync
Summary: A utility to sync local authorized_keys file updated with your with Github, Gitlab, and Launchpad public keys
Version: @@VERSION@@
Release: @@RELEASE@@%{?dist}
License: GPLv3+
Group: Applications/System
Source0: %{name}-%{version}.tar.gz
URL: https://github.com/budde25/ssh-key-sync

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

%description
%{summary}

%prep
%setup -q

%install
rm -rf %{buildroot}
mkdir -p %{buildroot}
cp -a * %{buildroot}

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
%{_bindir}/*

and Cargo.toml (default vales)

[package.metadata.rpm]
package = "keysync"

[package.metadata.rpm.cargo]
buildflags = ["--release"]

[package.metadata.rpm.targets]
keysync = { path = "/usr/bin/keysync" }

Support prerelease versions (e.g. as used by cargo-release)

Moving this over from:

iqlusioninc/crates#38

The version format used for cargo prereleases does not seem to be supported by RPM. This results in failures like:

$ cargo rpm build
    Finished release [optimized] target(s) in 0.0 secs
    Building sakcl-0.1.1-alpha.0.rpm (using rpmbuild 4.11.3)

error: error running /usr/bin/rpmbuild (exit status: exit code: 1)
ERROR: Job failed: exit code 1

cc @cardoe

Naming the package different than the crate is not possible

So the name of my executable collides with an existing RPM package that does not provide an executable. So I'm trying to generate an RPM package that has a different name than the executable that is included into the package. Without success.

can't switch between release and debug builds

There seems to be no way right now to create both a debug and release build of an RPM without modifying the Cargo.toml it would be nice to have a flag like --profile<debug> that allows overwriting the metadata.

The reason being is that release builds with rust take a lot of time and in CI, to test rpm creation it would often be enough to build as debug which is fairly quick, and see if the archive is usable.

edit:

cargo-deb offers the --profile flag to overwrite the profile on the command line

`init` command doesn't work with multi-directory setups

I have a fairly standard directory structure where the name of the binary is the folder name in src/bin:

$ tree src/bin 
src/bin
└── hal
    ├── cmd
    │   ├── address.rs
    │   ├── bech32.rs
    │   ├── bip32.rs
    │   ├── bip39.rs
    │   ├── block.rs
    │   ├── key.rs
    │   ├── ln.rs
    │   ├── message.rs
    │   ├── mod.rs
    │   ├── psbt.rs
    │   ├── script.rs
    │   └── tx.rs
    ├── main.rs
    ├── process_builder.rs
    └── util.rs

seems to freak cargo rpm init out:

error: target error: unrecognized file in src/bin: "./src/bin/hal"

Even when I try to move everything up, like this:

$ tree src/bin 
src/bin
├── cmd
│   ├── address.rs
│   ├── bech32.rs
│   ├── bip32.rs
│   ├── bip39.rs
│   ├── block.rs
│   ├── key.rs
│   ├── ln.rs
│   ├── message.rs
│   ├── mod.rs
│   ├── psbt.rs
│   ├── script.rs
│   └── tx.rs
├── main.rs
├── process_builder.rs
└── util.rs

But then again it fails with:

error: target error: unrecognized file in src/bin: "./src/bin/cmd"

It seems that any directory in the src/bin folder will cause an error.

rpmbuild fails if license is not set in Cargo.toml

Error:

�[m��[32m�[1m     Running�[m� cargo build --release
    Finished release [optimized] target(s) in 0.03s
�[m��[32m�[1m    Creating�[m� release archive: change-password-0.1.0.tar.gz
�[m��[32m�[1m    Building�[m� change-password-0.1.0.rpm (using rpmbuild 4.11.3)
�[m��[32m�[1m     Running�[m� /usr/bin/rpmbuild -D _topdir /home/das/genomedk-infra/system-tools/change-password/target/release/rpmbuild -D _tmppath /home/das/genomedk-infra/system-tools/change-password/target/release/rpmbuild/tmp -ba SPECS/change-password.spec
error: License field must be present in package: (main package)
�[m��[31m�[1merror:�[m� error running /usr/bin/rpmbuild (exit status: exit code: 1)

Maybe cargo rpm init should warn that a license is required, if not already set in Cargo.toml.

Allow multiple target architectures

I'm building an application that should target multiple target architectures. Currently, specifying the architecture for the RPM is possible in Cargo.toml under package.metadata.rpm.cargo.target, which is checked into version control.

cargo-rpm should rather take into account what cargo itself would consider the target, which is by passing either --target on CLI or reading ~/.cargo/config and .cargo/config. I am using the latter, e.g.

[build]
target = "arm-unknown-linux-gnueabihf"

Multiple binaries

I stumbled with placing multiple binaries targets (aka [[bin]] in Cargo.toml) in a package, and cargo-rpm printed a cryptic message:

RPM build errors:

ERROR: Job failed: exit code 1

cargo rpm init fails at [target.cfg(linux)'.dependencies]

When I run (on Linux)
cargo rpm init
I get an error message:
error: cargo-rpm fatal error: parse error: no variant of enum CargoLicense found in flattened data for key package at line 46 column 1

I assume this is referring to this line(46) in my Cargo.toml:
[target.'cfg(linux)'.dependencies]

If I comment this out it bombs on line 43:
[target.'cfg(windows)'.dependencies]

build failed - thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 2

Hi @tarcieri,

after solving #33 i got these output (same on centos-release-7-6.1810.2.el7.centos.x86_64 and macOS 10.14.6):

thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 2', /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/libcore/slice/mod.rs:2681:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

with backtrace:

thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 2', /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/libcore/slice/mod.rs:2681:10
stack backtrace:
   0: std::panicking::default_hook::{{closure}}
   1: std::panicking::default_hook
   2: std::panicking::rust_panic_with_hook
   3: std::panicking::continue_panic_fmt
   4: rust_begin_unwind
   5: core::panicking::panic_fmt
   6: core::panicking::panic_bounds_check
   7: cargo_rpm::rpmbuild::Rpmbuild::version
   8: cargo_rpm::rpmbuild::Rpmbuild::new
   9: cargo_rpm::builder::Builder::build
  10: <cargo_rpm::commands::build::BuildCmd as abscissa_core::runnable::Runnable>::run
  11: abscissa_core::application::Application::run
  12: abscissa_core::application::boot
  13: cargo_rpm::main
  14: std::rt::lang_start::{{closure}}
  15: std::panicking::try::do_call
  16: __rust_maybe_catch_panic
  17: std::rt::lang_start_internal
  18: main

rpmbuild --version output:
RPM-Version 4.14.2.1

sudo dtruss -f -t open cargo rpm build -v output:

    PID/THRD  SYSCALL(args)          = return
     Running cargo build
    Finished dev [unoptimized + debuginfo] target(s) in 0.09s
    Creating release archive: BE_ApiGateway2-0.1.0.tar.gz
thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 2', /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/libcore/slice/mod.rs:2681:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
10096/0x81c8:  open("/dev/dtracehelper\0", 0x2, 0xFFFFFFFFEF392FB0)                                                                         = 3 0
10096/0x81c8:  open("/usr/share/terminfo/78/xterm-256color\0", 0x1000000, 0x1B6)                                                            = 3 0
10096/0x81c8:  open("/dev/urandom\0", 0x1000000, 0x1B6)                                                                                     = 4 0
10096/0x81c8:  open("/Users/AP/.rustup/settings.toml\0", 0x1000000, 0x1B6)                                                                  = 3 0
10096/0x81c8:  open("/synectic/GIT/syn6/BE_ApiGateway2/rust-toolchain\0", 0x1000000, 0x1B6)                                                 = -1 Err#2
10096/0x81c8:  open("/synectic/GIT/syn6/rust-toolchain\0", 0x1000000, 0x1B6)                                                                = -1 Err#2
10096/0x81c8:  open("/synectic/GIT/rust-toolchain\0", 0x1000000, 0x1B6)                                                                     = -1 Err#2
10096/0x81c8:  open("/synectic/rust-toolchain\0", 0x1000000, 0x1B6)                                                                         = -1 Err#2
10096/0x81c8:  open("/rust-toolchain\0", 0x1000000, 0x1B6)                                                                                  = -1 Err#2
10096/0x81f9:  open("/dev/dtracehelper\0", 0x2, 0xFFFFFFFFE8A7FE20)                                                                         = 3 0
10096/0x81f9:  open("/dev/urandom\0", 0x1000000, 0x1B6)                                                                                     = 3 0
10096/0x81f9:  open("/Users/AP/.gitconfig\0", 0x1000000, 0x0)                                                                               = 3 0
10096/0x81fa:  open("/dev/dtracehelper\0", 0x2, 0xFFFFFFFFE5D77E10)                                                                         = 3 0
10096/0x81fa:  open("/dev/urandom\0", 0x1000000, 0x1B6)                                                                                     = 3 0
10096/0x81fa:  open("/synectic/GIT/syn6/BE_ApiGateway2/Cargo.toml\0", 0x1000000, 0x1B6)                                                     = 3 0
10096/0x81fa:  open("/synectic/GIT/syn6/BE_ApiGateway2/target/release/rpmbuild/SOURCES/BE_ApiGateway2-0.1.0.tar.gz\0", 0x1000601, 0x1B6)    = 3 0
10096/0x81fa:  open("/synectic/GIT/syn6/BE_ApiGateway2/target/release/BE_ApiGateway2\0", 0x1000000, 0x1B6)                                  = 4 0
10096/0x81fa:  open("./.rpm/BE_ApiGateway2.spec\0", 0x1000000, 0x1B6)                                                                       = 3 0
10096/0x81fa:  open("/synectic/GIT/syn6/BE_ApiGateway2/target/release/rpmbuild/SPECS/BE_ApiGateway2.spec\0", 0x1000601, 0x1B6)              = 4 0
10096/0x81fa:  open("/dev/null\0", 0x1000000, 0x1B6)                                                                                        = 3 0

No such file or directory for a file that does exist

$ ls -al src/bin/hal/main.rs 
-rw-r--r-- 1 steven steven 4.3K Apr 14 18:30 src/bin/hal/main.rs
$ cargo rpm build
error: couldn't read src/bin/hal/main.rs: No such file or directory (os error 2)

error: aborting due to previous error

    Finished release [optimized] target(s) in 0.04s
    Building hal-0.6.0-1.rpm (using rpmbuild 4.15.1)

error: rpmbuild error: error running rpmbuild (exit status: exit code: 1)

How to use the output with other actions

Hi, first of all, many thanks for sharing this. I am trying to create an rpm and then upload it as a release from a GitHub action with something like this:

 build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Rust Cargo Rpm Package Build (amd64, centos8)
      id: rpm_build
      uses: nbari/[email protected]

    - name: Create Release
      id: create_release
      uses: actions/create-release@latest
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
      with:
        tag_name: ${{ github.ref }}
        release_name: Release ${{ github.ref }}
        body: |
            Changes in this Release
            - Create RPM
            - Upload Source RPM
        draft: false
        prerelease: false

    - name: Upload a Release Asset
      uses: actions/upload-release-asset@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        upload_url: ${{ steps.create_release.outputs.upload_url }} 
        asset_path: /github/workspace/target/release/rpmbuild/RPMS/x86_64/httpwsrep-0.4.0-1.el8.x86_64.rpm
        asset_name: "httpwsrep.rpm"
        asset_content_type: "application/octet-stream"

The rpm gets created: https://github.com/nbari/httpwsrep/runs/1295799684?check_suite_focus=true#step:4:374

but then when I am trying to create the asset, I am getting a file not found: https://github.com/nbari/httpwsrep/runs/1295799684?check_suite_focus=true#step:6:10

For now, I am hardcoding the asset_path but wondering how could I take advantage of cargo rpm build and collect it so that later I could use it with something like:

asset_path : ${{ steps.create.rpm_build.output }}

Any ideas?

rpmbuild fails when path is not /usr/bin

I changed the path set in Cargo.toml:

change-password = { path = "/usr/local/bin/change-password" }

Running cargo rpm build --verbose then gives me this error:

�[m��[32m�[1m     Running�[m� cargo build --release
    Finished release [optimized] target(s) in 0.02s
�[m��[32m�[1m    Creating�[m� release archive: change-password-0.1.0.tar.gz
�[m��[32m�[1m    Building�[m� change-password-0.1.0.rpm (using rpmbuild 4.11.3)
�[m��[32m�[1m     Running�[m� /usr/bin/rpmbuild -D _topdir /home/das/system-tools/change-password/target/release/rpmbuild -D _tmppath /home/das/system-tools/change-password/target/release/rpmbuild/tmp -ba SPECS/change-password.spec
�[m��[32m�[1m    rpmbuild�[m� Executing(%prep): /bin/sh -e /home/das/system-tools/change-password/target/release/rpmbuild/tmp/rpm-tmp.v6zmQQ
+ umask 022
+ cd /home/das/system-tools/change-password/target/release/rpmbuild/BUILD
+ cd /home/das/system-tools/change-password/target/release/rpmbuild/BUILD
+ rm -rf change-password-0.1.0
+ /usr/bin/gzip -dc /home/das/system-tools/change-password/target/release/rpmbuild/SOURCES/change-password-0.1.0.tar.gz
+ /usr/bin/tar -xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd change-password-0.1.0
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
�[m��[32m�[1m    rpmbuild�[m� Executing(%install): /bin/sh -e /home/das/system-tools/change-password/target/release/rpmbuild/tmp/rpm-tmp.IKtW4R
+ umask 022
+ cd /home/das/system-tools/change-password/target/release/rpmbuild/BUILD
+ '[' /home/das/system-tools/change-password/target/release/rpmbuild/BUILDROOT/change-password-0.1.0-1.x86_64 '!=' / ']'
+ rm -rf /home/das/system-tools/change-password/target/release/rpmbuild/BUILDROOT/change-password-0.1.0-1.x86_64
++ dirname /home/das/system-tools/change-password/target/release/rpmbuild/BUILDROOT/change-password-0.1.0-1.x86_64
+ mkdir -p /home/das/system-tools/change-password/target/release/rpmbuild/BUILDROOT
+ mkdir /home/das/system-tools/change-password/target/release/rpmbuild/BUILDROOT/change-password-0.1.0-1.x86_64
+ cd change-password-0.1.0
+ rm -rf /home/das/system-tools/change-password/target/release/rpmbuild/BUILDROOT/change-password-0.1.0-1.x86_64
+ mkdir -p /home/das/system-tools/change-password/target/release/rpmbuild/BUILDROOT/change-password-0.1.0-1.x86_64
+ cp -a usr /home/das/system-tools/change-password/target/release/rpmbuild/BUILDROOT/change-password-0.1.0-1.x86_64
�[m��[32m�[1m    rpmbuild�[m� Processing files: change-password-0.1.0-1.x86_64
error: File not found by glob: /home/das/system-tools/change-password/target/release/rpmbuild/BUILDROOT/change-password-0.1.0-1.x86_64/usr/bin/*
    File not found by glob: /home/das/system-tools/change-password/target/release/rpmbuild/BUILDROOT/change-password-0.1.0-1.x86_64/usr/bin/*
�[m��[32m�[1m    rpmbuild�[m� 
�[m��[32m�[1m    rpmbuild�[m� 
�[m��[32m�[1m    rpmbuild�[m� RPM build errors:
�[m��[31m�[1merror:�[m� error running /usr/bin/rpmbuild (exit status: exit code: 1)

Clearly rpmbuild seems to assume that the file is located in /usr/bin/.

Add files to the package

I need to add a file from the project in the RPM
In the %install section of the generated spec file I want to add the two lines below

mkdir -p ${RPM_BUILD_ROOT}/etc/myproject
install -m 755 somefile.toml ${RPM_BUILD_ROOT}/etc/myproject/somefile.toml

question is how to get somefile.toml into the rpm SOURCES used for building the rpm?

[RFE] Support building library

Hi

  • I was able to build a rpm with rust binary but not library. Please see logs below.
[pi@centos7 sudo_pair]$ git remote -v
origin  [email protected]:learnrust/sudo_pair.git (fetch)
origin  [email protected]:learnrust/sudo_pair.git (push)
[pi@centos7 sudo_pair]$ cargo rpm  init
error: detected unsupported crate type: library (-f to override)
[pi@centos7 sudo_pair]$ cat Cargo.toml
[package]
name    = "sudo_pair"
version = "0.11.1"
license = "Apache-2.0"
edition = "2018"

authors     = ["Stephen Touset <[email protected]>"]
description = "sudo IO-plugin to require a live human pair"

homepage   = "https://github.com/square/sudo_pair"
repository = "https://github.com/square/sudo_pair.git"
readme     = "../README.md"

categories = [ "command-line-utilities" ]
keywords   = [ "sudo", "sudo-plugin", "dual-control", "sox" ]

[lib]
name       = "sudo_pair"
crate-type = ["cdylib"]

[dependencies]
libc        = '0'
failure     = '0'
sudo_plugin = { version = "1.1", path = "../sudo_plugin" }

[badges]
travis-ci = { repository = "square/sudo_pair" }
[pi@centos7 sudo_pair]$


error: missing field 'description' for key 'package'

When trying to run cargo rpm init, I'm getting the following error:

$ cargo rpm init
error: cargo-rpm fatal error: parse error: missing field `description` for key `package` at line 8 column 1

How is one supposed to provide the description field? Could we add it to the README documentation (or have I missed some doc piece that describes it)? Thanks.

Don't bury the result so deep

It would be easier to use if the rpm file was placed in target/rpm, instead of /target/release/rpmbuild/RPMs/{architecture}. It would also be consistent with cargo wix and cargo deb.

Cargo workspaces support

Currently, if cargo-rpm launched from within the workspace root the following error is printed:

error: no [package] section in Cargo.toml!

As I may guess, the workspaces are not supported and for now it's just possible to iterate over necessary crates manually and for each execute cargo rpm build. Would be nice, if it supported from cargo-rpm itself. List of possible subtasks:

  • new command cargo rpm list that lists projects that has a (valid) .rpm sub-folder at that workspace;
  • executing cargo rpm init at workspace root inits .rpm for each crate in that workspace, optionally with specified crate list;
  • executing cargo rpm build at workspace root builds each crate in a workspace (optionally) skipping ones without .rpm sub-folder;
  • flag -p/--package for selecting a package to work with (i.e. cargo rpm -p mypackage build works the same as changing directory to mypackage package and then launching cargo rpm build).

musl

Hey,

I can see some discussion, but I can't for the life of me get a musl build to work (and be triggered by the cargo rpm build command.

Is there a trick to getting --release --target x86_64-unknown-linux-musl passed through when compiling and then getting cargo-rpm to get the code form ./target/x86_64-unknown-linux-musl ?

build failed - No such file or directory (os error 2)

If i run cargo rpm build -v on macOS Mojave it fails with the following output:

    Running cargo build
    Finished dev [unoptimized + debuginfo] target(s) in 0.36s
    Creating release archive: BE_ApiGateway2-0.1.0.tar.gz
error: I/O error: No such file or directory (os error 2)

``cargo rpm init`` generates malformed TOML

In a project with a binary at src/bin/foo.rs, running
cargo rpm init adds these lines to Cargo.toml:

[package.metadata.rpm]
buildflags = ["--release"]

[package.metadata.rpm.targets]
./src/bin/foo = { path = "/usr/bin/./src/bin/foo" }

which is not well formed syntax and causes cargo to error out:

$ cargo build
error: failed to parse manifest at `/src/rust-dev/playground/cargo-rpm/test-bin/Cargo.toml`

Caused by:
  could not parse input as TOML

Caused by:
  expected a table key, found a period at line 15

I’m using cargo-fmt (0.6.0) on Fedora 30.

Help message lacks information

From the --help message it is not clear how to properly use cargo-rpm - that is a sub-optimal first encounter:

$cargo rpm --help
error: unrecognized command `--help`

cargo-rpm 0.8.0
Tony Arcieri <[email protected]>
Build RPMs from Rust projects using Cargo workflows

FLAGS:
    -c, --config CONFIG       path to configuration file
    -h, --help                print help message
    -v, --verbose             be verbose

which does not list init or any subcommand and also exits with exitcode 1 rather than 0.

Add option to disable cargo build during rpm builds

On cargo rpm build right now, project build is always triggered via cargo but there are situations where users may want to control the project build outside of cargo-rpm and use it only for the rpm packaging (eg: when cross is used to produce the binaries, or when users prefer to trigger the project build only once and then use the resulting binaries for various forms of packaging). For use in such situations, add a flag like --no-cargo-build to cargo rpm build.

Similar functionality is already present in packaging helpers like cargo-deb:
https://github.com/mmstick/cargo-deb#custom-build-flags

io error when debug directory but not release directory exists

The Problem

When you run cargo clean && cargo rpm build everything works fine, but if you run cargo clean && cargo build && cargo rpm build the rpm build will fail because of an unexpected missing directory.

It looks like this may be a duplicate of #33 so if this already fixed and just hasn't been released yet then feel free to close this.

rpm-rs backend

rpm-rs is a pure Rust library for building and parsing RPMs:

https://github.com/Richterrettich/rpm-rs

It includes support for much of the functionality in (lib)rpmbuild, including producing signed RPMs.

Unfortunately cargo-rpm is presently largely driven by .spec files, so supporting it would be a pretty major change.

It might be nice to support building RPMs without a spec file by using rpm-rs (i.e. via Cargo metadata alone), while retaining the current rpmbuild-based backend as well.

Purpose of the projetct

As you might know (or not), there is rust2rpm which is used by Fedora/Mageia/openSUSE for dealing with crates to package them as RPM.

So why there is a need to rewrite all that?

[RFE] Adding "--help" to trigger help message

  • Just an request for enhancement.
[pi@centos7 rust]$ cargo rpm --help
/home/pi/.cargo/bin/cargo-rpm: unrecognized command `--help`
[pi@centos7 rust]$ cargo rpm help
Usage: cargo rpm [COMMAND] [OPTIONS]

Available commands:

  help   Show help for a command
  init   Initialize a Rust project with RPM support
  build  Build an RPM out of the current project

[pi@centos7 rust]$

error: Installed (but unpackaged) file(s) found with files defined in package.metadata.rpm.files

Hi all,

I'm packaging a project that should contain configuration files and other stuff.
So I configured the package.metadata.rpm.files with the files but the cargo rpm build -v fails because of error: Installed (but unpackaged) file(s) found

This is the cargo section with rpm related stuff:


# RPM package configuration

[package.metadata.rpm]
package = "fog05-agent"

[package.metadata.rpm.cargo]
buildflags = ["--release"]

[package.metadata.rpm.targets]
fog05-agent = { path = "/usr/bin/fog05-agent" }

[package.metadata.rpm.files]
"../etc/agent.yaml" = { path = "/etc/fos/agent.yaml", mode = "644", username = "fos" }
"../var/placeholder" = { path = "/var/fos/placeholder", username = "fos" }
"../resources/fos-agent.service" = { path = "/lib/systemd/system/fos-agent.service" }

And this is the generated .spec file.

%define __spec_install_post %{nil}
%define __os_install_post %{_dbpath}/brp-compress
%define debug_package %{nil}

Name: fog05-agent
Summary: fog05: The End-to-End Compute, Storage and Networking Virtualisation solution.
Version: @@VERSION@@
Release: @@RELEASE@@%{?dist}
License:  EPL-2.0 OR Apache-2.0
Group: Applications/System
Source0: %{name}-%{version}.tar.gz
URL: http://fog05.io

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

%description
%{summary}

%prep
%setup -q

%install
rm -rf %{buildroot}
mkdir -p %{buildroot}
cp -a * %{buildroot}

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
%{_bindir}/*

It seems that the files are missing from the .spec file. Based on this they should be in the %files section.

Any idea how to solve this?

Add documentation about `[package.metadata.rpm]` to the README

I wasn't able to figure out about the existence of this extra toml metadata until I talked to the maintainer and then checked the source code itself to get more specifics.

It would be helpful to include additional documentation that does the following

  • Mentions that cargo rpm init adds some basic [package.metadata.rpm] fields to your Cargo.toml
  • Show examples of a Cargo.toml config that include using the [package.metadata.rpm.files] field at a minimum
  • Bonus points for comprehensively documenting the config format and all available options.

A comprehensive document isn't necessary for the README, all I really needed was knowledge of it's existence and possibly a code sample that showed something like this and mentioned that it takes files from the .rpm directory.

[package.metadata.rpm.files]
"scripts/automation-webhooks.cron" = { path = "/etc/cron.d/automation-webhooks" }
"scripts/automation-webhooks.init" = { path = "/etc/init.d/automation-webhooks" }
"scripts/automation-webhooks.logrotate" = { path = "/etc/logrotate.d/automation-webhooks" }
"scripts/automation-webhooks.monit" = { path = "/etc/monit.d/automation-webhooks.monit" }

I think an mdbook or rustdocs would be the best way to comprehensively document the introduced Cargo.toml metadata settings. The cargo book's manifest format section might be a good source of inspiration for how best to structure such a document file:///home/jlusby/git/rust/cargo/src/doc/book/reference/manifest.html.

If you do write such a document definitely link to it from the README near the more basic example of the most commonly used syntax.

Long path names

From tar documentation:

Note: This function does not support names over 100 bytes, or paths over 255 bytes, even for formats that support longer names. Instead, use Builder methods to insert a long-name extension at the same time as the file content.

When supplying long paths (harbour-whisperfish-0.6.0/usr/share/harbour-whisperfish/qml/components/attachment/), this gets triggered.

I'm just leaving this issue as documentation, I'm working on a patch already and that should get here in the next 30 minutes :'-)

build subcommand verbose print topdir arg should a quote

current verbose print is

Running rpmbuild -ba SPECS/a.spec -D _topdir /home/w/repos/temp/a/target/release/rpmbuild -D _tmppath /home/w/repos/temp/a/target/release/rpmbuild/tmp

when I copy this command run again get error: Macro %_topdir has empty body

the arg should print to -D '_topdir /home/w/repos/temp/a/target/release/rpmbuild' with quote to include whitespace

status_ok!("Running", "{} {}", cmd.path.display(), &args.join(" "));

current code use join to concat args can improve?

Cryptic error message if not in crate root

If I cd into the src folder in my Rust crate and run cargo rpm build, I get the following error:

error: No such file or directory (os error 2)

I would expect a clearer message about why it couldn't build the RPM.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.