blob: 08d7b890a2863341ab9da2d6ef804e8b27f0cc68 (
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
#!/bin/bash
# Used to compile a package and copy it to the correct repository location.
# all arguments are passed to makepkg
#
#
. /etc/makepkg.conf
. PKGBUILD
PKGHOME=/data/pkg_repo/packages
SRCPKGHOME=/data/pkg_repo/src_packages
mydir=`pwd`
repolist="core extra"
cmdline=$@
git_branch=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
case $git_branch in
"testing") PFIX="-testing" ;;
"master" ) PFIX="" ;;
* ) echo "can't determine which is in use";;
esac
#if [ x`basename $0` = xmpr ]
#then
# PFIX=""
#else
# PFIX="-testing"
#fi
ALL_OFF="$(tput sgr0)"
BOLD="$(tput bold)"
BLUE="${BOLD}$(tput setaf 4)"
GREEN="${BOLD}$(tput setaf 2)"
RED="${BOLD}$(tput setaf 1)"
YELLOW="${BOLD}$(tput setaf 3)"
plain() {
local mesg=$1; shift
printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
}
msg() {
local mesg=$1; shift
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
}
msg() {
local mesg=$1; shift
printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
}
warning() {
local mesg=$1; shift
printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
}
error() {
local mesg=$1; shift
printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
}
function bump {
msg x$cmdline | grep -q \\-b
if [ $? = 0 ]
then
cmdline=`msg $cmdline|sed -e "s/-b//g"`
i="PKGBUILD"
#getting pkgrel number after =
package_pkgrel=`cat $i | grep pkgrel= | cut -d'=' -f 2`
#extract number before dot in pkgrel
beforedot=`msg $package_pkgrel | cut -n -d'.' -f 1`
#add 1 to pkgrel
new_pkgrel=$[$beforedot+1]
#write it back to PKGBUILD
sed -i "s:pkgrel=${package_pkgrel}:pkgrel=${new_pkgrel}:g" $i
msg "bumped $pkgname release from $package_pkgrel to $new_pkgrel"
. PKGBUILD
fi
#defined below
# TOTALPKG="$pkgname"-"$pkgver"-"$pkgrel"-"$CARCH".pkg.tar.gz
SRCPKG="$pkgname"-"$pkgver"-"$pkgrel".src.tar.gz
}
function find_repo {
dirname=`dirname $mydir`
echo $dirname|grep -q "extra"
if [ $? = 0 ]
then
REPO=extra${PFIX}
else
REPO=core${PFIX}
fi
echo $dirname|grep -q "chroot-devel"
if [ $? = 0 ]
then
REPO=chroot-devel
fi
echo $dirname|grep -q "mv-core"
if [ $? = 0 ]
then
REPO=mv-core
fi
if [ x`basename $0` = xmpl ]
then
REPO="local"
fi
DOCROOT=/data/pkg_repo/$CARCH/$REPO
if [ ! -e $DOCROOT ]
then
mkdir -p $DOCROOT
fi
msg $REPO
}
function update-repo {
cd $DOCROOT
msg
msg "DOCROOT=$DOCROOT"
msg
for i in ${pkgname[@]}
do
msg $i
TOTALPKG="$i"-"$pkgver"-"$pkgrel"-"$CARCH".pkg.tar.gz
if [ ! -e $PKGDEST/$TOTALPKG ]
then
TOTALPKG="$i"-"$pkgver"-"$pkgrel"-"$CARCH".pkg.tar.xz
fi
if [ ! -e $PKGDEST/$TOTALPKG ]
then
msg $PKGDEST/$TOTALPKG
msg "Couldn't find the new package"
exit 0
fi
#remove old package from local copy
DELPKG="$i"-"$pkgver"-*-"$CARCH".pkg.tar.*z
rm -fvI $DELPKG
#copy in new package
msg "############################################"
msg "Updating $CARCH/$REPO with $TOTALPKG"
cp -f $PKGDEST/$TOTALPKG .
repo-add $DOCROOT/$REPO.db.tar.gz $DOCROOT/$TOTALPKG
msg "############################################"
done
cd -
}
function update-src-pkg {
msg "---------------------------------SRC-------------------------"
DELPKG="$pkgname"-"$pkgver"-*.src.tar.*z
msg "Removing old src pkg"
if [ ! -d $PKGHOME/$REPO/$SRCPKG ]
then
msg "Creating src_pkg directory"
mkdir -p $SRCPKGHOME/$REPO
fi
rm -vf $SRCPKGHOME/$REPO/$DELPKG
msg "copying src_pkg to $SRCPKGHOME/$REPO"
cp -f $PKGHOME/$SRCPKG $SRCPKGHOME/$REPO
}
function dup_check {
if [ $REPO = "local" -o $REPO = "mv-core" ]
then
return
fi
for i in $repolist
do
if [ ! $i$PFIX = $REPO ]
then
out=`pacman -Sl $i$PFIX|cut -d" " -f2 |grep ^pkgname$`
if [ $? = 0 ]
then
msg "#######################################"
msg "$pkgname already exists in $i$PFIX"
msg " "$out
msg
msg x$cmdline|grep -q \\-f
if [ $? = 0 ]
then
msg "Force detected, making pkg anyhow"
msg "#######################################"
return
else
msg "#######################################"
exit 2
fi
fi
fi
done
}
#MAIN PROGRAM
find_repo
dup_check
bump
makepkg --asroot $cmdline || exit 1
msg "=============FINSHED CREATING PKG=================="
if [ $arch = "any" ]
then
CARCH="any"
fi
msg "---------updating database ----------"
update-repo #&& pacman -Sy
msg "----------creating source package---------"
makepkg -f --holdver --asroot --source --skipinteg && update-src-pkg
|