Skip to content

Commit 4684f96

Browse files
authored
1st test
1 parent 1fa643e commit 4684f96

2 files changed

Lines changed: 63 additions & 46 deletions

File tree

.github/workflows/Build-Kernel.yml

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,38 @@ jobs:
2727
run:
2828
shell: bash
2929
steps:
30+
- name: "✔️ Pre-build checks"
31+
run: |
32+
body="~/body.txt"
33+
WSL_DATE="$(wget -q https://api.github.com/repos/microsoft/WSL2-Linux-Kernel/commits -O -\
34+
| grep '"date"' \
35+
| head -1 \
36+
| awk -F '"' '{print $(NF-1)}')"
37+
LAST_DATE=$( wget -q https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest -O - \
38+
| awk -F \" -v RS="," '/published_at/ {print $(NF-1)}' ) \
39+
|| LAST_DATE="2000.01.01T00:00:00Z"
40+
if [[ $WSL_DATE > $LAST_DATE ]]; then
41+
echo "NEW KERNEL SOURCE!!!!"
42+
echo "# KERNEL UPDATES" > $body
43+
echo >> $body
44+
cat $body
45+
fi
46+
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
47+
echo "NEW IMPROVEMENT!!!!"
48+
[ -f $body ] && echo >> $body
49+
echo "# IMPROVEMENTS" >> $body
50+
echo >> $body
51+
fi
52+
if [ -f $body ]; then
53+
echo "CANCEL=false" >> $GITHUB_ENV
54+
else
55+
echo "NOTHING NEW. CANCELLING ACTION..."
56+
echo "CANCEL=true" >> $GITHUB_ENV
57+
fi
58+
59+
3060
- name: "⏬ Checkout repository"
61+
if: env.CANCEL != 'true'
3162
uses: actions/checkout@v3
3263

3364

@@ -62,35 +93,6 @@ jobs:
6293
## or https://github.com/mxschmitt/action-tmate
6394

6495

65-
- name: "✔️ Pre-build checks"
66-
run: |
67-
WSL_DATE="$(wget -q https://api.github.com/repos/microsoft/WSL2-Linux-Kernel/commits -O -\
68-
| grep '"date"' \
69-
| head -1 \
70-
| awk -F '"' '{print $(NF-1)}')"
71-
LAST_DATE=$( wget -q https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest -O - \
72-
| awk -F \" -v RS="," '/published_at/ {print $(NF-1)}' ) \
73-
|| LAST_DATE="2000.01.01T00:00:00Z"
74-
if [[ $WSL_DATE > $LAST_DATE ]]; then
75-
echo "NEW KERNEL SOURCE!!!!"
76-
echo "# KERNEL UPDATES" > body.txt
77-
echo >> body.txt
78-
cat body.txt
79-
fi
80-
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
81-
echo "NEW IMPROVEMENT!!!!"
82-
[ -f body.txt ] && echo >> body.txt
83-
echo "# IMPROVEMENTS" >> body.txt
84-
echo >> body.txt
85-
fi
86-
if [ -f body.txt ]; then
87-
echo "CANCEL=false" >> $GITHUB_ENV
88-
else
89-
echo "NOTHING NEW. CANCELLING ACTION..."
90-
echo "CANCEL=true" >> $GITHUB_ENV
91-
fi
92-
93-
9496
- name: "⏬ Install Toolchain OS Tools"
9597
if: env.CANCEL != 'true'
9698
run: sudo apt -y install build-essential flex bison dwarves libssl-dev libelf-dev
@@ -140,7 +142,7 @@ jobs:
140142
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141143
with:
142144
tag_name: ${{ env.VERSION }}
143-
body_path: body.txt
145+
body_path: $body
144146
files: |
145147
*.7z
146148

install.ps1

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
1-
cd $PSScriptRoot
2-
$kernel=(gci WSLk*).PSPath
3-
$line="kernel=$($kernel -replace '/|\\','\\')"
4-
$wslcfg="~/.wslconfig"
5-
cp $wslcfg $PSScriptRoot
6-
if ( (Test-Path $wslcfg) -AND (gc $wslcfg | sls "^ *kernel *=") ) {
7-
# We already have a kernel setting
8-
(gc $wslcfg) -Replace "^ *kernel *=.*","$line" | Set-Content $wslcfg
9-
} else {
10-
if ( !( (Test-Path $wslcfg) -AND (gc $wslcfg | sls "^ *[WSL2]") ) ){
11-
# We don't have a [WSL2] section
12-
"`n[WSL2]" >> $wslcfg
13-
}
14-
"'n$line" >> $wslcfg
15-
}
16-
echo " Configuration file $wslcfg has been modified. A backup of the old file
1+
2+
function install_krnl {
3+
cd $PSScriptRoot
4+
$kernel = (gci WSLk*).FullName
5+
$newline = "kernel=$($kernel -replace '/|\\','\\')"
6+
$wslcfg = "~/.wslconfig"
7+
$WSL2line = $Krnlline = [int]0
8+
9+
if (Test-Path $wslcfg) {
10+
$WSL2line = [int]((gc $wslcfg) | sls "^ *\[wsl2]").Linenumber
11+
$Krnlline = [int]((gc $wslcfg) | sls "^ *kernel *=").Linenumber
12+
cp $wslcfg $PSScriptRoot
13+
echo " Configuration file $wslcfg has been modified. A backup of the old file
1714
can be found in folder $PSScriptRoot"
15+
}
16+
if ($WSL2line -eq 0) {
17+
# There isn't a WSL2 section
18+
"" >> $wslcfg
19+
"[wsl2]" >> $wslcfg
20+
"$newline" >> $wslcfg
21+
}
22+
elseif ($WSL2line -gt $Krnlline) {
23+
# no kernel line in WSL2 section
24+
"" >> $wslcfg
25+
"$newline" >> $wslcfg
26+
}
27+
else {
28+
# Replace current custom kernel
29+
(gc $wslcfg) -Replace "^ *kernel *=.*", "$newline" | Set-Content $wslcfg
30+
}
31+
}
32+
install_krnl

0 commit comments

Comments
 (0)