-
Notifications
You must be signed in to change notification settings - Fork 167
Expand file tree
/
Copy pathindex
More file actions
executable file
·160 lines (137 loc) · 5.58 KB
/
index
File metadata and controls
executable file
·160 lines (137 loc) · 5.58 KB
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
#!/bin/bash
if test $# -lt 2; then
echo "Usage: $0 <elixir_data_path> <project_name> [<repo_urls>...]"
echo "Usage: $0 <elixir_data_path> --all"
exit 1
fi
# $1 is the project path (inside will be created data/ and repo/).
# It supports being called on an existing project.
project_init() {
# Detect already inited projects. Avoids stderr logs.
# Using `git tag -n1` because `git status` doesn't work on bare repos.
if git -C $1/repo tag -n1 >/dev/null 2>/dev/null; then
return;
fi
mkdir -p $1/data $1/repo
git -C $1/repo -c init.defaultBranch=main init --bare
}
# $1 is the project path (parent of data/ and repo/).
# $2 is the remote URL.
project_add_remote() {
git="git -C $1/repo -c safe.directory=$1/repo"
# Do nothing if remote already exists.
if $git remote | xargs -L1 -r $git remote get-url 2>/dev/null | grep -qxF "$2"; then
return;
fi
# Remotes are called remote$i with $i = 0, 1, 2...
i="$($git remote | awk '
BEGIN { n=-1; }
$0 ~ /^remote[0-9]+$/ { i=substr($0, length("remote")+1);
if (i>n) n=i; }
END { print n+1; }')"
$git remote add remote$i "$2"
}
# $1 is the project path (parent of data/ and repo/).
project_fetch() {
git="git -C $1/repo -c safe.directory=$1/repo"
$git fetch --all --tags -j4
LXR_REPO_DIR=$1/repo LXR_DATA_DIR=$1/data \
./script.sh fetch-hook "$(realpath $1)" || exit 1
# A gc.log file implies a garbage collect failed in the past.
# Also, create a hidden flag which could be useful to trigger GCs manually.
if test -e $1/repo/gc.log -o "$ELIXIR_GC"; then
$git gc --aggressive
else
# Otherwise, give Git an occasion to trigger a GC.
# Porcelain commands should trigger that, but we don't use any.
$git gc --auto
fi
}
# $1 is the project path (parent of data/ and repo/).
project_index() {
if test -z "$ELIXIR_THREADS"; then
ELIXIR_THREADS="$(nproc)"
fi
elixir_sources="$(dirname "$(dirname "$0")")"
LXR_REPO_DIR=$1/repo LXR_DATA_DIR=$1/data \
python3 "$elixir_sources/update.py" $ELIXIR_THREADS
}
# $1 is the Elixir root data path.
# $2 is the project name.
# $... are the remote URLs.
add_remotes() {
dir="$1/$2"
project_init "$dir"
shift
shift
for remote
do
project_add_remote "$dir" "$remote"
done
}
# Call add_remotes() if no remotes are passed as arguments.
#
# $1 is the Elixir root data path.
# $2 is the CLI arg count.
# $3 is the CLI arg for project name (can be --all).
# $4 is the project name.
# $... are the default remote URLs.
add_default_remotes() {
if test $2 -eq 2 -a \( "$3" = "--all" -o "$3" = "$4" \); then
add_remotes "$1" "$4" ${@:5}
fi
}
do_index() {
if test ! "$(find $1/data -type f)"; then
# If we are indexing from scratch, do it twice as the initial one
# probably took a lot of time.
project_fetch "$1"
project_index "$1"
project_fetch "$1"
project_index "$1"
else
project_fetch "$1"
project_index "$1"
fi
}
# Add all known projects remotes. This works in two cases:
# ./utils/index <elixir_data_path> --all # => Add default remotes for all projects
# ./utils/index <elixir_data_path> musl # => Add default remote for musl
add_default_remotes $1 $# $2 amazon-freertos https://github.com/aws/amazon-freertos.git
add_default_remotes $1 $# $2 arm-trusted-firmware https://github.com/ARM-software/arm-trusted-firmware
add_default_remotes $1 $# $2 barebox https://git.pengutronix.de/git/barebox
add_default_remotes $1 $# $2 busybox https://git.busybox.net/busybox
add_default_remotes $1 $# $2 coreboot https://review.coreboot.org/coreboot.git
add_default_remotes $1 $# $2 dpdk https://dpdk.org/git/dpdk \
https://dpdk.org/git/dpdk-stable
add_default_remotes $1 $# $2 glibc https://sourceware.org/git/glibc.git
add_default_remotes $1 $# $2 llvm https://github.com/llvm/llvm-project.git
add_default_remotes $1 $# $2 mesa https://gitlab.freedesktop.org/mesa/mesa.git
add_default_remotes $1 $# $2 musl https://git.musl-libc.org/git/musl
add_default_remotes $1 $# $2 ofono https://git.kernel.org/pub/scm/network/ofono/ofono.git
add_default_remotes $1 $# $2 op-tee https://github.com/OP-TEE/optee_os.git
add_default_remotes $1 $# $2 qemu https://gitlab.com/qemu-project/qemu.git
add_default_remotes $1 $# $2 u-boot https://source.denx.de/u-boot/u-boot.git
add_default_remotes $1 $# $2 uclibc-ng https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git
add_default_remotes $1 $# $2 zephyr https://github.com/zephyrproject-rtos/zephyr
add_default_remotes $1 $# $2 toybox https://github.com/landley/toybox.git
add_default_remotes $1 $# $2 grub https://git.savannah.gnu.org/git/grub.git
add_default_remotes $1 $# $2 bluez https://git.kernel.org/pub/scm/bluetooth/bluez.git
add_default_remotes $1 $# $2 linux https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git \
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git \
https://github.com/bootlin/linux-history.git
add_default_remotes $1 $# $2 xen https://xenbits.xen.org/git-http/xen.git
add_default_remotes $1 $# $2 freebsd https://git.freebsd.org/src.git
# Index a single project
if test "x$2" != "x--all"; then
dir="$1/$2"
add_remotes "$@"
do_index "$dir"
else
# Index all projects.
# Note: this is not only the default projects ones but all the ones in $1.
find $1 -mindepth 1 -maxdepth 1 -type d | \
while read dir; do
do_index "$dir"
done
fi