forked from void-linux/void-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# This hook executes the following tasks: | ||
# - generates shlib-provides file for xbps-create(8) | ||
|
||
get_symbols() { | ||
local _destdir="$1" _fname="$2" _soname="$3" | ||
local _addr _type _sym | ||
local _path="${_fname#$_destdir}" | ||
_path=${_path%/*} | ||
$NM -Dg --defined-only $_fname | while read _addr _type _sym; do | ||
echo "${_path}/$_soname $_sym ${pkgname}-${version}" | ||
echo "${_path}/$_soname $_sym ${pkgname}-${version}" >&2 | ||
done | ||
} | ||
|
||
get_old_symbols() { | ||
local _destdir="$1" _fname="$2" | ||
$XBPS_QUERY_CMD -R --cat "/usr/lib/symbols/${pkgname}" "$pkgname" || : | ||
} | ||
|
||
merge_symbols() { | ||
awk ' | ||
{x[$1][$2]=$3} | ||
END{ | ||
for (k in x) for (k1 in x[k]) printf "%s %s %s\n",k,k1,x[k][k1] | ||
}' | ||
} | ||
|
||
collect_symbols() { | ||
local _destdir="$1" | ||
local _soname | ||
|
||
if [ ! -d ${_destdir} ]; then | ||
return 0 | ||
fi | ||
mkdir -p "${_destdir}/usr/lib/symbols" | ||
|
||
find ${_destdir} -type f -name "*.so*" | while read f; do | ||
_fname="${f##*/}" | ||
case "$(file -bi "$f")" in | ||
application/x-sharedlib*|application/x-pie-executable*) | ||
_soname=$(${OBJDUMP} -p "$f"|grep SONAME|awk '{print $2}') | ||
get_symbols "$_destdir" "$f" "$_soname" | ||
get_old_symbols "$_destdir" "$f" "$_soname" | ||
;; | ||
esac | ||
done | merge_symbols >"${_destdir}/usr/lib/symbols/${pkgname}" | ||
} | ||
|
||
hook() { | ||
local _destdir32=${XBPS_DESTDIR}/${pkgname}-32bit-${version} | ||
|
||
if [ -z "$shlib_provides" -a "${archs// /}" = "noarch" -o -n "$noshlibprovides" ]; then | ||
return 0 | ||
fi | ||
|
||
# native pkg | ||
collect_symbols ${PKGDESTDIR} | ||
# 32bit pkg | ||
collect_symbols ${_destdir32} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Template file for 'testbin' | ||
pkgname=testbin | ||
version=0.2 | ||
revision=1 | ||
hostmakedepends="" | ||
makedepends="testlib-devel" | ||
depends="" | ||
short_desc="symbol package version test" | ||
maintainer="Duncaen <duncaen@voidlinux.org>" | ||
license="BSD-2-clause" | ||
homepage="https://voidlinux.org" | ||
|
||
do_build() { | ||
echo "#include <stdio.h>" >main.c | ||
echo "#include <testlib.h>" >>main.c | ||
case "${version}" in | ||
0.1) | ||
echo 'int main(void) { printf("%d\n", foo()); return 0; }' >>main.c | ||
;; | ||
0.2) | ||
echo 'int main(void) { printf("%d %d\n", foo(), bar()); return 0; }' >>main.c | ||
;; | ||
esac | ||
$CC $CFLAGS -c -o main.o main.c | ||
$CC $LDFLAGS -o testbin main.c -ltestlib | ||
} | ||
|
||
do_install() { | ||
vbin testbin | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
testlib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Template file for 'testlib' | ||
pkgname=testlib | ||
version=0.2 | ||
revision=1 | ||
hostmakedepends="" | ||
makedepends="" | ||
depends="" | ||
short_desc="symbol package version test" | ||
maintainer="Duncaen <duncaen@voidlinux.org>" | ||
license="BSD-2-clause" | ||
homepage="https://voidlinux.org" | ||
|
||
do_build() { | ||
case "$version" in | ||
0.1) | ||
echo "int foo(void);" >testlib.h | ||
echo "int foo(void) { return 1; }" >testlib.c | ||
$CC $CFLAGS -c -o testlib.o testlib.c | ||
$CC -shared $LDFLAGS -Wl,-soname,libtestlib.so.0 testlib.o -o libtestlib.so.${version} | ||
ln -sf libtestlib.so.${version} libtestlib.so.0 | ||
ln -sf libtestlib.so.${version} libtestlib.so | ||
;; | ||
0.2) | ||
echo "int foo(void);" >testlib.h | ||
echo "int bar(void);" >>testlib.h | ||
echo "int foo(void) { return 1; }" >testlib.c | ||
echo "int bar(void) { return 1; }" >>testlib.c | ||
$CC $CFLAGS -c -o testlib.o testlib.c | ||
$CC -shared $LDFLAGS -Wl,-soname,libtestlib.so.0 testlib.o -o libtestlib.so.${version} | ||
ln -sf libtestlib.so.${version} libtestlib.so.0 | ||
ln -sf libtestlib.so.${version} libtestlib.so | ||
;; | ||
esac | ||
} | ||
|
||
do_install() { | ||
vmkdir usr/lib | ||
vinstall libtestlib.so.${version} 755 usr/lib | ||
vcopy libtestlib.so* usr/lib | ||
vinstall testlib.h 644 usr/include | ||
} | ||
|
||
testlib-devel_package() { | ||
short_desc+=" - development files" | ||
depends="${sourcepkg}>=${version}_${revision}" | ||
pkg_install() { | ||
vmove usr/include | ||
vmove "usr/lib/*.so" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/sh | ||
|
||
mktestlib() { | ||
local version="$1" | ||
sed -i "s/version=.*/version=$version/" srcpkgs/testlib/template | ||
./xbps-src -f pkg testlib >/dev/null || exit 1 | ||
echo "symbols for $version:" | ||
xbps-query \ | ||
--repository=hostdir/binpkgs/ \ | ||
--repository=hostdir/binpkgs/symbol-map \ | ||
--cat /usr/lib/symbols/testlib testlib || exit 1 | ||
} | ||
|
||
mktestbin() { | ||
local version="$1" | ||
sed -i "s/version=.*/version=$version/" srcpkgs/testbin/template | ||
./xbps-src -f pkg testbin >/dev/null || exit 1 | ||
echo "deps for testbin-$version:" | ||
xbps-query \ | ||
--repository=hostdir/binpkgs/ \ | ||
--repository=hostdir/binpkgs/symbol-map \ | ||
-x testbin || exit 1 | ||
} | ||
|
||
rm -rf hostdir/binpkgs/symbol-map | ||
mktestlib "0.1" | ||
mktestbin "0.1" | ||
mktestlib "0.2" | ||
mktestbin "0.2" |