bin sh Copyright 2008 Mikhail Gusarov dottedmag altlinux org hsh wrapp

 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
#!/bin/sh
#
# Copyright (C) 2008 Mikhail Gusarov <dottedmag@altlinux.org>
#
# hsh wrapper for building packages on tmpfs
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
. gear-sh-functions
. shell-getopt
print_version()
{
cat <<EOF
$PROG version $PROG_VERSION
Written by Mikhail Gusarov <dottedmag@altlinux.org>
Copyright (C) 2008 Mikhail Gusarov <dottedmag@altlinux.org>
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
EOF
exit
}
hash_repo_dir() {
echo "$1" | sed -e 's,/,_,g'
}
GETOPT_ALLOW_UNKNOWN=1
TEMP=`getopt -n $PROG -o 'h,V' -l 'repo:,repo-bin:,repo-src:,help,version' -- "$@"` || show_usage
eval set -- "$TEMP"
while :; do
case "$1" in
--repo|--repo-bin|--repo-src)
option=$1
show_usage "hsh(1) option $1 is not supported in $PROG"
exit
;;
-h|--help)
hsh -h | awk 'BEGIN { show=1 }
/^hsh/ { $1="hsh-tmpfs"; $4="package in tmpfs" }
/^Usage:/ { $0="Usage: hsh-tmpfs [options] [<path-to-repodir>] <package>..." }
/^<path-to-workdir>/ { $1="<path-to-repodir>" }
/--repo/ { show=0 }
/--save-fakeroot/ { show=1 }
{ if(show) print }'
exit
;;
-V|--version)
print_version
;;
--)
shift
break
;;
esac
shift
done
if [ $# -eq 0 ]; then
show_usage "At least one argument is required"
fi
REPODIR=$1
shift
mkdir -p "$REPODIR" || show_usage "Unable to create repository in $REPODIR"
REPODIR=`realpath $REPODIR`
WORKDIR=/tmp/.private/$USER/`hash_repo_dir "$REPODIR"`
mkdir -p "$WORKDIR" || show_usage "Unable to create hasher worker directory in $WORKDIR"
exec hsh --repo="$REPODIR" "$WORKDIR" "$@"