Comments (8)
example output of the script (if you refuse to run such a ugly script in your machine, which is understandable )
$ xpcdeps gio-2.0
libglib-devel -> glib-2.0
libglib-devel -> gobject-2.0
$ xpcdeps gtk+-3.0
gtk+3-devel -> gdk-3.0
atk-devel -> atk
cairo-devel -> cairo
cairo-devel -> cairo-gobject
gdk-pixbuf-devel -> gdk-pixbuf-2.0
libglib-devel -> gio-2.0
$ xpcdeps libgxps
libglib-devel -> gio-2.0
libarchive-devel -> libarchive
cairo-devel -> cairo
libglib-devel -> gobject-2.0
$ xpcdeps libxbps
$ xpcdeps pangoft2
pango-devel -> pango
freetype-devel -> freetype2
fontconfig-devel -> fontconfig
from xtools.
it should be fair to ignore Requires.private since those only apply to static linking.
from xtools.
ideas: handle pcfiles for packages available via hostdir/binpkgs, this allows people adding new packages to find the dependencies required, use a tempfile with a env override so pkg-config --print-requires
can be used.
from xtools.
bad news for handling pcfiles via pkg-config --print-requires.
$ env PKG_CONFIG_PATH=/run/user/1000/tmp.jQ2zFNCzHC/ pkg-config --print-requires libpeas-1.0
Package gobject-introspection-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gobject-introspection-1.0.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gobject-introspection-1.0', required by 'libpeas-1.0', not found
from xtools.
This script uses a local file, this will allow in the future for us to extend it to use local packages in hostdir/binpkgs
#!/bin/sh
cleanup() {
[ -n "$tempdir" ] &&
[ -d "$tempdir" ] &&
rm -rf -- "$tempdir"
}
trap cleanup EXIT
tempdir="$(mktemp -d)"
grab_requires() {
for pkg in "$@" ; do
xlocate "usr/\(lib\|share\)/pkgconfig/$pkg.pc" |
{ grep . || { echo "xpcdeps: No pkg-config file for $pkg found." 1>&2 ; exit 1; } } |
while read -r pkgname file ; do
for rpkg in $( xbps-query --cat="$file" "${pkgname%-*}" | grep Requires: | cut -d: -f2 ) ; do
# This makes the iterator ignore over the version specifier available for pkg-config
# >=, <=, >, <, =, and also ignore versions by expecting a single letter
[ -z "${rpkg##*=*}" ] && continue
[ -z "${rpkg##*<*}" ] && continue
[ -z "${rpkg##*>*}" ] && continue
[ -z "${rpkg##*[a-zA-Z]*}" ] || continue
[ -z "$rpkg" ] && continue
echo "$rpkg" >> "$tempdir/$pkg.pc"
done
done
done
}
get_package_from_requires() {
while read -r pkg ; do
xlocate "usr/\(lib\|share\)/pkgconfig/$pkg.pc" |
{ grep . || { printf -- "UNKNOWN PKG PLEASE FIX -> %s\\n" "$pkg" 1>&2 ; continue; } } |
while read -r pkgname file ; do
file="${file##*/}"
printf -- "%s -> %s\\n" "${pkgname%-*}" "${file%*.pc}"
done
done
}
grab_requires "$@" && cat "$tempdir"/* | get_package_from_requires
from xtools.
This is a poorly optimized version that handles local packages in hostdir/binpkgs/$branch
#!/bin/sh
cleanup() {
[ -n "$tempdir" ] &&
[ -d "$tempdir" ] &&
rm -rf -- "$tempdir"
}
trap cleanup EXIT INT TERM
tempdir="$(mktemp -d)"
grab_local() {
branch=$(git symbolic-ref -q --short HEAD 2>/dev/null)
for pkg in hostdir/binpkgs/$branch/* ; do
pkg="${pkg##*/}"
pcfile="$(xbps-query -i --repository=hostdir/binpkgs/"$branch" -f "${pkg%-*}" | grep "$1.pc")"
if [ -n "$pcfile" ] ; then
printf "%s %s\\n" "${pkg%-*}" "$pcfile"
fi
done | while read -r pkgname file ; do
for rpkg in $( xbps-query --repository=hostdir/binpkgs/"$branch" --cat="$file" "$pkgname" | grep Requires: | cut -d: -f2 ) ; do
# This makes the iterator ignore over the version specifier available for pkg-config
# >=, <=, >, <, =, and also ignore versions by expecting a single letter
[ -z "${rpkg##*[<=>]*}" ] && continue
[ -z "${rpkg##*[a-zA-Z]*}" ] || continue
echo "$rpkg" >> "$tempdir/$1.pc"
done
# touch the file, it indicates we have found the file here, so it won't try to
# grab the .pc file from the outside
touch "$tempdir/$1.pc"
done
# Check if the file doesn't exist, we can't check if it empty because emptyness
# means the Requires: is defined but is empty
[ -f "$tempdir/$1.pc" ] || return 1
}
grab_requires() {
for pkg in "$@" ; do
xlocate "usr/\(lib\|share\)/pkgconfig/$pkg.pc" |
{ grep . || { echo "xpcdeps: No pkg-config file for $pkg found." 1>&2 ; exit 1; } } |
while read -r pkgname file ; do
for rpkg in $( xbps-query --cat="$file" "${pkgname%-*}" | grep Requires: | cut -d: -f2 ) ; do
# This makes the iterator ignore over the version specifier available for pkg-config
# >=, <=, >, <, =, and also ignore versions by expecting a single letter, we don't
# skip empty lines, because those lines indicate that there are no requirements
[ -z "${rpkg##*[<=>]*}" ] && continue
[ -z "${rpkg##*[a-zA-Z]*}" ] || continue
echo "$rpkg" >> "$tempdir/$pkg.pc"
done
done
done
# Check if the file doesn't exist, we can't check if it empty because emptyness
# means the Requires: is defined but is empty
[ -f "$tempdir/$1.pc" ] || exit 1
}
get_package_from_requires() {
while read -r pkg ; do
xlocate "usr/\(lib\|share\)/pkgconfig/$pkg.pc" |
{ grep . || { printf -- "UNKNOWN PKG PLEASE FIX -> %s\\n" "$pkg" 1>&2 ; continue; } } |
while read -r pkgname file ; do
file="${file##*/}"
printf -- "%s -> %s\\n" "${pkgname%-*}" "${file%*.pc}"
done
done
}
grab_local "$@" || grab_requires "$@" && cat "$tempdir"/* | get_package_from_requires
UPDATE1: changed the 3 < = > checks with [<=>], thanks leah for the suggestion
from xtools.
#!/bin/sh
cleanup() {
[ -n "$tempdir" ] &&
[ -d "$tempdir" ] &&
rm -rf -- "$tempdir"
}
trap cleanup EXIT INT TERM
tempdir="$(mktemp -d)"
# This takes 1 argument which is the name of the file to write to and reads
# lines from stdin in the form of '$pkgname $file'
create_pcfile() {
branch=$(git symbolic-ref -q --short HEAD 2>/dev/null)
while read -r pkgname file ; do
for rpkg in $( xbps-query --repository=hostdir/binpkgs/"$branch" --cat="$file" "$pkgname" | grep Requires: | cut -d: -f2 ) ; do
# This makes the iterator ignore over the version specifier available for pkg-config
# >=, <=, >, <, =, and also ignore versions by expecting a single letter
[ -z "${rpkg##*[<=>]*}" ] && continue
[ -z "${rpkg##*[a-zA-Z]*}" ] || continue
echo "$rpkg" >> "$tempdir/$1.pc"
done
done
}
grab_local() {
branch=$(git symbolic-ref -q --short HEAD 2>/dev/null)
for pkg in hostdir/binpkgs/$branch/* ; do
pkg="${pkg##*/}"
pcfile="$(xbps-query -i --repository=hostdir/binpkgs/"$branch" -f "${pkg%-*}" | grep "$1.pc")"
if [ -n "$pcfile" ] ; then
printf "%s %s\\n" "${pkg%-*}" "$pcfile"
touch "$tempdir/$1.pc"
fi
done | create_pcfile "$1"
# Check if the file doesn't exist, we can't check if it empty because emptyness
# means the Requires: is defined but is empty
[ -f "$tempdir/$1.pc" ] || return 1
}
grab_requires() {
for pkg in "$@" ; do
xlocate "usr/\(lib\|share\)/pkgconfig/$pkg.pc" |
{ grep . || { echo "xpcdeps: No pkg-config file for $pkg found." 1>&2 ; exit 1; } } |
create_pcfile "$pkg"
done
}
get_package_from_requires() {
while read -r pkg ; do
xlocate "usr/\(lib\|share\)/pkgconfig/$pkg.pc" |
{ grep . || { printf -- "UNKNOWN PKG PLEASE FIX -> %s\\n" "$pkg" 1>&2 ; continue; } } |
while read -r pkgname file ; do
file="${file##*/}"
printf -- "%s -> %s\\n" "${pkgname%-*}" "${file%*.pc}"
done
done
}
grab_local "$@" || grab_requires "$@" && cat "$tempdir"/* | get_package_from_requires
from xtools.
Here is a final-ish version.
#!/bin/sh
# xpcdeps PKGS...
cleanup() {
[ -n "$tempdir" ] &&
[ -d "$tempdir" ] &&
rm -rf -- "$tempdir"
}
trap cleanup EXIT INT TERM
tempdir="$(mktemp -d)"
# This takes 1 argument which is the name of the file to write to and reads
# lines from stdin in the form of '$pkgname $file'
create_pcfile() {
branch=$(git symbolic-ref -q --short HEAD 2>/dev/null)
while read -r pkgname file ; do
for rpkg in $( xbps-query --repository=hostdir/binpkgs/"$branch" --cat="$file" "$pkgname" | grep Requires: | cut -d: -f2 ) ; do
# This makes the iterator ignore over the version specifier available for pkg-config
# >=, <=, >, <, =, and also ignore versions by ignoring everything that doesn't have
# a letter
[ -z "${rpkg##*[<=>]*}" ] && continue
[ -z "${rpkg##*[a-zA-Z]*}" ] || continue
echo "$rpkg" >> "$tempdir/$1.pc"
done
done
}
grab_local() {
branch=$(git symbolic-ref -q --short HEAD 2>/dev/null)
for pkg in hostdir/binpkgs/$branch/* ; do
pkg="${pkg##*/}"
pcfile="$(xbps-query -i --repository=hostdir/binpkgs/"$branch" -f "${pkg%-*}" | grep "$1.pc")"
if [ -n "$pcfile" ] ; then
printf "%s %s\\n" "${pkg%-*}" "$pcfile"
touch "$tempdir/$1.pc"
fi
done | create_pcfile "$1"
# Check if the file doesn't exist, we can't check if it empty because emptyness
# means the Requires: is defined but is empty
[ -f "$tempdir/$1.pc" ] || return 1
}
grab_requires() {
for pkg in "$@" ; do
xlocate "usr/\(lib\|share\)/pkgconfig/$pkg.pc" |
{ grep . || { echo "xpcdeps: No pkg-config file for $pkg found." 1>&2 ; exit 1; } } |
create_pcfile "$pkg"
done
}
get_package_from_requires() {
while read -r pkg ; do
xlocate "usr/\(lib\|share\)/pkgconfig/$pkg.pc" |
{ grep . || { printf -- "UNKNOWN PKG PLEASE FIX -> %s\\n" "$pkg" 1>&2 ; return; } } |
while read -r pkgname file ; do
file="${file##*/}"
printf -- "%s -> %s\\n" "${pkgname%-*}" "${file%*.pc}"
done
done
}
for arg; do
grab_local "$arg" || grab_requires "$arg" && [ -f "$tempdir/$arg.pc" ] && get_package_from_requires < "$tempdir/$arg.pc"
done
from xtools.
Related Issues (20)
- xtools.1 breaks apropos output HOT 1
- xetcchanges lists files not modified HOT 3
- cannot pass arguments to `xq`
- xcheckrestart reports random stuff? HOT 6
- xlint: check for `-D$opt=$(vopt_if $opt true false)` instead of `$(vopt_bool $opt)`
- xnew <URL> shouldn't replace $pkgname in $distfiles HOT 2
- Silence vopt_if etc. spam for all scripts sourcing template
- helix support for xnew HOT 2
- [idea] xsi HOT 2
- xlint: remove trailing whitespace HOT 4
- xbloat: Script to find packages with a lot of dependencies HOT 3
- xlint: check if desc_option_<optname> is already covered by options.description
- xrevshlib: add option to consider only given package/subpackage
- xlint: lint update files too HOT 2
- xcheckrestart: reports docker/podman processes HOT 1
- xlint: add lint for `${pkgname}` in subpackage's `depends` (should use `${sourcepkg}` instead)
- bougus ask to update database even though its not outdated HOT 5
- Add Fish completions HOT 2
- xdeptree: List dependencies of package (or find closest link) HOT 6
- `xbump` thinks that subpackage with + in its name is not a subpackage HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xtools.