ci: add CI for clippy, rustfmt and shell scripts (#193)
This commit is contained in:
@@ -13,7 +13,10 @@ fn get_git_version() -> (u32, String) {
|
||||
.stdout,
|
||||
)
|
||||
.expect("Failed to read git count stdout");
|
||||
let version_code: u32 = version_code.trim().parse().expect("Failed to parse git count");
|
||||
let version_code: u32 = version_code
|
||||
.trim()
|
||||
.parse()
|
||||
.expect("Failed to parse git count");
|
||||
let version_code = 10000 + 200 + version_code; // For historical reasons
|
||||
|
||||
let version_name = String::from_utf8(
|
||||
@@ -28,7 +31,7 @@ fn get_git_version() -> (u32, String) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let (code, name)= get_git_version();
|
||||
let (code, name) = get_git_version();
|
||||
let out_dir = env::var("OUT_DIR").expect("Failed to get $OUT_DIR");
|
||||
let out_dir = Path::new(&out_dir);
|
||||
File::create(Path::new(out_dir).join("VERSION_CODE"))
|
||||
|
||||
@@ -20,6 +20,5 @@ pub const DISABLE_FILE_NAME: &str = "disable";
|
||||
pub const UPDATE_FILE_NAME: &str = "update";
|
||||
pub const REMOVE_FILE_NAME: &str = "remove";
|
||||
|
||||
|
||||
pub const VERSION_CODE: &str = include_str!(concat!(env!("OUT_DIR"), "/VERSION_CODE"));
|
||||
pub const VERSION_NAME: &str = include_str!(concat!(env!("OUT_DIR"), "/VERSION_NAME"));
|
||||
pub const VERSION_NAME: &str = include_str!(concat!(env!("OUT_DIR"), "/VERSION_NAME"));
|
||||
|
||||
@@ -9,12 +9,16 @@ use extattr::{setxattr, Flags as XattrFlags};
|
||||
|
||||
const SYSTEM_CON: &str = "u:object_r:system_file:s0";
|
||||
const _ADB_CON: &str = "u:object_r:adb_data_file:s0";
|
||||
const SELINUX_XATTR : &str = "security.selinux";
|
||||
const SELINUX_XATTR: &str = "security.selinux";
|
||||
|
||||
pub fn setcon<P: AsRef<Path>>(path: P, con: &str) -> Result<()> {
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
setxattr(&path, SELINUX_XATTR, con, XattrFlags::empty())
|
||||
.with_context(|| format!("Failed to change SELinux context for {}", path.as_ref().display()))?;
|
||||
setxattr(&path, SELINUX_XATTR, con, XattrFlags::empty()).with_context(|| {
|
||||
format!(
|
||||
"Failed to change SELinux context for {}",
|
||||
path.as_ref().display()
|
||||
)
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -32,9 +36,9 @@ pub fn restore_syscon<P: AsRef<Path>>(dir: P) -> Result<()> {
|
||||
for dir_entry in WalkDir::new(dir).parallelism(Serial) {
|
||||
if let Some(path) = dir_entry.ok().map(|dir_entry| dir_entry.path()) {
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
setxattr(&path, SELINUX_XATTR, SYSTEM_CON, XattrFlags::empty()).with_context(
|
||||
|| format!("Failed to change SELinux context for {}", path.display()),
|
||||
)?;
|
||||
setxattr(&path, SELINUX_XATTR, SYSTEM_CON, XattrFlags::empty()).with_context(|| {
|
||||
format!("Failed to change SELinux context for {}", path.display())
|
||||
})?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -745,4 +745,4 @@ pub fn check_rule(policy: &str) -> Result<()> {
|
||||
apply_one_rule(&statement, true)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user