2
2
set -eu
3
3
interactive_pkgs=libsdl2-dev
4
4
gem5=false
5
+ gem5_given=false
5
6
qemu=true
6
- submodules=' buildroot linux'
7
+ qemu_given=false
8
+ submodules_dir=submodules
9
+ submodules=buildroot
7
10
y=
8
11
while getopts gpqt OPT; do
9
12
case " $OPT " in
10
13
g)
11
- gem5 =true
14
+ gem5_given =true
12
15
;;
13
16
p)
14
17
submodules=" ${submodules} parsec-benchmark"
15
18
;;
16
19
q)
17
- qemu=false
20
+ qemu_given=true
18
21
;;
19
22
t)
20
23
interactive_pkgs=
@@ -23,6 +26,12 @@ while getopts gpqt OPT; do
23
26
esac
24
27
done
25
28
shift $(( $OPTIND - 1 ))
29
+ if " $gem5_given " && ! " $qemu_given " ; then
30
+ qemu=false
31
+ fi
32
+ if " $gem5_given " ; then
33
+ gem5=true
34
+ fi
26
35
27
36
# # apt-get
28
37
@@ -69,14 +78,11 @@ pkgs="$pkgs libelf-dev"
69
78
70
79
# https://stackoverflow.com/questions/20010199/determining-if-a-process-runs-inside-lxc-docker
71
80
if [ -f /.dockerenv ]; then
72
- # --jobs is not available in git 2.7.4 from Ubuntu 16.04.
73
- gitjobs=
74
81
mysudo=
75
82
# https://askubuntu.com/questions/496549/error-you-must-put-some-source-uris-in-your-sources-list
76
83
sed -Ei ' s/^# deb-src/deb-src/' /etc/apt/sources.list
77
84
y=-y
78
85
else
79
- gitjobs=" --jobs $( nproc) "
80
86
mysudo=sudo
81
87
fi
82
88
$mysudo apt-get update $y
105
111
if " $gem5 " ; then
106
112
submodules=" ${submodules} gem5"
107
113
fi
108
- submodules=" $( for submodule in ${submodules} ; do printf " submodules/${submodule} " ; done) "
109
- (
110
- set -e
111
- # Shallow cloning saves a considerable amount of time, specially because of the linux kernel.
112
- # However, git submodules are buggy as usual, and this is the best way I've found to get it done:
113
- # https://stackoverflow.com/questions/2144406/git-shallow-submodules/47374702#47374702
114
- # In particular:
115
- # - `shallow = true` on the submodule has no effect for the non default educational branches of our submodules
116
- # - QEMU's submodules point to commits that are neither under branches nor tags, and so `--shallow-submodules` fails
117
- git submodule update --depth 1 $gitjobs --init -- ${submodules}
118
- if " $qemu " ; then
119
- git -C submodules/qemu submodule update --init --recursive
120
- fi
121
- ) &
122
- # https://unix.stackexchange.com/questions/65532/why-does-set-e-not-work-inside-subshells-with-parenthesis-followed-by-an-or
123
- wait $! || git submodule update --init --recursive -- $submodules
114
+ submodules=" $( for submodule in ${submodules} ; do printf " ${submodules_dir} /${submodule} " ; done) "
115
+
116
+ # == Shallow cloning.
117
+ #
118
+ # TODO Ideally we should shallow clone --depth 1 all of them.
119
+ #
120
+ # However, most git servers out there are crap or craply configured
121
+ # and don't allow shallow cloning except for branches.
122
+ #
123
+ # So for now, let's shallow clone only the Linux kernel, which has by far
124
+ # the largest .git repo history, and full clone the others.
125
+ #
126
+ # Then we will maintain a GitHub Linux kernel mirror / fork that always has a
127
+ # lkmc branch, and point to it, so that it will always succeed.
128
+ #
129
+ # See also:
130
+ #
131
+ # * https://stackoverflow.com/questions/3489173/how-to-clone-git-repository-with-specific-revision-changeset
132
+ # * https://stackoverflow.com/questions/2144406/git-shallow-submodules/47374702#47374702
133
+ # * https://unix.stackexchange.com/questions/338578/why-is-the-git-clone-of-the-linux-kernel-source-code-much-larger-than-the-extrac
134
+ #
135
+ # == Other nice git options for when distros move to newer Git
136
+ #
137
+ # Currently not on Ubuntu 16.04:
138
+ #
139
+ # `--progress`: added on Git 2.10:
140
+ #
141
+ # * https://stackoverflow.com/questions/32944468/how-to-show-progress-for-submodule-fetching
142
+ # * https://stackoverflow.com/questions/4640020/progress-indicator-for-git-clone
143
+ #
144
+ # `--jobs"`: https://stackoverflow.com/questions/26957237/how-to-make-git-clone-faster-with-multiple-threads/52327638#52327638
145
+ #
146
+ git submodule update --init --recursive -- ${submodules}
147
+ git submodule update --depth 1 --init --recursive -- " ${submodules_dir} /linux"
0 commit comments