summaryrefslogtreecommitdiff
path: root/eclass/flx-tools.eclass
blob: 32207daacd8be6687dfea9d106ffa5f3def058a3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

#
# Original Author: root
# Purpose: 
#

HOMEPAGE="http://formilux.org"

function unpack_plist ()
{
	[ $# -ne 2 ] \
		&& die "unpack_plist <category> <dst>"

	local cat=$1
	local dst="$2"

	[ ! -d "$dst" ] \
		&& mkdir -p "$dst"

	local t
	[ -e "$PORTAGE_CONFIGROOT/etc/portage/plist/${cat}/transform" ] \
		&& t=(
			$(< $PORTAGE_CONFIGROOT/etc/portage/plist/${cat}/transform)
		)

	find "$PORTAGE_CONFIGROOT/etc/portage/plist/${cat}" \
			-mindepth 2 -maxdepth 2 \
			-type f -printf '%P\n' | sort \
		| while read ; do
			[ "$(best_version ~$REPLY)" != "$REPLY" ] \
				&& ewarn "You should update $PORTAGE_CONFIGROOT/etc/portage/plist/${cat}/$REPLY"

			[ ! -e "$PKGDIR/${REPLY}.tbz2" ] \
				&& die "Can't find $PKGDIR/${REPLY}.tbz2"

			einfo "Extracting ${REPLY} ..."
			qtbz2 --tarbz2 -O "$PKGDIR/${REPLY}.tbz2" \
				| tar xvpj --atime-preserve --show-transformed-names \
					-C "$dst" \
					-T "$PORTAGE_CONFIGROOT/etc/portage/plist/${cat}/${REPLY}" \
					${t[@]/#/--transform } \
				| while read ; do
					einfo "  $REPLY"
				done
		done
}

function check_symbol ()
{
	[ $# -ne 1 ] \
		&& die "chk_dep <fs dir>"

	local dir="$1"
	[ ! -d "$dir" ] \
		&& die "fs dir $dir does not exist"

	mkdir NEEDED SONAME
	einfo "Checking NEEDED and SONAME mismatches ..."

	scanelf -RqBn "$dir" \
		| sed -e "s;$dir/;;" \
		| awk '{
			size=split($1,libs,",")
			for (i = 1 ; i <= size ; i++) {
				print $2 >> "'NEEDED/'"libs[i]
			}
		}'

	scanelf -RqBS "$dir" \
		| sed -e "s;dir/;;" \
		| awk '{
			size=split($1,libs,",")
			for (i = 1 ; i <= size ; i++) {
				print $2 >> "'SONAME/'"libs[i]
			}
		}'

	diff -Nu \
		<(find SONAME -mindepth 1 \
				-printf '%f\n' \
			| sort) \
		<(find NEEDED -mindepth 1 \
				-printf '%f\n' \
			| sort) \
		| egrep '^(\-|\+)[a-zA-Z0-9]' \
		| while read ; do
			case ${REPLY:0:1} in
				-) ewarn "${REPLY:1} is needed by nothing" ;;
				+) ewarn "${REPLY:1} is missing but needed by :"
				   cat NEEDED/${REPLY:1}
				   ;;
			esac
		done

#	| fgrep -v \
#		-f /etc/portage/crossdev/libdl.lst \
#		-f /etc/portage/crossdev/lib-nosoname.lst \
}

function big_compress ()
{
	[ $# -ne 1 ] \
		&& die "big_compress <dir>"

	find ${1} -type d -name bin -or -name sbin \
		| xargs --no-run-if-empty -I {} -- \
	find {} -type f \
		| xargs --no-run-if-empty -- \
	scanelf -mBF '%F' \
		| xargs --no-run-if-empty -- \
	sstrip -z
}