aboutsummaryrefslogtreecommitdiffstats
path: root/main/lua-aports/0001-buildrepo-make-sure-we-flush-stdout-on-info-output.patch
blob: 1c75549e8de39ecc0eb0597adbc18adec2af87f1 (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
From 2a5a80d9c3ace1fce642c1bbee6efe98d6bf7215 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Mon, 14 Apr 2014 09:14:46 +0000
Subject: [PATCH] buildrepo: make sure we flush stdout on info output

We introduce a printf-like function 'info'
---
 buildrepo.lua | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/buildrepo.lua b/buildrepo.lua
index 7093141..005b548 100755
--- a/buildrepo.lua
+++ b/buildrepo.lua
@@ -6,10 +6,12 @@ local lfs = require("lfs")
 
 local function warn(formatstr, ...)
 	io.stderr:write(("WARNING: %s\n"):format(formatstr:format(...)))
+	io.stderr:flush()
 end
 
 local function err(formatstr, ...)
 	io.stderr:write(("ERROR: %s\n"):format(formatstr:format(...)))
+	io.stderr:flush()
 end
 
 local function fatal(exitcode, formatstr, ...)
@@ -17,6 +19,11 @@ local function fatal(exitcode, formatstr, ...)
 	os.exit(exitcode)
 end
 
+local function info(formatstr, ...)
+	io.stdout:write(("%s\n"):format(formatstr:format(...)))
+	io.stdout:flush()
+end
+
 local function parse_opts(opthelp, raw_args)
 	local valid_opts = {}
 	local opts = {}
@@ -179,10 +186,12 @@ for _,repo in pairs(args) do
 		if not db:known_deps_exists(aport) then
 			warn("%s: Skipped due to missing dependencies", aport.pkgname)
 		elseif not (opts.s and skip_aport(aport)) then
-			io.write(("%d/%d %d/%d %s/%s %s\n"):format(tried, #pkgs,
+			info("%d/%d %d/%d %s/%s %s-r%s",
+					tried, #pkgs,
 					totally_built,
 					stats[repo].relevant_aports,
-					repo, aport.pkgname, aport.pkgver))
+					repo, aport.pkgname,
+					aport.pkgver, aport.pkgrel)
 			if build_aport(aport, repodest, logdir) then
 				built = built + 1
 			else
@@ -203,7 +212,7 @@ for _,repo in pairs(args) do
 		local apkrepodir = ("%s/%s/%s"):format(repodest, repo, abuild.arch)
 		for file in lfs.dir(apkrepodir) do
 			if file:match("%.apk$") and not keep[file] then
-				print("Deleting ", file)
+				info("Deleting %s", file)
 				if not opts.n then
 					os.remove(("%s/%s"):format(apkrepodir, file))
 					deleted = deleted + 1
@@ -214,7 +223,7 @@ for _,repo in pairs(args) do
 
 	-- generate new apkindex
 	if not opts.n then
-		print("Updating apk index")
+		info("Updating apk index")
 		apkrepo.update_index(("%s/%s"):format(repodest, repo),
 				abuild.arch, db:git_describe())
 	end
@@ -225,11 +234,10 @@ for _,repo in pairs(args) do
 end
 
 for repo,stat in pairs(stats) do
-	print(repo.." built:", stat.built)
-	print(repo.." tried:", stat.tried)
-	print(repo.." deleted:", stat.deleted)
-	print(repo.." time:", stat.time)
-	print(repo.." total built:", stat.relevant_aports - stat.tried + stat.built)
-	print(repo.." total relevant aports:", stat.relevant_aports)
-	print(repo.." total aports:", stat.total_aports)
+	info("%s built:\t%d", repo, stat.built)
+	info("%s tried:\t%d", repo, stat.tried)
+	info("%s deleted:\t%d", repo, stat.deleted)
+	info("%s total built:\t%d", repo, stat.relevant_aports - stat.tried + stat.built)
+	info("%s total relevant aports:\t%d", repo, stat.relevant_aports)
+	info("%s total aports:\t%d", repo, stat.total_aports)
 end
-- 
1.9.2