mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 20:13:32 +01:00
defs.mk, pkg.sh: Move log_install.sh as command into pkg.sh
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
25e4c197d3
commit
a9c8eadd18
2 changed files with 198 additions and 9 deletions
196
scripts/pkg.sh
196
scripts/pkg.sh
|
|
@ -481,6 +481,177 @@ cmd_upload()
|
|||
upload_pkg
|
||||
}
|
||||
|
||||
cmd_log_install()
|
||||
{
|
||||
local args="$*"
|
||||
|
||||
local c_format=rpm
|
||||
local c_logfile=install.log
|
||||
local c_mode_dir=false
|
||||
local c_group=`id -gn`
|
||||
local c_owner=`whoami`
|
||||
local c_suffix=
|
||||
local c_prefix=
|
||||
local c_opmode=opmode_install
|
||||
local c_absolute=0
|
||||
|
||||
set -- `getopt 'Li:a:f:l:bg:cdm:o:psS:vA' $*`
|
||||
|
||||
cfgfile_macro()
|
||||
{
|
||||
if echo "$*" | grep -qe '/etc/\|\.conf$'; then
|
||||
echo "%config(noreplace) "
|
||||
fi
|
||||
}
|
||||
|
||||
while [ "$1" != -- ]; do
|
||||
case $1 in
|
||||
-f)
|
||||
c_format=$2
|
||||
shift;;
|
||||
-l)
|
||||
c_logfile=$2
|
||||
shift;;
|
||||
-a)
|
||||
c_use_attr=true
|
||||
;;
|
||||
-i)
|
||||
c_ignore_prefix=$2
|
||||
shift
|
||||
;;
|
||||
|
||||
-b)
|
||||
;;
|
||||
-c)
|
||||
;;
|
||||
-d)
|
||||
c_mode_dir=true;;
|
||||
-D)
|
||||
;;
|
||||
-g)
|
||||
c_group=$2
|
||||
shift;;
|
||||
-m)
|
||||
c_mode=$2
|
||||
shift;;
|
||||
-o)
|
||||
c_owner=$2
|
||||
shift;;
|
||||
-p)
|
||||
;;
|
||||
-s)
|
||||
;;
|
||||
-S)
|
||||
c_suffix=$2
|
||||
shift;;
|
||||
-v)
|
||||
;;
|
||||
-L)
|
||||
c_opmode=opmode_link;;
|
||||
-A)
|
||||
c_absolute=1;;
|
||||
*)
|
||||
echo unknown option \"$1\". Exiting. >&2
|
||||
exit 1;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
shift
|
||||
|
||||
local args="`echo " $args" | sed -e 's/ -l *[^ ]*//g; s/ -f *[^ ]*//g; s/\b-a\b//g;'`"
|
||||
|
||||
if [ -z "$c_use_attr" ]; then
|
||||
#args="`echo " $args" | sed -e 's/ -g *[^ ]*//g; s/ -m *[^ ]*//g; s/ -o *[^ ]*//g;'`"
|
||||
args="`echo " $args" | sed -e 's/ -g *[^ ]*//g; s/ -o *[^ ]*//g;'`"
|
||||
fi
|
||||
|
||||
local c_target="`echo $* | rev | cut -d' ' -f1 | rev`"
|
||||
local c_source="`echo $* | rev | cut -d' ' -f2- | rev`"
|
||||
|
||||
case $c_opmode in
|
||||
|
||||
opmode_install)
|
||||
if [ -L "$c_source" ]; then
|
||||
cp -d $c_source $c_target || exit $?
|
||||
else
|
||||
install $args || exit $?
|
||||
fi
|
||||
;;
|
||||
|
||||
opmode_link)
|
||||
if [ "$c_mode_dir" = true ]; then
|
||||
echo "ignoring directory $c_source during link creation"
|
||||
exit 0
|
||||
fi
|
||||
if [ "$c_absolute" != 0 ]; then
|
||||
c_logfile=""
|
||||
c_source=`readlink -f $c_source`
|
||||
else
|
||||
c_source=`basename $c_source`
|
||||
fi
|
||||
cd `dirname $c_target`
|
||||
ln -sf $c_source `basename $c_target`
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Mode \"$c_opmode\" not implemented. Exiting." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
[ "$c_logfile" ] || {
|
||||
exit 0
|
||||
}
|
||||
|
||||
local file mode installd_file cfgfile dir
|
||||
if [ "$c_mode_dir" = true ]; then
|
||||
for file in $*; do
|
||||
echo "%dir %attr($c_mode,$c_owner,$c_group) $file" >> $c_logfile
|
||||
done
|
||||
else
|
||||
if [ -d "$c_target" ]; then
|
||||
for file in $c_source; do
|
||||
installed_file="$c_target/`basename $file`"
|
||||
cfgfile=""
|
||||
mode
|
||||
if [ "$c_mode" ]; then
|
||||
mode=$c_mode
|
||||
cfgfile=`cfgfile_macro "$installed_file"`
|
||||
else
|
||||
if [ -d "$file" ]; then
|
||||
dir="%dir "
|
||||
mode=0755
|
||||
else
|
||||
cfgfile=`cfgfile_macro "$installed_file"`
|
||||
dir=""
|
||||
mode=0644
|
||||
fi
|
||||
fi
|
||||
echo "$dir%attr($mode,$c_owner,$c_group) $cfgfile$installed_file" |
|
||||
sed "s/^$c_ignore_prefix//" >> $c_logfile
|
||||
done
|
||||
else
|
||||
installed_file="$c_target"
|
||||
cfgfile=""
|
||||
if [ "$c_mode" ]; then
|
||||
mode=$c_mode
|
||||
cfgfile=`cfgfile_macro "$installed_file"`
|
||||
else
|
||||
if [ -d "$c_source" ]; then
|
||||
dir="%dir "
|
||||
mode=0755
|
||||
else
|
||||
cfgfile=`cfgfile_macro "$installed_file"`
|
||||
dir=""
|
||||
mode=0644
|
||||
fi
|
||||
fi
|
||||
echo "$dir%attr($mode,$c_owner,$c_group) $cfgfile$c_target" | sed "s/^$c_ignore_prefix//" >> $c_logfile
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# ---- here we go
|
||||
umask 0022
|
||||
trap goodbye SIGINT SIGKILL
|
||||
|
|
@ -508,7 +679,22 @@ SCM=cvs
|
|||
[ "$CVS_RSH" ] && SSH=$CVS_RSH
|
||||
[ -d .git ] && SCM=git
|
||||
|
||||
eval set -- `getopt -- 'ht:p:m:N:R:D:P:a:F:' "$@"`
|
||||
|
||||
opts='ht:p:m:N:R:D:P:a:F:'
|
||||
args=("$@")
|
||||
while [ "$1" ]; do
|
||||
[ ${#1} = 2 -a ${1:0:1} = - ] && echo $opts | grep -q "${1:1}" && {
|
||||
echo $opts | grep -q "${1:1}" && shift
|
||||
shift
|
||||
continue
|
||||
}
|
||||
break
|
||||
done
|
||||
cmd=$1
|
||||
|
||||
set -- "${args[@]}"
|
||||
set -- "${@/$cmd/--}"
|
||||
|
||||
while [ "$1" != -- ] ; do
|
||||
case "$1" in
|
||||
-h)
|
||||
|
|
@ -557,10 +743,9 @@ shift
|
|||
SRPMS_DIR=`find_path $HOME/rpmbuild/SRPMS /usr/src/packages/SRPMS`
|
||||
RPMS_DIR=`find_path $HOME/rpmbuild/RPMS/$RPM_ARCH /usr/src/packages/RPMS/$RPM_ARCH`
|
||||
|
||||
cmd=$1
|
||||
shift
|
||||
# shift
|
||||
|
||||
[ $# -ne 0 -o ! "$cmd" ] && usage 1
|
||||
[ ! "$cmd" ] && usage 1
|
||||
|
||||
case $PKG_FORMAT in
|
||||
rpm)
|
||||
|
|
@ -624,6 +809,9 @@ release)
|
|||
hash)
|
||||
calculate_hash
|
||||
;;
|
||||
log-install)
|
||||
eval cmd_log_install "$@"
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue