Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issues 1261 #1262

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

fix issues 1261 #1262

wants to merge 2 commits into from

Conversation

Greyh4t
Copy link

@Greyh4t Greyh4t commented Jan 6, 2024

fix #1261

@tiann
Copy link
Owner

tiann commented Jan 8, 2024

#816

I think this may cause other issues

@Greyh4t
Copy link
Author

Greyh4t commented Jan 8, 2024

#816

I think this may cause other issues

我检查了你给的这个 issue,发现如果用 mv -f ,我之前的修复会导致 product 已经存在的情况下无法被合并。可以用 cp -rf 来解决这个问题,代码已经更新,按照新的解决方法,可以看看修改后下面两种 case 分别会怎么执行

假设 MODPATH=/data/adb/modules/myapp

CASE1

REMOVE="
/system/product/app/A
"
模块内文件结构如下
/data/adb/modules/myapp
└── system
    └── product
        └── app
            └── B

此时 mark_remove 会执行如下命令

mkdir -p /data/adb/modules/myapp/system/product/app
mknod /data/adb/modules/myapp/system/product/app/A c 0 0
chmod 644 /data/adb/modules/myapp/system/product/app/A

接下来 handle_partition 会执行

cp -rf /data/adb/modules/myapp/system/product /data/adb/modules/myapp/ && rm -rf /data/adb/modules/myapp/system/product && ln -sf ../product /data/adb/modules/myapp/system/product

执行完模块结构是这样的

/data/adb/modules/myapp
├── product
│   └── app
│       ├── A
│       └── B
└── system
    └── product -> ../product

CASE1 执行结果符合预期

CASE2

REMOVE="
/product/app/A
"
模块内文件结构如下
/data/adb/modules/myapp
└── system
    └── product
        └── app
            └── B

此时 mark_remove 会执行如下命令

mkdir -p /data/adb/modules/myapp/product/app
mknod /data/adb/modules/myapp/product/app/A c 0 0
chmod 644 /data/adb/modules/myapp/product/app/A

接下来 handle_partition 会执行

cp -rf /data/adb/modules/myapp/system/product /data/adb/modules/myapp/ && rm -rf /data/adb/modules/myapp/system/product && ln -sf ../product /data/adb/modules/myapp/system/product

执行完模块结构是这样的

/data/adb/modules/myapp
├── product
│   └── app
│       ├── A
│       └── B
└── system
    └── product -> ../product

CASE2 执行结果符合预期

@Bot-wxt1221
Copy link
Contributor

Why not merge it?It works properly

@tiann
Copy link
Owner

tiann commented Feb 17, 2024

cp -rfrm -rfmv 的行为有很多地方不一样,比如:

  1. mv 的过程很快,不会改变文件属性,但 cp 做不到。
  2. mv 可以保留特殊文件,比如符号连接,设备文件等,cp 后会变成普通文件。

在没有充分的证据之前,我认为这个修复会带来更多的问题。而本 issue 的问题,可以通过其他的方式规避。

@mywalkb
Copy link

mywalkb commented Apr 6, 2024

但 cp 做不到。

Sorry I don't speak chinese and I translated with google, I hope is correct, but cp can preserve timestamp, owernship, device, symbolic link with parameter -a
or another alternative is use tar.

  • tar cf
  • rm -rf
  • tar xf
  • ln -s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

REMOVE变量与system/product同时使用时挂载到错误的路径
4 participants