Skip to content

Commit a54dc83

Browse files
authored
Add git clone support
1 parent 432f1c6 commit a54dc83

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

init.sh

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Options:
1212
-v, --version VERSION The version of kernel
1313
-b, --branch BRANCH NAME The branch of dst kernel
1414
-t, --type KERNEL TYPE The kernel type: LTS from kernel.org, AOSP kernel
15+
-d, --download KERNEL DOWNLOAD The kernel download type: GIT, TAR
1516
-h, --help Show command help.
1617
"
1718

@@ -28,6 +29,7 @@ default_param() {
2829
VERSION=linux-5.15.154
2930
BRANCH=linux-5.15
3031
TYPE=LTS
32+
DOWNLOAD=TAR
3133
}
3234

3335
# Function to parse command line arguments
@@ -59,6 +61,10 @@ parseargs()
5961
TYPE=`echo $2`
6062
shift
6163
shift
64+
elif [ "x$1" == "x-d" -o "x$1" == "x--download" ]; then
65+
DOWNLOAD=`echo $2`
66+
shift
67+
shift
6268
else
6369
echo `date` - ERROR, UNKNOWN params "$@"
6470
return 2
@@ -95,13 +101,18 @@ if [ "${URL: -1}" = "/" ]; then
95101
URL="${URL:0:len-1}"
96102
fi
97103

98-
wget ${URL}/${VERSION}.${TARBALL} -qO kernel/${VERSION}/${VERSION}.${TARBALL}
99-
100-
# Unarchive Kernel
101-
echo Unarchive Kernel
102-
cd kernel/${VERSION}
103-
tar xf ${VERSION}.${TARBALL}
104-
cd ${VERSION}
104+
# Download and Unarchive Kernel
105+
if [ "x$DOWNLOAD" = "xTAR" ]; then
106+
wget ${URL}/${VERSION}.${TARBALL} -qO kernel/${VERSION}/${VERSION}.${TARBALL}
107+
echo Unarchive Kernel
108+
cd kernel/${VERSION}
109+
tar xf ${VERSION}.${TARBALL}
110+
cd ${VERSION}
111+
else
112+
git clone ${URL} -b ${VERSION} --depth=1 ${VERSION}
113+
cd ${VERSION}
114+
rm -rf .git
115+
fi
105116

106117
# Copy BSP files
107118
echo Copying BSP files
@@ -128,11 +139,15 @@ echo Merging old kernel
128139
mv .git ../
129140
rm -rf *
130141

131-
if [ "x$TYPE" = "xLTS" ]; then
132-
cp -raf ${ROOT_PATH}/kernel/${VERSION}/${VERSION}/. .
142+
if [ "x$DOWNLOAD" = "xTAR" ]; then
143+
if [ "x$TYPE" = "xLTS" ]; then
144+
cp -raf ${ROOT_PATH}/kernel/${VERSION}/${VERSION}/. .
145+
else
146+
cp -raf ${ROOT_PATH}/kernel/${VERSION}/. .
147+
rm -rf *.tar.gz
148+
fi
133149
else
134-
cp -raf ${ROOT_PATH}/kernel/${VERSION}/. .
135-
rm -rf *.tar.gz
150+
cp -raf ${ROOT_PATH}/${VERSION}/. .
136151
fi
137152

138153
mv ../.git .

0 commit comments

Comments
 (0)