summaryrefslogtreecommitdiff
blob: 2a8d82e5e223b34b663a397364c7e248689b71cd (plain)
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
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# Author:  Martin Schlemmer <azarah@gentoo.org>
# $Header: /var/cvsroot/gentoo-x86/sys-devel/gcc/files/awk/fixlafiles.awk,v 1.2 2002/11/24 04:03:55 azarah Exp $

function einfo(string)
{
	system("echo -e \" \\e[32;01m*\\e[0m " string "\"")
}

function ewarn(string)
{
	system("echo -e \" \\e[33;01m*\\e[0m " string "\"")
}

function eerror(string)
{
	system("echo -e \" \\e[31;01m*\\e[0m " string "\"")
}


BEGIN {

	while((getline ldsoconf_data < ("/etc/ld.so.conf")) > 0) {

		if (ldsoconf_data !~ /[[:space:]]*#/) {

			if (ldsoconf_data == "") continue
	
			split(ldsoconf_data, nodes, /[:,[:space:]]/)

			DIRLIST[1] = "/lib"
			DIRLIST[2] = "/usr/lib"

			for (x in nodes) {

				sub(/=.*/, "", nodes[x])
				sub(/\/$/, "", nodes[x])

				if (nodes[x] == "") continue
		
				DIRLIST[++i + 2] = nodes[x]
			}
		}
	}

	close("/etc/ld.so.conf")

	pipe = "/usr/bin/python -c 'import portage; print portage.settings[\"CHOST\"];'"
	(pipe) | getline CHOST
	close(pipe)

	GCCLIB = "/usr/lib/gcc-lib/" CHOST

	sub(/\/$/, "",  GCCLIB)

	pipe = "gcc -dumpversion"
	(pipe) | getline NEWVER
	close(pipe)
	
	for (x in DIRLIST) {
		
		if (DIRLIST[x] ~ GCCLIB) continue

		einfo("Scanning " DIRLIST[x] "...")

		pipe = "ls -1 " DIRLIST[x] "/*.la 2>/dev/null"
		while (((pipe) | getline la_files) > 0) {

			CHANGED = 0

			while ((getline la_data < (la_files)) > 0) {

				if (gsub(GCCLIB "/" OLDVER "/", GCCLIB "/" NEWVER "/", la_data) > 0)
					CHANGED = 1

				if (gsub(GCCLIB "/" OLDVER "[[:space:]]", GCCLIB "/" NEWVER " ", la_data) > 0)
					CHANGED = 1
			}

			close(la_files)

			if (CHANGED) {

				ewarn("  FIXING: " la_files)

				while ((getline la_data < (la_files)) > 0) {

					gsub(GCCLIB "/" OLDVER "/", GCCLIB "/" NEWVER "/", la_data)
					gsub(GCCLIB "/" OLDVER "[[:space:]]", GCCLIB "/" NEWVER " ", la_data)

					print la_data >> (la_files ".new")
				}

				close(la_files ".new")

				system("mv -f " la_files ".new " la_files)
			}
		}

		close(pipe)
	}
}