This repository has been archived by the owner on May 1, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmkrepo.sh
executable file
·128 lines (102 loc) · 3.21 KB
/
mkrepo.sh
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
# Colored makepkg-like functions
all_off="$(tput sgr0)"
bold="${all_off}$(tput bold)"
blue="${bold}$(tput setaf 4)"
yellow="${bold}$(tput setaf 3)"
msg_blue() {
printf "${blue}==>${bold} $1${all_off}\n"
}
note(){
printf "${blue}==>${yellow} NOTE:${bold} $1${all_off}\n"
}
# Colored makepkg-like functions
REPONAME="gpd-pocket"
REPODIR="/opt/njkli/${REPONAME}/$(uname -m)"
[[ ! -d $REPODIR ]] && sudo mkdir -p $REPODIR
mkdir -p /tmp/{build,yaourt}
sudo chown --recursive $UID $REPODIR
sudo chown --recursive $UID /tmp/{build,yaourt}
_dkr() {
TEMP_MOUNT="${PWD}/njkli-repo:/usr/local/bin/njkli-repo"
arg=$1
vol_pkgdir="${arg}:/home/dev/pkg"
vol_build="/tmp/build:/tmp/makepkg"
vol_yaourt="/tmp/yaourt:/home/dev/tmp/yaourt"
vol_pkginst="${REPODIR}:/home/dev/install"
vol_gpg="$HOME/.gnupg:/home/dev/.gnupg:rw"
dkr_volumes="-v ${vol_build} -v ${vol_yaourt} -v ${vol_pkgdir} -v ${vol_pkginst}"
dkr_img="njkli/makepkg"
dkr_opts="--rm -ti --name makepkg"
# refresh the image
export refreshed=$(docker pull $dkr_img)
DKR="docker run ${dkr_opts} ${dkr_volumes} ${dkr_img}"
echo $DKR
}
_mkpkg() {
[[ ! $(find ./ -name *.pkg.tar.xz) ]] && eval "$(_dkr $PWD)"
[[ $(find ./ -name \*.pkg.tar.xz\*) ]] && \
msg_blue "mv *.pkg.tar.xz* $REPODIR" && \
mv *.pkg.tar.xz $REPODIR
}
_mkpkgs() {
local dir=$PWD
for pkg in $(ls $PWD/*/PKGBUILD)
do
cd $(dirname $pkg)
_mkpkg
done
cd $dir
}
_mkclean() {
msg_blue "find $REPODIR -name *.sig -delete"
find $REPODIR -name *.sig -delete &> /dev/null
msg_blue "find $REPODIR -name *.tar.gz -delete"
find $REPODIR -name *.tar.gz -delete &> /dev/null
msg_blue "find $REPODIR -name *.old -delete"
find $REPODIR -name *.old -delete &> /dev/null
msg_blue "find $REPODIR -type l -delete"
find $REPODIR -type l -delete &> /dev/null
rm -rf $REPODIR/$REPONAME.{db,files}
}
_sign_pkgs() {
msg_blue "find $REPODIR/*.pkg.tar.xz -exec gpg --detach-sign '{}' ';'"
find $REPODIR/*.pkg.tar.xz -exec gpg --detach-sign '{}' ';'
}
_mkrepo() {
local ext="db files"
_mkclean
_sign_pkgs
msg_blue "repo-add --sign $REPODIR/$REPONAME.db.tar.gz $REPODIR/*.pkg.tar.xz"
repo-add --sign $REPODIR/$REPONAME.db.tar.gz $REPODIR/*.pkg.tar.xz
find $REPODIR -type l -delete
for i in ${ext[@]}
do
msg_blue "mv $REPODIR/$REPONAME.$i.tar.gz $REPODIR/$REPONAME.$i"
mv $REPODIR/$REPONAME.$i.tar.gz $REPODIR/$REPONAME.$i
msg_blue "mv $REPODIR/$REPONAME.$i.tar.gz.sig $REPODIR/$REPONAME.$i.sig"
mv $REPODIR/$REPONAME.$i.tar.gz.sig $REPODIR/$REPONAME.$i.sig
done
}
_mkrelease() {
local dir=$PWD
cd $REPODIR
local files=$(find ./ -type f | awk -F'/' '{print $2}')
for f in ${files[@]}
do
msg_blue "github-release upload -t $(uname -m) -n $f -f $f -R"
github-release upload -t $(uname -m) -n $f -f $f -R
done
cd $dir
}
mkdir -p /tmp/{build,yaourt}
sudo chmod 0777 /tmp/{build,yaourt}
if [ $# -eq 0 ]; then
_mkpkgs
_mkrepo
_mkrelease
else
[[ $1 == "release" ]] && _mkrepo && _mkrelease
[[ $1 == "refresh" ]] && _mkrepo
[[ $(find ./ -type d -name $1) ]] && cd $1 && _mkpkg
fi