ksud: fix broken /system/vendor when it is a symlink
This commit is contained in:
@@ -13,6 +13,11 @@ fn mount_partition(partition: &str, lowerdir: &mut Vec<String>) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if /partition is a symlink and linked to /system/partition, then we don't need to overlay it separately
|
||||
if Path::new(&format!("/{}", partition)).read_link().is_ok() {
|
||||
println!("partition: {} is a symlink", partition);
|
||||
return;
|
||||
}
|
||||
// add /partition as the lowerest dir
|
||||
let lowest_dir = format!("/{}", partition);
|
||||
lowerdir.push(lowest_dir.clone());
|
||||
@@ -67,7 +72,9 @@ pub fn do_systemless_mount(module_dir: &str) -> Result<()> {
|
||||
system_lowerdir.push(format!("{}", module_system.display()));
|
||||
|
||||
for part in &partition {
|
||||
let part_path = Path::new(&module_system).join(part);
|
||||
// if /partition is a mountpoint, we would move it to $MODPATH/$partition when install
|
||||
// otherwise it must be a symlink and we don't need to overlay!
|
||||
let part_path = Path::new(&module).join(part);
|
||||
if !part_path.exists() {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -281,6 +281,22 @@ is_legacy_script() {
|
||||
return $?
|
||||
}
|
||||
|
||||
handle_partition() {
|
||||
# if /system/vendor is a symlink, we need to move it out of $MODPATH/system, otherwise it will be overlayed
|
||||
# if /system/vendor is a normal directory, it is ok to overlay it and we don't need to overlay it separately.
|
||||
if [ ! -e $MODPATH/system/$1 ]; then
|
||||
# no partition found
|
||||
return;
|
||||
fi
|
||||
|
||||
if [ -L "/system/$1" ] && [ "$(readlink -f /system/$1)" = "/$1" ]; then
|
||||
ui_print "- Handle partition /$1"
|
||||
# we create a symlink if module want to access $MODPATH/system/$1
|
||||
# but it doesn't always work(ie. write it in post-fs-data.sh would fail because it is readonly)
|
||||
mv -f $MODPATH/system/$1 $MODPATH/$1 && ln -sf /$1 $MODPATH/system/$1
|
||||
fi
|
||||
}
|
||||
|
||||
# Require OUTFD, ZIPFILE to be set
|
||||
install_module() {
|
||||
rm -rf $TMPDIR
|
||||
@@ -355,6 +371,10 @@ install_module() {
|
||||
[ -f $MODPATH/customize.sh ] && . $MODPATH/customize.sh
|
||||
fi
|
||||
|
||||
handle_partition vendor
|
||||
handle_partition system_ext
|
||||
handle_partition product
|
||||
|
||||
# Handle replace folders
|
||||
for TARGET in $REPLACE; do
|
||||
ui_print "- Replace target: $TARGET"
|
||||
|
||||
Reference in New Issue
Block a user