-
Notifications
You must be signed in to change notification settings - Fork 4
171 lines (150 loc) · 7.13 KB
/
list_termux_pkgs.yaml
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
160
161
162
163
164
165
166
167
168
169
170
171
name: 💾 Fetch || ⏫ Update Termux Package Registry 📦
#MAX_RUNTIME: ~ 03 mins
on:
workflow_dispatch:
schedule:
- cron: "0 */2 * * *" # Every 2 Hrs
jobs:
fetch:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: "main"
filter: "blob:none" #https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/
- name: Setup ENV
run: |
#presets
set +x ; set +e
#-------------#
##Install coreutils
sudo apt-get update -y -qq && sudo apt-get install curl coreutils dos2unix file findutils gawk git jq moreutils rsync tar xz-utils util-linux wget zip -y -qq
#tmp
SYSTMP="$(dirname $(mktemp -u))" && export SYSTMP="$SYSTMP"
echo "SYSTMP=$SYSTMP" >> "$GITHUB_ENV"
##Setup rClone
mkdir -p "$HOME/.config/rclone"
echo "${{ secrets.RCLONE_CF_R2_PUB }}" > "$HOME/.config/rclone/rclone.conf"
export RCLONE_STATS="120s" ; echo "RCLONE_STATS=$RCLONE_STATS" >> "$GITHUB_ENV"
##User-Agent
USER_AGENT="$(curl -qfsSL 'https://pub.ajam.dev/repos/Azathothas/Wordlists/Misc/User-Agents/ua_chrome_macos_latest.txt')" && export USER_AGENT="$USER_AGENT"
echo "USER_AGENT=$USER_AGENT" >> "$GITHUB_ENV"
continue-on-error: true
- name: Install Addons
run: |
#presets
set +x ; set +e
#-------------#
bash <(curl -qfsSL "https://pub.ajam.dev/repos/Azathothas/Arsenal/misc/Linux/install_bb_tools.sh")
#yj
sudo curl -qfsSL "https://bin.ajam.dev/$(uname -m)/yj" -o "/usr/local/bin/yj" && sudo chmod +x "/usr/local/bin/yj"
continue-on-error: true
- name: Fetch || Update Termux Package Registry (Docker --> termux/termux-docker)
run: |
#Presets
set +x ; set +e
#--------------#
docker run --privileged --name termux \
termux/termux-docker:latest \
bash -c 'apt-get clean && apt-get update; for pkg in $(apt-cache pkgnames | sort -u); do version=$(apt-cache show $pkg | grep -m 1 "Version:" | cut -c 10-); description=$(apt-cache show $pkg | grep -m 1 "Description:" | cut -c 14-); homepage=$(apt-cache show $pkg | grep -m 1 "Homepage:" | cut -c 11-); echo "| **$pkg** | $version | $description | $homepage |"; done > termux.pkgs'
#Copy
docker cp "termux:/data/data/com.termux/files/home/termux.pkgs" "$GITHUB_WORKSPACE/main/termux.pkgs"
sed 's/[\*\|]//g' "$GITHUB_WORKSPACE/main/termux.pkgs" > "$GITHUB_WORKSPACE/main/pkgs.txt"
continue-on-error: false
- name: Update README.md
run: |
#Presets
set +x ; set +e
#--------------#
cd "$GITHUB_WORKSPACE/main"
cat "$GITHUB_WORKSPACE/main/INFO.md" > "$GITHUB_WORKSPACE/main/README.md"
echo -e "" >> "$GITHUB_WORKSPACE/main/README.md"
echo '---' >> "$GITHUB_WORKSPACE/main/README.md"
echo "|Package | Version | Description | Homepage |" >> "$GITHUB_WORKSPACE/main/README.md"
echo "|--------|---------|-------------|----------|" >> "$GITHUB_WORKSPACE/main/README.md"
cat "$GITHUB_WORKSPACE/main/termux.pkgs" >> "$GITHUB_WORKSPACE/main/README.md"
echo -e "" >> "$GITHUB_WORKSPACE/main/README.md"
echo '---' >> "$GITHUB_WORKSPACE/main/README.md"
continue-on-error: false
- name: Generate index.html --> ("https://termux-packages.ajam.dev")
run: |
#Presets
set +x ; set +e
#--------------#
#https://github.com/oscarmorrison/md-page
cat "$GITHUB_WORKSPACE/main/.github/style.header" > "$GITHUB_WORKSPACE/main/index.html"
echo "" >> "$GITHUB_WORKSPACE/main/index.html"
#cat "$GITHUB_WORKSPACE/main/README.md" >> "$GITHUB_WORKSPACE/main/index.html"
sed -n "$(($(grep -n '|Package' "$GITHUB_WORKSPACE/main/README.md" | cut -d ':' -f 1) - 1)),\$p" "$GITHUB_WORKSPACE/main/README.md" >> "$GITHUB_WORKSPACE/main/index.html"
echo "" >> "$GITHUB_WORKSPACE/main/index.html"
cat "$GITHUB_WORKSPACE/main/.github/style.footer" >> "$GITHUB_WORKSPACE/main/index.html"
continue-on-error: true
- name: Generate JSON
run: |
#Presets
set +x ; set +e
#--------------#
awk '
BEGIN {
FS="|";
}
/^-+$/ { next }
NR > 3 && NF > 1 {
#Trim leading and trailing spaces
for (i=1; i<=NF; i++) gsub(/^ *| *$/, "", $i)
#Ignore lines with only separators or empty fields
if ($2 == "" && $3 == "" && $4 == "" && $5 == "") next
#Remove '**' from the Package field
gsub(/\*\*/, "", $2)
#Remove backticks from values
gsub("\140", "", $2)
gsub("\140", "", $3)
gsub("\140", "", $4)
gsub("\140", "", $5)
#Remove single quotes from values
gsub("\047", "", $2)
gsub("\047", "", $3)
gsub("\047", "", $4)
gsub("\047", "", $5)
#Remove double quotes from values
gsub("\042", "", $2)
gsub("\042", "", $3)
gsub("\042", "", $4)
gsub("\042", "", $5)
#Construct JSON object
printf "{\n"
printf " \"Package\": \"%s\",\n", $2
printf " \"Version\": \"%s\",\n", $3
printf " \"Description\": \"%s\",\n", $4
printf " \"Homepage\": \"%s\"\n", $5
printf "}\n"
}' "$GITHUB_WORKSPACE/main/README.md" > "$SYSTMP/temp.json"
#Validate
jq -c 'select(has("Package") and (.Package | test("[[:alnum:]]")) and .Package != "")' "$SYSTMP/temp.json" | jq -s '.' > "$SYSTMP/tempd.json"
jq '[.[] | select(.Package != "Package" and .Version != "Version")] | sort_by(.Package)' "$SYSTMP/tempd.json" > "$GITHUB_WORKSPACE/main/pkgs.json"
#Convert to YAML
cat "$GITHUB_WORKSPACE/main/pkgs.json" | yj -jy | tee "$GITHUB_WORKSPACE/main/pkgs.yaml"
continue-on-error: false
- name: Get DateTime
run: |
#Presets
set +x ; set +e
#--------------#
NEPALI_TIME=$(TZ='Asia/Kathmandu' date +'%Y-%m-%d (%I:%M:%S %p)')
echo "NEPALI_TIME=$NEPALI_TIME" >> $GITHUB_ENV
continue-on-error: true
- name: Git Pull
run: |
cd "$GITHUB_WORKSPACE/main" && git pull origin main
continue-on-error: true
#Commit & Push
- uses: stefanzweifel/git-auto-commit-action@v5
with:
repository: ./main
commit_user_name: Azathothas # defaults to "github-actions[bot]"
commit_user_email: [email protected] # defaults to "41898282+github-actions[bot]@users.noreply.github.com"
commit_message: "✅ Update Termux pkg Registry 📦 <-- ${{ env.NEPALI_TIME }} ⌚"
#push_options: '--force'