diff options
| author | ruki <[email protected]> | 2017-09-21 00:23:19 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-09-20 20:20:00 +0800 |
| commit | 79b9be402d6b8676714fad3f979371289fea4128 (patch) | |
| tree | 9e758cbaafa3d6bb194af78e85771cb78f50fd95 | |
| parent | ac393411a927991097b7c38eb63a374ad27314b0 (diff) | |
add admin perm tips for pacman
| -rw-r--r-- | xmake/modules/package/manager/pacman/install.lua | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/xmake/modules/package/manager/pacman/install.lua b/xmake/modules/package/manager/pacman/install.lua index 945dc00d7..7e449654a 100644 --- a/xmake/modules/package/manager/pacman/install.lua +++ b/xmake/modules/package/manager/pacman/install.lua @@ -25,6 +25,7 @@ -- imports import("core.base.option") import("lib.detect.find_tool") +import("privilege.sudo") -- install package -- @@ -50,9 +51,35 @@ function main(name, opt) table.insert(argv, "--verbose") end - -- TODO sudo - -- install package - os.vrunv(pacman.program, argv) + -- install package directly if the current user is root + if os.isroot() then + os.vrunv(pacman.program, argv) + -- install with administrator permission? + elseif sudo.has() then + + -- get confirm + local confirm = option.get("yes") + if confirm == nil then + + -- show tips + cprint("${bright yellow}note: ${default yellow}try to install %s with administrator permission?", name) + cprint("please input: y (y/n)") + + -- get answer + io.flush() + local answer = io.read() + if answer == 'y' or answer == '' then + confirm = true + end + end + + -- install it if be confirmed + if confirm then + sudo.vrunv(pacman.program, argv) + end + else + return false + end -- ok return true |
