-
Notifications
You must be signed in to change notification settings - Fork 14
/
configure
executable file
·197 lines (177 loc) · 4.4 KB
/
configure
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/bin/bash
VERSION=0.0.0
CFG_CMDLINE=
CFG_CROSS=
CROSS_ARCH=
DISTDIR=
MASTERDIR=
HOSTDIR=
SRCPKGS=
XSC=
_append=""
RCV=`command -v xbps-checkvers 2>/dev/null`
RCV_F="repo-checkvers.txt"
TOBUILD=
_TOBUILD=
USAGE="Usage: $0 [-a cross-arch] [-CN] [-d|-m|-h dir]"
[ -f $RCV ] || {
printf "ERROR: The 'xbps-checkvers' was not found in the PATH.\n"
exit 1
}
while getopts a:Cc:d:Nm:h:v OPT; do
case "$OPT" in
a)
CFG_CROSS="-a $OPTARG"
case "$OPTARG" in
native-*-musl|native-*)
unset CFG_CROSS CROSS_ARCH
export XBPS_ARCH=${OPTARG#native-}
;;
native) unset CFG_CROSS CROSS_ARCH;;
armv6hf) CROSS_ARCH="armv6l";;
armv6hf-musl) CROSS_ARCH="armv6l-musl";;
armv7|armv7hf) CROSS_ARCH="armv7l";;
armv7-musl|armv7hf-musl) CROSS_ARCH="armv7l-musl";;
*) CROSS_ARCH="$OPTARG";;
esac
;;
v)
printf "xbps-bulk version $VERSION\n"
exit 0
;;
C)
rm -rf tobuild built
rm -f *.txt Makefile
exit 0
;;
d)
[ -d $OPTARG ] || {
printf "ERROR: Cannot find DISTDIR "
printf "'%s': No such file or directory.\n" "$OPTARG"
exit 1
}
DISTDIR="$OPTARG"
;;
N) CFG_LOCAL="-N";;
m)
[ -d $OPTARG ] || {
printf "ERROR: Cannot find MASTERDIR "
printf "'%s': No such file or directory.\n" "$OPTARG"
exit 1
}
MASTERDIR="$OPTARG"
;;
h)
[ -d $OPTARG ] || {
printf "ERROR: Cannot find HOSTDIR "
printf "'%s': No such file or directory.\n" "$OPTARG"
exit 1
}
HOSTDIR="$OPTARG"
;;
\?)
printf "%s\n" "$USAGE"
exit 1
;;
esac
done
shift $(($OPTIND - 1))
# Assign defaults
: ${DISTDIR:=$HOME/xbps-packages}
: ${MASTERDIR:=$DISTDIR/masterdir}
: ${HOSTDIR:=$DISTDIR/hostdir}
SRCPKGS=$DISTDIR/srcpkgs
XBPS_SRCPKGDIR=$SRCPKGS
XSC="$DISTDIR/xbps-src $CFG_CROSS $CFG_LOCAL -L $CFG_CMDLINE -m $MASTERDIR -H $HOSTDIR"
if [ -n "$CFG_CROSS" ]; then
export XBPS_TARGET_ARCH=$CROSS_ARCH
fi
RCV_CMD_LINE="$RCV --distdir=${DISTDIR} ${*}"
printf "INFO: Getting list of updates, please wait...\n"
printf "INFO: Running '$RCV_CMD_LINE' (${CROSS_ARCH:-native}) ...\n"
[ -f $RCV_F ] && _append="-a"
$RCV_CMD_LINE | tee ${_append} $RCV_F
if [ 0 -ne ${PIPESTATUS[0]} ]; then
printf "ERROR: xbps-checkvers exited with an error: %d\n" ${PIPESTATUS[0]}
exit 1
fi
grep pkgname $RCV_F | awk '{ print $2 }' > pkgs.txt
printf "INFO: Creating source targets...\n"
rm -rf tobuild built
mkdir -p tobuild built
for p in `cat pkgs.txt`; do
if [ -f "$SRCPKGS/$p/template" ]; then
touch tobuild/$p
fi
done
_TOBUILD="`find tobuild -type f`"
concat() {
local found=0
for tb in $TOBUILD; do
if [ "$1" = "$tb" ]; then
found=1
break
fi
done
if [ $found -eq 0 ]; then
TOBUILD="$TOBUILD $1"
fi
}
getlink() {
local p="`basename $1`"
local target="`readlink $SRCPKGS/$p`"
if [ $? -eq 0 -a -n "$target" ]; then
p=$target
fi
echo $p
}
printf "INFO: Generating a proper list (without subpkgs)...\n"
for tb in $_TOBUILD; do
concat "`getlink $tb`"
done
printf "INFO: Removing old Makefile (if any)...\n"
[ -f Makefile ] && rm -f Makefile
touch Makefile
printf "INFO: Generating standard targets...\n"
printf "# Generated by configure, do not modify.\n\n" >> Makefile
printf "PKGS = $TOBUILD\n" >> Makefile
printf "TOBUILD = \$(patsubst %%,tobuild/%%,\$(PKGS))\n" >> Makefile
printf "BUILT = \$(patsubst tobuild/%%,built/%%,\$(TOBUILD))\n\n" >> Makefile
printf "all: \$(BUILT)\n" >> Makefile
printf "\t@echo \"[Done]\"\n\n" >> Makefile
printf "print_pkgs:\n" >> Makefile
printf "\t@echo \$(PKGS)\n\n" >> Makefile
printf "built/%%: tobuild/%%\n" >> Makefile
printf "\t@echo \"[xbps-src]\t\${@F}\"\n" >> Makefile
printf "\t@$XSC pkg \${@F}\n" >> Makefile
printf "\t@touch \$@\n" >> Makefile
printf "\t@rm tobuild/\${@F}\n\n" >> Makefile
printf "INFO: Finding and adding dependencies...\n"
printf "# Dependencies\n" >> Makefile
for p in $TOBUILD; do
sedcmd="s|[<>].*\$||g"
_deps="`$XSC show-build-deps $p | sed -e \"$sedcmd\"`"
deps=
for d in $_deps; do
found=0
realdep=`getlink $d`
for _p in $TOBUILD; do
if [ "$_p" = "$realdep" ]; then
found=1
break;
fi
done
if [ $found -gt 0 ]; then
deps="$deps built/$realdep"
fi
done
printf "built/$p: $deps\n" >> Makefile
done
printf "\n" >> Makefile
printf "clean:\n" >> Makefile
printf "\t@rm -f built/*\n" >> Makefile
printf "\t@echo \"[Clean]\"\n\n" >> Makefile
printf ".PHONY: all print_pkgs clean\n" >> Makefile
printf "INFO: 'Makefile' generated.\n"
printf "INFO: Type 'make'\n"
exit 0