Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions boulder/src/package/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ impl<'a> Chain<'a> {
Box::new(handler::binary),
Box::new(handler::elf),
Box::new(handler::pkg_config),
Box::new(handler::perl),
Box::new(handler::python),
Box::new(handler::cmake),
Box::new(handler::compressman),
Expand Down
37 changes: 36 additions & 1 deletion boulder/src/package/analysis/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use filetime::FileTime;
use itertools::Itertools;
use std::{
fs::File,
io::{BufReader, BufWriter, Write},
io::{BufRead, BufReader, BufWriter, Write},
os::unix::fs::symlink,
path::{Component, Path, PathBuf},
process::Command,
Expand Down Expand Up @@ -64,6 +64,41 @@ pub fn binary(bucket: &mut BucketMut<'_>, info: &mut PathInfo) -> Result<Respons
Ok(Decision::NextHandler.into())
}

// Parse the 'package' value from a .pm file e.g. package Foo::Bar;
pub fn perl(bucket: &mut BucketMut<'_>, info: &mut PathInfo) -> Result<Response, BoxError> {
Copy link
Member

@ermo ermo Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would probably benefit from documentation showing what a typical perl module line that can be parsed actually looks like.

let file_path = info.path.clone().into_os_string().into_string().unwrap_or_default();
let is_pm_file = file_path.contains("perl") && info.file_name().ends_with(".pm");

if !is_pm_file {
return Ok(Decision::NextHandler.into());
}

let reader = BufReader::new(File::open(&info.path)?);

for line in reader.lines() {
match line {
Ok(line) => {
if line.starts_with("package") {
let perl_module = line
.strip_prefix("package")
.unwrap()
.trim_start()
.strip_suffix(";")
.unwrap_or_default();
bucket.providers.insert(Provider {
kind: dependency::Kind::Perl,
name: perl_module.to_owned(),
});
break;
}
}
Err(e) => println!("ERROR: {e}"),
}
}

Ok(Decision::NextHandler.into())
}

pub fn pkg_config(bucket: &mut BucketMut<'_>, info: &mut PathInfo) -> Result<Response, BoxError> {
let file_name = info.file_name();

Expand Down
4 changes: 4 additions & 0 deletions crates/stone/src/payload/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ pub enum Dependency {

/// An emul32-compatible pkgconfig .pc dependency (lib32/*.pc)
PkgConfig32,

/// A Perl module
Perl,
}

#[repr(u8)]
Expand Down Expand Up @@ -146,6 +149,7 @@ fn decode_dependency(i: u8) -> Result<Dependency, DecodeError> {
6 => Dependency::Binary,
7 => Dependency::SystemBinary,
8 => Dependency::PkgConfig32,
9 => Dependency::Perl,
_ => return Err(DecodeError::UnknownDependency(i)),
};
Ok(result)
Expand Down
5 changes: 5 additions & 0 deletions moss/src/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ pub enum Kind {

/// Exported 32-bit pkgconfig provider
PkgConfig32,

/// Perl module
Perl,
}

/// Convert payload dependency types to our internal representation
Expand All @@ -74,6 +77,7 @@ impl From<payload::meta::Dependency> for Kind {
payload::meta::Dependency::Binary => Kind::Binary,
payload::meta::Dependency::SystemBinary => Kind::SystemBinary,
payload::meta::Dependency::PkgConfig32 => Kind::PkgConfig32,
payload::meta::Dependency::Perl => Kind::Perl,
}
}
}
Expand All @@ -91,6 +95,7 @@ impl From<Kind> for payload::meta::Dependency {
Kind::Binary => Self::Binary,
Kind::SystemBinary => Self::SystemBinary,
Kind::PkgConfig32 => Self::PkgConfig32,
Kind::Perl => Self::Perl,
}
}
}
Expand Down
Loading