]> Cypherpunks.ru repositories - gocheese.git/blob - makedist.sh
Less hardcoded module name
[gocheese.git] / makedist.sh
1 #!/bin/sh -ex
2
3 cur=$(pwd)
4 tmp=$(mktemp -d)
5 release=$1
6 [ -n "$release" ]
7 MAKEINFO=${MAKEINFO:=makeinfo}
8
9 git clone . $tmp/gocheese-$release
10 cd $tmp/gocheese-$release
11 git checkout v$release
12
13 redo-ifchange module-name
14 mod_name=`cat module-name`
15 crypto_mod_path=$(sed -n 's#^require \(golang.org/x/crypto\) \(.*\)$#\1@\2#p' go.mod)
16 mkdir -p src/$mod_name
17 mv *.go go.mod go.sum src/$mod_name
18
19 mods="
20 golang.org/x/crypto
21 golang.org/x/net
22 "
23 for mod in $mods; do
24     mod_path=$(sed -n "s# // indirect## ; s#^   \($mod\) \(.*\)\$#\1@\2#p" src/$mod_name/go.mod)
25     [ -n "$mod_path" ]
26     mkdir -p src/$mod
27     ( cd $GOPATH/pkg/mod/$mod_path ; tar cf - --exclude ".git*" * ) | tar xfC - src/$mod
28     chmod -R +w src/$mod
29 done
30
31 for mod in golang.org/x/sys; do
32     mod_path=$(sed -n "s#^\($mod\) \(.*\) h1:.*\$#\1@\2#p" src/$mod_name/go.sum | sed /go.mod/d | sort -n -r | sed -n 1p)
33     [ -n "$mod_path" ]
34     mkdir -p src/$mod
35     ( cd $GOPATH/pkg/mod/$mod_path ; tar cf - --exclude ".git*" * ) | tar xfC - src/$mod
36     chmod -R +w src/$mod
37 done
38
39 cat > $tmp/includes <<EOF
40 golang.org/x/crypto/AUTHORS
41 golang.org/x/crypto/argon2
42 golang.org/x/crypto/blake2b
43 golang.org/x/crypto/CONTRIBUTORS
44 golang.org/x/crypto/go.mod
45 golang.org/x/crypto/go.sum
46 golang.org/x/crypto/LICENSE
47 golang.org/x/crypto/PATENTS
48 golang.org/x/crypto/README.md
49 golang.org/x/net/AUTHORS
50 golang.org/x/net/CONTRIBUTORS
51 golang.org/x/net/go.mod
52 golang.org/x/net/go.sum
53 golang.org/x/net/LICENSE
54 golang.org/x/net/netutil
55 golang.org/x/net/PATENTS
56 golang.org/x/net/README.md
57 golang.org/x/sys/AUTHORS
58 golang.org/x/sys/CONTRIBUTORS
59 golang.org/x/sys/cpu
60 golang.org/x/sys/go.mod
61 golang.org/x/sys/LICENSE
62 golang.org/x/sys/PATENTS
63 golang.org/x/sys/README.md
64 EOF
65 tar cfCI - src $tmp/includes | tar xfC - $tmp
66 rm -fr src/golang.org $tmp/includes
67 mv $tmp/golang.org src
68
69 cat > download.texi <<EOF
70 You can obtain releases source code prepared tarballs on
71 @url{http://www.gocheese.cypherpunks.ru/}.
72 EOF
73 redo gocheese.info
74
75 texi=$(mktemp)
76 cat > $texi <<EOF
77 \input texinfo
78 @documentencoding UTF-8
79 @settitle INSTALL
80 @include install.texi
81 @bye
82 EOF
83 perl -i -p -e "s/.verbatiminclude PUBKEY.asc/Look in PUBKEY.asc file./" install.texi
84 $MAKEINFO --plaintext -o INSTALL $texi
85 rm $texi
86
87 rm -rf .redo .git .gitignore style.css makedist.sh www.do module-name.do
88 echo 'GOPATH=`pwd` ${GO:=go} build -o $3 -ldflags "-X main.Version=`cat VERSION`" `cat module-name`' > gocheese.do
89 echo 'GOPATH=`pwd` ${GO:=go} test `cat module-name`/... >&2' > test.do
90
91 find . -type d -exec chmod 755 {} \;
92 find . -type f -exec chmod 644 {} \;
93 chmod +x pyshop2packages.sh
94
95 cd ..
96 tar cvf gocheese-"$release".tar --uid=0 --gid=0 --numeric-owner gocheese-"$release"
97 xz -9 gocheese-"$release".tar
98 gpg --detach-sign --sign --local-user CD5CD01F55343D88 gocheese-"$release".tar.xz
99
100 tarball=gocheese-"$release".tar.xz
101 size=$(( $(stat -f %z $tarball) / 1024 ))
102 hash=$(gpg --print-md SHA256 < $tarball)
103 release_date=$(date "+%Y-%m-%d")
104
105 cat <<EOF
106 An entry for documentation:
107 @item $release @tab $release_date @tab $size KiB
108 @tab @url{gocheese-${release}.tar.xz, link} @url{gocheese-${release}.tar.xz.sig, sign}
109 @tab @code{$hash}
110 EOF
111
112 mv $tmp/$tarball $tmp/"$tarball".sig $cur/gocheese.html/