Skip to content

Commit

Permalink
Copy config files to output directory
Browse files Browse the repository at this point in the history
  • Loading branch information
qzed committed Sep 14, 2024
1 parent d582e85 commit 4e00aee
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 14 deletions.
18 changes: 8 additions & 10 deletions pkg/fedora/surface-dtx-daemon.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Summary: Surface Detachment System (DTX) Daemon
License: MIT
URL: https://github.com/linux-surface/surface-dtx-daemon

Source0: https://github.com/linux-surface/surface-dtx-daemon/archive/refs/tags/v%{version}-{release}.tar.gz

Requires: dbus libgcc
BuildRequires: rust cargo dbus-devel

Expand Down Expand Up @@ -35,14 +33,14 @@ install -D -m755 "target/release/surface-dtx-daemon" "%{buildroot}/usr/bin/surfa
install -D -m755 "target/release/surface-dtx-userd" "%{buildroot}/usr/bin/surface-dtx-userd"

# application files
install -D -m644 "etc/dtx/surface-dtx-daemon.conf" "%{buildroot}/etc/surface-dtx/surface-dtx-daemon.conf"
install -D -m644 "etc/dtx/surface-dtx-userd.conf" "%{buildroot}/etc/surface-dtx/surface-dtx-userd.conf"
install -D -m755 "etc/dtx/attach.sh" "%{buildroot}/etc/surface-dtx/attach.sh"
install -D -m755 "etc/dtx/detach.sh" "%{buildroot}/etc/surface-dtx/detach.sh"
install -D -m644 "etc/systemd/surface-dtx-daemon.service" "%{buildroot}/usr/lib/systemd/system/surface-dtx-daemon.service"
install -D -m644 "etc/systemd/surface-dtx-userd.service" "%{buildroot}/usr/lib/systemd/user/surface-dtx-userd.service"
install -D -m644 "etc/dbus/org.surface.dtx.conf" "%{buildroot}/etc/dbus-1/system.d/org.surface.dtx.conf"
install -D -m644 "etc/udev/40-surface_dtx.rules" "%{buildroot}/etc/udev/rules.d/40-surface_dtx.rules"
install -D -m644 "target/etc/dtx/surface-dtx-daemon.conf" "%{buildroot}/etc/surface-dtx/surface-dtx-daemon.conf"
install -D -m644 "target/etc/dtx/surface-dtx-userd.conf" "%{buildroot}/etc/surface-dtx/surface-dtx-userd.conf"
install -D -m755 "target/etc/dtx/attach.sh" "%{buildroot}/etc/surface-dtx/attach.sh"
install -D -m755 "target/etc/dtx/detach.sh" "%{buildroot}/etc/surface-dtx/detach.sh"
install -D -m644 "target/etc/systemd/surface-dtx-daemon.service" "%{buildroot}/usr/lib/systemd/system/surface-dtx-daemon.service"
install -D -m644 "target/etc/systemd/surface-dtx-userd.service" "%{buildroot}/usr/lib/systemd/user/surface-dtx-userd.service"
install -D -m644 "target/etc/dbus/org.surface.dtx.conf" "%{buildroot}/etc/dbus-1/system.d/org.surface.dtx.conf"
install -D -m644 "target/etc/udev/40-surface_dtx.rules" "%{buildroot}/etc/udev/rules.d/40-surface_dtx.rules"

# completion files
install -D -m644 "target/surface-dtx-daemon.bash" "%{buildroot}/usr/share/bash-completion/completions/surface-dtx-daemon"
Expand Down
31 changes: 29 additions & 2 deletions surface-dtx-daemon/build.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,43 @@
use std::env;
use std::path::PathBuf;
use clap_complete::shells;

include!("src/cli.rs");


fn main() {
let outdir = env::var_os("CARGO_TARGET_DIR")
let outdir: PathBuf = env::var_os("CARGO_TARGET_DIR")
.or_else(|| env::var_os("OUT_DIR"))
.unwrap();
.unwrap()
.into();

let rootdir = env::current_dir().unwrap();
let rootdir = rootdir
.parent().unwrap();

println!("{rootdir:?}");

// generate shell completions
let mut app = app();
clap_complete::generate_to(shells::Bash, &mut app, "surface-dtx-daemon", &outdir).unwrap();
clap_complete::generate_to(shells::Zsh, &mut app, "surface-dtx-daemon", &outdir).unwrap();
clap_complete::generate_to(shells::Fish, &mut app, "surface-dtx-daemon", &outdir).unwrap();

// copy config files
let files = [
"etc/dbus/org.surface.dtx.conf",
"etc/dtx/attach.sh",
"etc/dtx/detach.sh",
"etc/dtx/surface-dtx-daemon.conf",
"etc/systemd/surface-dtx-daemon.service",
"etc/udev/40-surface_dtx.rules",
];

for file in files {
let src = rootdir.join(file);
let tgt = outdir.join(file);

std::fs::create_dir_all(tgt.parent().unwrap()).unwrap();
std::fs::copy(src, tgt).unwrap();
}
}
27 changes: 25 additions & 2 deletions surface-dtx-userd/build.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,39 @@
use std::env;
use std::path::PathBuf;
use clap_complete::shells;

include!("src/cli.rs");


fn main() {
let outdir = env::var_os("CARGO_TARGET_DIR")
let outdir: PathBuf = env::var_os("CARGO_TARGET_DIR")
.or_else(|| env::var_os("OUT_DIR"))
.unwrap();
.unwrap()
.into();

let rootdir = env::current_dir().unwrap();
let rootdir = rootdir
.parent().unwrap();

println!("{rootdir:?}");

// generate shell completions
let mut app = app();
clap_complete::generate_to(shells::Bash, &mut app, "surface-dtx-userd", &outdir).unwrap();
clap_complete::generate_to(shells::Zsh, &mut app, "surface-dtx-userd", &outdir).unwrap();
clap_complete::generate_to(shells::Fish, &mut app, "surface-dtx-userd", &outdir).unwrap();

// copy config files
let files = [
"etc/dtx/surface-dtx-userd.conf",
"etc/systemd/surface-dtx-userd.service",
];

for file in files {
let src = rootdir.join(file);
let tgt = outdir.join(file);

std::fs::create_dir_all(tgt.parent().unwrap()).unwrap();
std::fs::copy(src, tgt).unwrap();
}
}

0 comments on commit 4e00aee

Please sign in to comment.