From: moo Date: Fri, 13 Feb 2026 22:36:29 +0000 (-0800) Subject: pkgbuilding more stuff X-Git-Url: https://git.taranathan.com/?a=commitdiff_plain;h=12b9d9573f55cec5c90ec669f6a6d37a6c43304e;p=dibble.git pkgbuilding more stuff --- diff --git a/PKGBUILD b/PKGBUILD index 8ee27cb..267c935 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -10,3 +10,26 @@ depends=('gcc-libs') license=('MIT' 'custom') url="https://github.com/moogoesmeow0/dibble" +prepare() { + cd "$srcdir/$pkgname-$pkgver" + export RUSTUP_TOOLCHAIN=stable + cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')" +} + +build() { + cd "$srcdir/$pkgname-$pkgver" + export RUSTUP_TOOLCHAIN=stable + export CARGO_TARGET_DIR=target + cargo build --frozen --release --all-features +} + +package() { + cd "$srcdir/$pkgname-$pkgver" + + install -Dm755 "target/release/$pkgname" "$pkgdir/usr/bin/$pkgname" + + # install dict files + install -dm755 "$pkgdir/usr/share/dibble/dict" + cp -r dict/* "$pkgdir/usr/share/dibble/dict/" + +} diff --git a/src/main.rs b/src/main.rs index 156c816..47f50c8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,21 +57,34 @@ fn main() -> Result<()> { fn read_data(path: PathBuf) -> Result { let dirs: ProjectDirs = ProjectDirs::from("com.taranathan.dibble", "taran", "dibble").unwrap(); - // let mut file = File::open(dirs.data_dir())?; - // let mut contents = String::new(); - // file.read_to_string(&mut contents)?; - - let mut target = dirs.data_dir().to_path_buf(); - target.push(Path::new("dict")); - target.push(path); - target.set_extension("json"); - dbg!(&target); + let mut user_target = dirs.data_dir().to_path_buf(); + user_target.push(Path::new("dict")); + user_target.push(&path); + user_target.set_extension("json"); + + let mut system_target = PathBuf::from("/usr/share/dibble/dict"); + system_target.push(&path); + system_target.set_extension("json"); + + if let Ok(mut file) = File::open(&user_target) { + let mut contents = String::new(); + file.read_to_string(&mut contents)?; + return Ok(contents); + } - let mut file = File::open(target)?; - let mut contents = String::new(); - file.read_to_string(&mut contents)?; + // system installation fallback + if let Ok(mut file) = File::open(&system_target) { + let mut contents = String::new(); + file.read_to_string(&mut contents)?; + return Ok(contents); + } - return Ok(contents); + // If both failed, return a helpful error + anyhow::bail!( + "Dictionary file not found. Searched:\n - {}\n - {}", + user_target.display(), + system_target.display() + ) } pub type DictionaryFile = HashMap;