File tree Expand file tree Collapse file tree 1 file changed +123
-0
lines changed
Expand file tree Collapse file tree 1 file changed +123
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ set -e
4+
5+ stamp () {
6+ local msg=' Void Updates check'
7+ local time=" $( date +%Y-%m-%d\ %H:%M\ %Z) "
8+
9+ if [ " $1 " ]; then
10+ local start=$1
11+ local end=$( date +%s)
12+
13+ msg=" $msg ended: $time ($(( $end - $start )) s)"
14+ else
15+ msg=" $msg started: $time "
16+ date +%s
17+ fi
18+ printf -- ' %s\n' " $msg " 1>&2
19+ }
20+
21+ init_src () {
22+ if ! [ -d $src /.git ]; then
23+ mkdir -p $src
24+ git clone -q $repo $src
25+ fi
26+
27+ if ! [ -d $src /hostdir/binpkgs ]; then
28+ (cd $src && ./xbps-src binary-bootstrap)
29+ fi
30+ }
31+
32+ update_src () {
33+ GIT_WORK_TREE=$src git pull -q
34+ }
35+
36+ find_pkgs () {
37+ local f p
38+
39+ for f in $src /srcpkgs/* ; do
40+ p=$( basename $f )
41+
42+ if [ ! -h $f ] && [ -f $f /template ]; then
43+ printf -- ' %s\n' $p
44+ fi
45+ done
46+ }
47+
48+ add_maintainer () {
49+ local p m
50+ while IFS= read -r p; do
51+ m=$( grep ^maintainer= $src /srcpkgs/$p /template |
52+ awk -F' <' ' { print $2 }' |
53+ tr -d " >\" '" | tr -d ' ' )
54+
55+ if [ " $m " ]; then
56+ printf ' %s %s\n' $p $dest /updates_$m .txt
57+ fi
58+ done
59+ }
60+
61+ parallel_check () {
62+ xargs -P20 -L1 /bin/sh -c \
63+ " (cd $src && ./xbps-src update-check \$ 0) >> \$ 1"
64+ }
65+
66+ create_summary () {
67+ local f m
68+
69+ for f in $dest /updates_* .txt; do
70+ if [ -s $f ]; then
71+ m=$( basename ${f%% .txt} | sed ' s/updates_//' )
72+
73+ printf ' %s\n%s\n' $m $( printf %${# m} s | tr ' ' -)
74+ sort $f
75+ printf -- ' \n'
76+ else
77+ rm -f $f
78+ fi
79+ done > $dest .txt
80+ }
81+
82+ make_current () {
83+ ln -sf $dest .txt $out /$name .txt
84+ ln -sf $dest $out /$name
85+ }
86+
87+ while getopts " p:r:s:o:" opt; do
88+ case $opt in
89+ p)
90+ procs=$OPTARG
91+ ;;
92+ r)
93+ repo=$OPTARG
94+ ;;
95+ s)
96+ src=$OPTARG
97+ ;;
98+ o)
99+ out=$OPTARG
100+ ;;
101+ esac
102+ done
103+
104+ [ " $procs " ] || procs=1
105+ [ " $repo " ]
106+ [ " $src " ]
107+ [ " $out " ]
108+
109+ name=$( basename $0 )
110+ date=$( date +%Y-%m-%d)
111+ dest=$out /${name} _$date
112+
113+ mkdir -p $dest
114+
115+ {
116+ start=$( stamp)
117+ init_src
118+ update_src
119+ find_pkgs | add_maintainer | parallel_check
120+ create_summary
121+ make_current
122+ stamp $start
123+ } 2> $dest /_log.txt
You can’t perform that action at this time.
0 commit comments