5
5
CONFFILE="/etc/apt/apt-build.conf"
10
# We need to set RET empty in case of /proc/cpuinfo is missing
12
case "`dpkg-architecture -qDEB_HOST_ARCH`" in
13
i[3-9]86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686)
14
if [ -r /proc/cpuinfo ]; then
15
case "`grep 'vendor_id' /proc/cpuinfo | cut -d ':' -f 2 | head -n 1`" in
17
db_input critical apt-build/arch_amd || true
19
db_get apt-build/arch_amd
22
db_input critical apt-build/arch_intel || true
24
db_get apt-build/arch_intel
30
db_input critical apt-build/arch_sparc || true
32
db_get apt-build/arch_sparc
35
db_input critical apt-build/arch_alpha || true
37
db_get apt-build/arch_alpha
40
db_input critical apt-build/arch_arm || true
42
db_get apt-build/arch_arm
45
db_input critical apt-build/arch_amd64 || true
47
db_get apt-build/arch_amd64
55
db_get apt-build/olevel
58
db_get apt-build/build_dir
60
db_get apt-build/repository_dir
62
db_get apt-build/add_to_sourceslist
63
add_to_sourceslist="$RET"
64
db_get apt-build/options
66
db_get apt-build/make_options
7
# remove obsolete config file from apt-build <= 0.12.37
8
if dpkg-maintscript-helper supports rm_conffile 2>/dev/null ; then
9
dpkg-maintscript-helper rm_conffile /etc/apt/sources.list.d/apt-build -- "$@"
12
if [ "$1" = "configure" ] ; then
72
13
. /usr/share/debconf/confmodule
15
db_get apt-build/olevel
28
db_get apt-build/build_dir
31
db_get apt-build/repository_dir
34
db_get apt-build/add_to_sourceslist
35
add_to_sourceslist="$RET"
37
db_get apt-build/options
40
db_get apt-build/make_options
43
db_get apt-build/archtype
76
if [ ! -e "$build_dir" ]; then
48
if [ ! -e "$build_dir" ] ; then
80
52
# Create repository_dir
81
if [ ! -e "$repository_dir" ]; then
82
mkdir -p "$repository_dir"
88
ln -s . binary-`dpkg --print-architecture`
91
sed s/__arch__/`dpkg --print-architecture`/ /usr/share/apt-build/Release > "$repository_dir/Release"
93
# Add to sources.list if asked
94
if [ "$add_to_sourceslist" = "true" ] && [ -z "`grep "$repository_dir" /etc/apt/sources.list`" ]; then
95
tempfile=`tempfile -m 644`
96
echo "deb file:$repository_dir apt-build main" > $tempfile
97
mv $tempfile /etc/apt/sources.list.d/apt-build.list
53
if [ ! -e "$repository_dir" ] ; then
54
mkdir -p "$repository_dir"/dists/apt-build/main
55
ln -s ../../.. "$repository_dir"/dists/apt-build/main/binary-$(dpkg --print-architecture)
58
# link release file for apt-build distribution (for upgrade from 0.12.41)
59
if [ ! -e "$repository_dir"/dists/apt-build/Release ] ; then
60
ln -s ../../Release "$repository_dir"/dists/apt-build/Release
63
sed s/__arch__/$(dpkg --print-architecture)/ /usr/share/apt-build/Release > "$repository_dir/Release"
66
# prepare sources.list entry
67
eval $(apt-config shell etcdir Dir::Etc)
68
eval $(apt-config shell sourceslist Dir::Etc::sourcelist)
69
eval $(apt-config shell sourcesparts Dir::Etc::sourceparts)
70
sourceslist=/"$etcdir""$sourceslist"
71
sourcesparts=/"$etcdir""$sourcesparts"
72
aptbuildsource="$sourcesparts"/apt-build.list
73
debline="deb file:$repository_dir apt-build main"
76
# run loop to prevent errors if some sources does not exist
77
for source in "$sourceslist" "$sourcesparts"/*.list ; do
78
if [ -e "$source" ] ; then
79
# comment in all sources lists if asked
80
if [ "$add_to_sourceslist" = "false" ] ; then
81
sed -i -e "s|^[:space:]*$debline.*|#$debline|" "$source"
83
# check if source entry is already enabled
84
elif grep -Eq "^[[:space:]]*$debline" "$source" ; then
90
# do not modify anything if source entry is already enabled
91
if [ "$add_to_sourceslist" = "true" ] && [ $src_enabled = "false" ] ; then
92
if [ ! -e "$sourcesparts" ] ; then
93
mkdir -p "$sourcesparts"
96
if [ ! -e "$aptbuildsource" ] ; then
97
echo "$debline" > "$aptbuildsource"
100
if grep -q "$debline" "$aptbuildsource" ; then
101
# modify only first occurrence of $debline to prevent duplicate entries
102
sed -i -e "0,\|^.*$debline|s||$debline|" "$aptbuildsource"
104
echo "$debline" >> "$aptbuildsource"
100
108
# Remove one-byte Packages file created by old postinst
101
if [ -f $repository_dir/Packages.gz ] && [ $(zcat $repository_dir/Packages.gz | wc -c) -eq 1 ]; then
102
rm -f $repository_dir/Packages.gz
109
if [ -f $repository_dir/Packages.gz ] && [ $(zcat $repository_dir/Packages.gz | wc -c) -eq 1 ] ; then
110
rm -f $repository_dir/Packages.gz
105
if [ ! -e "$repository_dir/Packages.gz" ]; then
106
gzip -9 < /dev/null > "$repository_dir/Packages.gz"
113
if [ ! -e "$repository_dir/Packages.gz" ] ; then
114
gzip -9 < /dev/null > "$repository_dir/Packages.gz"
111
echo "build-dir = $build_dir" > $CONFFILE
112
echo "repository-dir = $repository_dir" >> $CONFFILE
116
echo "Olevel = -O1" >> $CONFFILE
119
echo "Olevel = -O2" >> $CONFFILE
122
echo "Olevel = -O3" >> $CONFFILE
126
# echo "march = -march=$arch" >> $CONFFILE
127
echo "mtune = -mtune=$arch" >> $CONFFILE
128
echo "options = \" $options\"" >> $CONFFILE
129
echo "make_options = \" $make_options\"" >> $CONFFILE
134
upgrade|abort-upgrade|abort-remove|abort-deconfigure)
138
echo "postinst called with unknown argument \`$1'" >&2
118
# Configuration options
119
# if config file does not exist
120
if [ ! -e $CONFFILE ] ; then
121
echo "build-dir =" > $CONFFILE
122
echo "repository-dir =" >> $CONFFILE
123
echo "Olevel =" >> $CONFFILE
124
#echo "march =" >> $CONFFILE
125
echo "mtune =" >> $CONFFILE
126
echo "options =" >> $CONFFILE
127
echo "make_options =" >> $CONFFILE
130
cp -a -f $CONFFILE $CONFFILE.tmp
132
# (re)add deleted or commented variables
133
test -z "build-dir" || grep -Eq '^[[:space:]]*build-dir =' $CONFFILE || \
134
echo "build-dir =" >> $CONFFILE
135
test -z "repository-dir" || grep -Eq '^[[:space:]]*repository-dir =' $CONFFILE || \
136
echo "repository-dir =" >> $CONFFILE
137
test -z "Olevel" || grep -Eq '^[[:space:]]*Olevel =' $CONFFILE || \
138
echo "Olevel =" >> $CONFFILE
139
#test -z "march" || grep -Eq '^[[:space:]]*march =' $CONFFILE || \
140
# echo "march =" >> $CONFFILE
141
test -z "mtune" || grep -Eq '^[[:space:]]*mtune =' $CONFFILE || \
142
echo "mtune =" >> $CONFFILE
143
test -z "options" || grep -Eq '^[[:space:]]*options =' $CONFFILE || \
144
echo "options =" >> $CONFFILE
145
test -z "make_options" || grep -Eq '^[[:space:]]*make_options =' $CONFFILE || \
146
echo "make_options =" >> $CONFFILE
148
sed -e "s|^[:space:]*build-dir =.*|build-dir = $build_dir|" \
149
-e "s|^[:space:]*repository-dir =.*|repository-dir = $repository_dir|" \
150
-e "s|^[:space:]*Olevel =.*|Olevel = $Olevel|" \
151
-e "s|^[:space:]*mtune =.*|mtune = $mtune|" \
152
-e "s|^[:space:]*options =.*|options = \" $options\"|" \
153
-e "s|^[:space:]*make_options =.*|make_options = \" $make_options\"|" \
154
< $CONFFILE > $CONFFILE.tmp
156
mv -f $CONFFILE.tmp $CONFFILE