Skip to content

Commit 6f38dca

Browse files
Provision the ability to apply the non upstream patches in any order (sonic-net#313)
* Provision the ability to apply the patches in any order Signed-off-by: Vivek Reddy <[email protected]> * Make INCLUDE_EXTERNAL_PATCHES a mandatory parameter Signed-off-by: Vivek Reddy <[email protected]> --------- Signed-off-by: Vivek Reddy <[email protected]> Co-authored-by: Saikrishna Arcot <[email protected]>
1 parent fbd307e commit 6f38dca

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

Makefile

+30-21
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,36 @@ ORIG_FILE_URL = "$(SOURCE_FILE_BASE_URL)/$(ORIG_FILE)"
6161
NON_UP_DIR = /tmp/non_upstream_patches
6262

6363
$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
64+
# Include any non upstream patches
65+
rm -rf $(NON_UP_DIR)
66+
mkdir -p $(NON_UP_DIR)
67+
68+
if [ x${INCLUDE_EXTERNAL_PATCHES} == xy ]; then
69+
if [ ! -z ${EXTERNAL_KERNEL_PATCH_URL} ]; then
70+
wget $(EXTERNAL_KERNEL_PATCH_URL) -O patches.tar
71+
tar -xf patches.tar -C $(NON_UP_DIR)
72+
else
73+
if [ -d "$(EXTERNAL_KERNEL_PATCH_LOC)" ]; then
74+
cp -r $(EXTERNAL_KERNEL_PATCH_LOC)/* $(NON_UP_DIR)/
75+
fi
76+
fi
77+
fi
78+
79+
if [ -f "$(NON_UP_DIR)/series.patch" ]; then
80+
echo "Patch the series file"
81+
cat $(NON_UP_DIR)/series.patch
82+
pushd patch
83+
# clear any unstaged changes
84+
git stash -- series
85+
git apply $(NON_UP_DIR)/series.patch
86+
popd
87+
88+
if [ -d "$(NON_UP_DIR)/patches" ]; then
89+
echo "Copy the non upstream patches"
90+
cp $(NON_UP_DIR)/patches/*.patch patch/
91+
fi
92+
fi
93+
6494
# Obtaining the Debian kernel source
6595
rm -rf $(BUILD_DIR)
6696
wget -O $(DSC_FILE) $(DSC_FILE_URL)
@@ -102,27 +132,6 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
102132
stg repair
103133
stg import -s ../patch/series
104134

105-
rm -rf $(NON_UP_DIR)
106-
mkdir -p $(NON_UP_DIR)
107-
108-
if [ ! -z ${EXTERNAL_KERNEL_PATCH_URL} ]; then
109-
wget $(EXTERNAL_KERNEL_PATCH_URL) -O patches.tar
110-
tar -xf patches.tar -C $(NON_UP_DIR)
111-
fi
112-
113-
# Precedence is given for external URL
114-
if [ -z ${EXTERNAL_KERNEL_PATCH_URL} ] && [ x${INCLUDE_EXTERNAL_PATCH_TAR} == xy ]; then
115-
if [ -f "$(EXTERNAL_KERNEL_PATCH_TAR)" ]; then
116-
tar -xf $(EXTERNAL_KERNEL_PATCH_TAR) -C $(NON_UP_DIR)
117-
fi
118-
fi
119-
120-
if [ -f "$(NON_UP_DIR)/series" ]; then
121-
echo "External Patches applied:"
122-
cat $(NON_UP_DIR)/series
123-
stg import -s $(NON_UP_DIR)/series
124-
fi
125-
126135
# Optionally add/remove kernel options
127136
if [ -f ../manage-config ]; then
128137
../manage-config $(CONFIGURED_ARCH) $(CONFIGURED_PLATFORM) $(SECURE_UPGRADE_MODE) $(SECURE_UPGRADE_DEV_SIGNING_CERT)

0 commit comments

Comments
 (0)