blob: 8c8c667877ecd239da3ea8e81d8f565c7b03ef53 (
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
|
#!/bin/bash
# Random integrity things
[ "$UID" = "" ] && UID=$(uid)
BASEDIR="$(dirname $0)"
if [ -f "$BASEDIR/config" ]; then
. "$BASEDIR/config"
fi
# Useful functions
source_makepkg () {
if [ -f "/etc/makepkg.conf" ]; then
#Get some config info
. /etc/makepkg.conf
else
echo "/etc/makepkg.conf does not exist!"
exit 1
fi
}
UMASK=""
set_umask () {
UMASK="$(umask)"
umask 002
}
restore_umask () {
umask $UMASK
}
repo_lock () { #repo_lock repo-name arch
LOCKFILE="$TMPDIR/.repolock.$1.$2"
if [ -f "$LOCKFILE" ]; then
owner="$(/usr/bin/stat -c %U $LOCKFILE)"
echo "error: db generation is already in progress (started by $owner)"
exit 1
else
/bin/touch "$LOCKFILE"
fi
}
repo_unlock () { #repo_unlock repo-name arch
LOCKFILE="$TMPDIR/.repolock.$1.$2"
if [ ! -f "$LOCKFILE" ]; then
echo "error: repo lock doesn't exist... something went terribly wrong!"
else
rm -f "$LOCKFILE"
fi
}
# Get the package name from the filename
# hackish, but should work for now
getpkgname() {
local tmp
tmp=${1##*/}
tmp=${tmp%$PKGEXT}
tmp=${tmp%$SRCEXT}
tmp=${tmp%-$CARCH}
echo ${tmp%-*-*}
}
check_pkg_arch () { #check_pkg_arch pkgfile arch
local arch
_arch="$(/usr/bin/bsdtar -xOf "$1" .PKGINFO | /bin/grep "^arch" | /bin/sed 's|\w*\s*=\s*\(.*\)|\1|')"
if [ -z "$_arch" ]; then
echo "ERROR: Package '$1' has no arch in the PKGINFO. Fail!"
return 1
fi
if [ "$_arch" = "$2" ]; then
return 0
else
return 1
fi
}
# Simple helper function to ensure we always
# have proper DB permissions
copy_helper () { #copy_helper file dest
/bin/cp $1 $2 || return 1
dir=$2
[ -f $dir ] && dir=$(dirname $dir)
/bin/chmod 664 "$dir/$(basename $1)" || return 1
}
# vim: set ts=4 sw=4 noet ft=sh:
|