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

feat: preinst不再监听更新过程 #144

Merged
merged 1 commit into from
Mar 3, 2025
Merged

Conversation

fly602
Copy link
Contributor

@fly602 fly602 commented Mar 3, 2025

preinst不再监听更新过程

Log: preinst不再监听更新过程
pms: BUG-306117

preinst不再监听更新过程

Log: preinst不再监听更新过程
pms: BUG-306117
@deepin-ci-robot
Copy link

deepin pr auto review

这个preinst脚本的主要功能是在安装或升级lastore-daemon包时,执行一些特定的操作。以下是代码审查的详细意见:

语法和逻辑

  1. 变量未定义BIN_OUTPUT变量在export语句中被定义,但在脚本的其他部分没有使用。如果这个变量不需要,应该删除它。
  2. 临时目录创建mktemp命令使用了/tmp目录,这可能会导致权限问题。建议使用/var/tmp目录,因为它通常有更大的权限限制。
  3. find_lastore_daemon_deb函数:函数内部使用了local关键字来定义局部变量,这是一个好的做法。但是,函数返回值没有进行错误处理,如果find命令没有找到任何文件,函数将返回空字符串,这可能会导致后续代码出错。
  4. cd命令:在cd命令之后,脚本没有返回到原始目录,这可能会导致后续操作失败。建议使用pushdpopd来管理目录。
  5. ar命令:使用ar -x解压deb包,这可能会导致解压后的文件权限问题。建议使用dpkg-deb -x来解压deb包,这样可以保留文件权限。
  6. tar命令:使用tar -xf解压tar包,这可能会导致解压后的文件权限问题。建议使用tar -xf --strip-components=1来解压tar包,这样可以保留文件权限。
  7. 路径检查:在检查路径和文件是否存在时,应该使用-e选项来确保脚本在路径或文件不存在时退出。

代码质量

  1. 代码重复find_lastore_daemon_deb函数在两个地方被调用,可以考虑将其封装成一个函数,减少代码重复。
  2. 错误处理:脚本中没有足够的错误处理,应该添加更多的错误处理逻辑,以便在出现问题时能够提供有用的错误信息。
  3. 日志记录:脚本中没有日志记录,建议添加日志记录,以便在出现问题时能够更容易地调试。

代码性能

  1. 文件查找:使用find命令查找文件可能会导致性能问题,特别是在文件数量较多的情况下。可以考虑使用更高效的文件查找方法,例如使用find-maxdepth选项来限制搜索深度。

代码安全

  1. 临时目录权限:使用mktemp创建的临时目录的权限应该设置为最小权限,以防止未授权访问。
  2. 命令执行:在执行命令时,应该使用set -e来确保在命令失败时立即退出脚本。

综上所述,这个脚本在语法、逻辑、代码质量、性能和安全方面都有改进的空间。建议根据上述意见进行修改,以提高代码的健壮性和安全性。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ECQZXC, fly602

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fly602 fly602 merged commit c4b920e into linuxdeepin:master Mar 3, 2025
14 of 16 checks passed
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.

3 participants