diff options
| author | ruki <[email protected]> | 2021-05-13 07:20:34 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-05-13 07:20:34 +0800 |
| commit | 50aaa366492eab0d7e8d1805e3d8f195be403413 (patch) | |
| tree | 3ab28638dd5e58af875fada1f55fcb14bae8a46e | |
| parent | 82e3505800015291822dd4c2b37cc62627c0f132 (diff) | |
| parent | 5c2381bfa1b31f25117cc42b0232cc219d1834ae (diff) | |
Merge pull request #1407 from Phate6660/dev
remove gentoolkit dep, initial implementation of getting package files in pure lua
| -rwxr-xr-x | scripts/get.sh | 4 | ||||
| -rw-r--r-- | xmake/modules/package/manager/portage/find_package.lua | 33 |
2 files changed, 26 insertions, 11 deletions
diff --git a/scripts/get.sh b/scripts/get.sh index fc049b519..8363b4499 100755 --- a/scripts/get.sh +++ b/scripts/get.sh @@ -153,12 +153,12 @@ install_tools() { yum --version >/dev/null 2>&1 && $sudoprefix yum install -y git readline-devel ccache && $sudoprefix yum groupinstall -y 'Development Tools'; } || { zypper --version >/dev/null 2>&1 && $sudoprefix zypper --non-interactive install git readline-devel ccache && $sudoprefix zypper --non-interactive install -t pattern devel_C_C++; } || { pacman -V >/dev/null 2>&1 && $sudoprefix pacman -S --noconfirm --needed git base-devel ccache; } || - { emerge -V >/dev/null 2>&1 && $sudoprefix emerge -atv dev-vcs/git ccache gentoolkit; } || + { emerge -V >/dev/null 2>&1 && $sudoprefix emerge -atv dev-vcs/git ccache; } || { pkg list-installed >/dev/null 2>&1 && $sudoprefix pkg install -y git getconf build-essential readline ccache; } || # termux { pkg help >/dev/null 2>&1 && $sudoprefix pkg install -y git readline ccache ncurses; } || # freebsd { apk --version >/dev/null 2>&1 && $sudoprefix apk add git gcc g++ make readline-dev ncurses-dev libc-dev linux-headers; } } -test_tools || { install_tools && test_tools; } || my_exit "$(echo -e 'Dependencies Installation Fail\nThe getter currently only support these package managers\n\t* apt\n\t* yum\n\t* zypper\n\t* pacman\n\t* portage\nPlease install following dependencies manually:\n\t* git\n\t* build essential like `make`, `gcc`, etc\n\t* libreadline-dev (readline-devel)\n\t* ccache (optional)\n\t* gentoolkit (only for Portage if on Gentoo)')" 1 +test_tools || { install_tools && test_tools; } || my_exit "$(echo -e 'Dependencies Installation Fail\nThe getter currently only support these package managers\n\t* apt\n\t* yum\n\t* zypper\n\t* pacman\n\t* portage\nPlease install following dependencies manually:\n\t* git\n\t* build essential like `make`, `gcc`, etc\n\t* libreadline-dev (readline-devel)\n\t* ccache (optional)')" 1 projectdir=$tmpdir if [ 'x__local__' = "x$branch" ]; then if [ -d '.git' ]; then diff --git a/xmake/modules/package/manager/portage/find_package.lua b/xmake/modules/package/manager/portage/find_package.lua index f4b08a482..1b6eb27fe 100644 --- a/xmake/modules/package/manager/portage/find_package.lua +++ b/xmake/modules/package/manager/portage/find_package.lua @@ -20,6 +20,7 @@ -- imports import("core.base.option") +import("lib.detect.find_file") import("lib.detect.find_tool") import("package.manager.pkgconfig.find_package", {alias = "find_package_from_pkgconfig"}) @@ -33,24 +34,38 @@ function main(name, opt) -- init options opt = opt or {} - -- find equery - local equery = find_tool("equery") - if not equery then - return - end - -- for msys2/mingw? mingw-w64-[i686|x86_64]-xxx if opt.plat == "mingw" then name = "mingw64-runtime" -- there is only one package for mingw end -- get package files list - -- gentoolkit package is required until I can do what it does in pure lua - local list = try { function() return os.iorunv(equery.program, {"f", name}) end } - if not list then + local file_path = "/var/db/pkg/*/" .. name .. "-*/" + local file = find_file("CONTENTS", file_path) + + -- if the file couldn't be found, then the package isn't installed + if not file then return end + local file_contents = io.readfile(file) + + -- create a table for the list + local list_table = {} + + -- split entries based on newlines + local entries = file_contents:split("\n") + + -- iterate over the table created by split() + for _, entry in pairs(entries) do + -- the file path is the second element after being delimited by spaces + local split_entry = entry:split(" ")[2] + table.insert(list_table, split_entry) + end + + -- create a string out of list_table called list + local list = table.concat(list_table, "\n") + -- parse package files list local pkgconfig_dir = nil local pkgconfig_name = nil |
