2024-08-05 22:37:23 +02:00
|
|
|
#[cfg(feature = "mysql-admutils-compatibility")]
|
|
|
|
use anyhow::anyhow;
|
|
|
|
#[cfg(feature = "mysql-admutils-compatibility")]
|
|
|
|
use std::{env, os::unix::fs::symlink, path::PathBuf};
|
|
|
|
|
|
|
|
fn main() -> anyhow::Result<()> {
|
|
|
|
#[cfg(feature = "mysql-admutils-compatibility")]
|
|
|
|
{
|
|
|
|
// NOTE: This is slightly illegal, and depends on implementation details.
|
|
|
|
// But it is only here for ease of testing the compatibility layer,
|
|
|
|
// and not critical in any way. Considering the code is never going
|
|
|
|
// to be used as a library, it should be fine.
|
|
|
|
let target_profile_dir: PathBuf = PathBuf::from(env::var("OUT_DIR")?)
|
|
|
|
.parent()
|
|
|
|
.and_then(|p| p.parent())
|
|
|
|
.and_then(|p| p.parent())
|
|
|
|
.ok_or(anyhow!("Could not resolve target profile directory"))?
|
|
|
|
.to_path_buf();
|
|
|
|
|
2024-08-07 16:19:40 +02:00
|
|
|
if !target_profile_dir.exists() {
|
|
|
|
std::fs::create_dir_all(&target_profile_dir)?;
|
|
|
|
}
|
2024-08-05 22:37:23 +02:00
|
|
|
|
|
|
|
if !target_profile_dir.join("mysql-useradm").exists() {
|
|
|
|
symlink(
|
|
|
|
target_profile_dir.join("mysqladm"),
|
|
|
|
target_profile_dir.join("mysql-useradm"),
|
2024-08-07 16:19:40 +02:00
|
|
|
)
|
|
|
|
.ok();
|
2024-08-05 22:37:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if !target_profile_dir.join("mysql-dbadm").exists() {
|
|
|
|
symlink(
|
|
|
|
target_profile_dir.join("mysqladm"),
|
|
|
|
target_profile_dir.join("mysql-dbadm"),
|
2024-08-07 16:19:40 +02:00
|
|
|
)
|
|
|
|
.ok();
|
2024-08-05 22:37:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|