Skip to content

Commit 5b1fa48

Browse files
committed
up
1 parent 45b1af8 commit 5b1fa48

File tree

5 files changed

+87
-75
lines changed

5 files changed

+87
-75
lines changed

.github/workflows/build.yml

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,48 @@ jobs:
3232
run: |
3333
echo remote_version=${{ needs.check_update.outputs.remote_version }} | tee -a $GITHUB_ENV
3434
echo build_time=$(TZ=Asia/Shanghai date '+%Y%m%d%H%M') | tee -a $GITHUB_ENV
35-
- uses: actions/checkout@v4
36-
- uses: uraimo/run-on-arch-action@v2
37-
name: Install packages
38-
id: runcmd
39-
with:
40-
arch: aarch64
41-
distro: ubuntu_latest
42-
run: |
43-
bash build/chroot-alpine.sh
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
37+
38+
- name: Install Dependencies
39+
run: |
40+
sudo apt-get update
41+
sudo apt-get --no-install-recommends -y install \
42+
binutils build-essential libcap-dev libseccomp-dev make qemu-user-static xz-utils
43+
- name: download latest minirootfs
44+
env:
45+
URL: https://dl-cdn.alpinelinux.org/alpine/edge/releases
46+
ARCHITECTURE: aarch64
47+
run: |
48+
mkdir -p alpine
49+
50+
wget -q https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O yq
51+
sudo mv yq /usr/local/bin/yq
52+
sudo chmod +x /usr/local/bin/yq
53+
54+
FILE=$(curl -s "$URL/$ARCHITECTURE/latest-releases.yaml" | yq '.[] | select(.flavor == "alpine-minirootfs") | .file')
55+
wget "$URL/$ARCHITECTURE/$FILE"
56+
tar -xzf "$FILE" -C alpine
57+
- name: Build AARCH64
58+
run: |
59+
cat << 'EOF' | sudo tee alpine/build.sh
60+
#!/bin/sh
61+
rm /etc/resolv.conf
62+
echo "nameserver 1.1.1.1" > /etc/resolv.conf
63+
echo https://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories
64+
apk update
65+
apk add bash curl wget sudo coreutils clang make git
66+
apk add wget make clang git xz-dev libintl libbsd-static libsemanage-dev libselinux-utils libselinux-static xz-libs zlib zlib-static libselinux-dev linux-headers libssl3 libbsd libbsd-dev gettext-libs gettext-static gettext-dev gettext python3 build-base openssl-misc openssl-libs-static openssl zlib-dev xz-dev openssl-dev automake libtool bison flex gettext autoconf gettext sqlite sqlite-dev pcre-dev wget texinfo docbook-xsl libxslt docbook2x musl-dev gettext gettext-asprintf gettext-dbg gettext-dev gettext-doc gettext-envsubst gettext-lang gettext-libs gettext-static
67+
apk add upx
68+
git clone https://github.com/rurioss/rurima-aio
69+
cd rurima-aio
70+
make
71+
mv out rurima-aio
72+
tar -cvf /$(uname -m).tar rurima-aio
73+
EOF
74+
sudo chmod +x alpine/build.sh
75+
sudo ../ruri -a aarch64 -q /usr/bin/qemu-aarch64-static ./alpine /bin/sh /build.sh
76+
sudo mv alpine/aarch64.tar ./aarch64.tar
4477
- name: Release
4578
uses: softprops/action-gh-release@v2
4679
with:

build/chroot-alpine.sh

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/curl-wrapper.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ int main(int argc, char **argv)
99
char *path = (char *)malloc(4096);
1010
path[0] = '\0';
1111
realpath("/proc/self/exe", path);
12+
if (!path) {
13+
perror("realpath");
14+
fprintf(stderr, "Error: cannot resolve /proc/self/exe\n");
15+
fprintf(stderr, "Make sure your /proc is mounted properly.\n");
16+
return 1;
17+
}
1218
for (size_t i = strlen(path) - 1; i >= 0; i--) {
1319
if (path[i] == '/') {
1420
path[i] = '\0';
@@ -21,8 +27,8 @@ int main(int argc, char **argv)
2127
command[1] = "--dns-servers";
2228
command[2] = "1.1.1.1,8.8.8.8";
2329
command[3] = "--capath";
24-
char cert_path[4096];
25-
sprintf(cert_path, "%s/certs", path);
30+
char cert_path[4096];
31+
sprintf(cert_path, "%s/certs", path);
2632
command[4] = cert_path;
2733
char ca_path[4096];
2834
sprintf(ca_path, "%s/certs/ca-certificates.crt", path);
@@ -34,6 +40,6 @@ int main(int argc, char **argv)
3440
command[argc + 6] = NULL;
3541
free(path);
3642
execv(command[0], command);
37-
perror("execv");
38-
return 1;
43+
perror("execv");
44+
return 1;
3945
}

src/file-wrapper.c

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,37 @@
33
#include <stdlib.h>
44
#include <string.h>
55
#include <stdio.h>
6-
int main(int argc,char **argv){
7-
char *command[argc+11];
8-
char *path = (char *)malloc(4096);
9-
path[0]='\0';
10-
realpath("/proc/self/exe",path);
11-
for(size_t i=strlen(path)-1;i>=0;i--){
12-
if(path[i]=='/'){
13-
path[i]='\0';
14-
break;
15-
}
16-
}
17-
char file[4096]={'\0'};
18-
sprintf(file,"%s/file-static",path);
19-
command[0]=file;
20-
command[1]="--magic-file";
21-
char magic[4096]={'\0'};
22-
sprintf(magic,"%s/magic.mgc",path);
23-
command[2]=magic;
24-
for(int i=1;i<argc;i++){
25-
command[i+2]=argv[i];
26-
}
27-
command[argc+2] = NULL;
28-
free(path);
29-
execv(command[0],command);
30-
perror("execv");
31-
return 1;
6+
int main(int argc, char **argv)
7+
{
8+
char *command[argc + 11];
9+
char *path = (char *)malloc(4096);
10+
path[0] = '\0';
11+
realpath("/proc/self/exe", path);
12+
if (!path) {
13+
perror("realpath");
14+
fprintf(stderr, "Error: cannot resolve /proc/self/exe\n");
15+
fprintf(stderr, "Make sure your /proc is mounted properly.\n");
16+
return 1;
17+
}
18+
for (size_t i = strlen(path) - 1; i >= 0; i--) {
19+
if (path[i] == '/') {
20+
path[i] = '\0';
21+
break;
22+
}
23+
}
24+
char file[4096] = { '\0' };
25+
sprintf(file, "%s/file-static", path);
26+
command[0] = file;
27+
command[1] = "--magic-file";
28+
char magic[4096] = { '\0' };
29+
sprintf(magic, "%s/magic.mgc", path);
30+
command[2] = magic;
31+
for (int i = 1; i < argc; i++) {
32+
command[i + 2] = argv[i];
33+
}
34+
command[argc + 2] = NULL;
35+
free(path);
36+
execv(command[0], command);
37+
perror("execv");
38+
return 1;
3239
}

src/rurima-wrapper.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ void init(void)
3838
char *self_path = realpath("/proc/self/exe", NULL);
3939
if (!self_path) {
4040
perror("realpath");
41+
fprintf(stderr, "Error: cannot resolve /proc/self/exe\n");
42+
fprintf(stderr, "Make sure your /proc is mounted properly.\n");
4143
exit(1);
4244
}
4345
for (int i = strlen(self_path) - 1; i >= 0; --i) {

0 commit comments

Comments
 (0)