aboutsummaryrefslogtreecommitdiffstats
path: root/main/abuild/mr128-newapkbuild-fetch-rust-deps-in-prepare.patch
blob: 298f717e3ba4fdb7778f70464469515ddafe7fcb (plain)
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
Patch-Source: https://gitlab.alpinelinux.org/alpine/abuild/-/merge_requests/128
--
From 29611f3a6929b4edecd89506e666f963fa25ae52 Mon Sep 17 00:00:00 2001
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Thu, 16 Dec 2021 00:19:07 +0100
Subject: [PATCH 1/2] newapkbuild: fetch rust dependencies in prepare phase

Fetch all dependencies in the prepare phase and do not access network
in the following phases.
---
 newapkbuild.in | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/newapkbuild.in b/newapkbuild.in
index c58d519..0182ad2 100644
--- a/newapkbuild.in
+++ b/newapkbuild.in
@@ -30,6 +30,12 @@ is_github_url() {
 	return 1
 }
 
+prepare_rust() {
+	cat >>APKBUILD<<__EOF__
+	cargo fetch --locked
+__EOF__
+}
+
 # Build sections
 build_make() {
 	cat >>APKBUILD<<__EOF__
@@ -104,7 +110,7 @@ __EOF__
 
 build_rust() {
 	cat >>APKBUILD<<__EOF__
-	cargo build --release --locked
+	cargo build --frozen --release
 __EOF__
 }
 
@@ -150,7 +156,7 @@ __EOF__
 
 check_rust() {
 	cat >>APKBUILD<<__EOF__
-	cargo test --release --locked
+	cargo test --frozen --release
 __EOF__
 }
 
@@ -199,7 +205,7 @@ __EOF__
 
 package_rust() {
 	cat >>APKBUILD<<__EOF__
-	cargo install --locked --path . --root="\$pkgdir/usr"
+	cargo install --frozen --offline --path . --root="\$pkgdir/usr"
 	rm "\$pkgdir"/usr/.crates*
 __EOF__
 }
@@ -333,6 +339,21 @@ __EOF__
 		fi
 	fi
 
+	case "$buildtype" in
+	rust)
+		cat >>APKBUILD<<__EOF__
+prepare() {
+	default_prepare
+
+__EOF__
+		prepare_rust
+		cat >>APKBUILD<<__EOF__
+}
+
+__EOF__
+		;;
+	esac
+
 	# Create build() function
 	cat >>APKBUILD<<__EOF__
 build() {
-- 
GitLab


From 0a9374e4ffa8202ba011497ea39fb5443d7ef9a5 Mon Sep 17 00:00:00 2001
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Thu, 16 Dec 2021 00:23:48 +0100
Subject: [PATCH 2/2] newapkbuild: do not run cargo test with --release

It takes a longer time to compile and, most importantly, it may cause
unnecessary rebuild of everything in the package phase (installation).
---
 newapkbuild.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/newapkbuild.in b/newapkbuild.in
index 0182ad2..9e8643d 100644
--- a/newapkbuild.in
+++ b/newapkbuild.in
@@ -156,7 +156,7 @@ __EOF__
 
 check_rust() {
 	cat >>APKBUILD<<__EOF__
-	cargo test --frozen --release
+	cargo test --frozen
 __EOF__
 }
 
-- 
GitLab