mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 03:53:32 +01:00
bin, make, scripts: Re-add files necessary for packaging jw-build
Re-add all files necessary to package jw-build itself, i.e. sucessfully run make pkg-rebuild-reinstall. This adds 1892 lines of code. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
bc883deed4
commit
82eb80979d
11 changed files with 1881 additions and 0 deletions
35
bin/Makefile
Normal file
35
bin/Makefile
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
########################################################################
|
||||
# #
|
||||
# development utilities #
|
||||
# (c) 2001 jannet it services #
|
||||
# Authors: Jan Lindemann #
|
||||
# contact@jannet.de #
|
||||
# patches, bugfixes and comments are welcome at patch@jannet.de #
|
||||
# #
|
||||
# $Id$
|
||||
# #
|
||||
# This program is free software; permission to use, copy, modify, #
|
||||
# distribute, and sell this software and its documentation under the #
|
||||
# terms of the GNU Public license as published by the Free Software #
|
||||
# Foundation, either version 2 or any later version of the license, is #
|
||||
# hereby granted without fee, provided that (i) the above copyright #
|
||||
# notices and this permission notice appear in all copies of the #
|
||||
# software and related documentation, and (ii) the name of jannet may #
|
||||
# not be used in any advertising or publicity relating to the software #
|
||||
# without the specific, prior written permission of jannet. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, but #
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- #
|
||||
# TABILITY 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 Founda- #
|
||||
# tion, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
TOPDIR = ..
|
||||
|
||||
include $(TOPDIR)/make/proj.mk
|
||||
include $(JWBDIR)/make/bin.mk
|
||||
11
make/bin.mk
Normal file
11
make/bin.mk
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# generic utility modules
|
||||
# (c) 2005 jannet it services
|
||||
# contact@jannet.de
|
||||
# $Id$
|
||||
|
||||
include $(JWBDIR)/make/defs.mk
|
||||
|
||||
all install:
|
||||
clean distclean:
|
||||
$(RM) -rf $(filter-out $(LOCAL_MKFILES) CVS debug release,$(wildcard *))
|
||||
test:
|
||||
1
make/tag-defs.mk
Normal file
1
make/tag-defs.mk
Normal file
|
|
@ -0,0 +1 @@
|
|||
TAG_VERSION = V_$(shell echo $(VERSION) | $(SED) 's/[\.-]/_/g')
|
||||
7
make/tag-rules.mk
Normal file
7
make/tag-rules.mk
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
ifeq ($(VCS),cvs)
|
||||
tag.dist:
|
||||
cvs tag $(TAG_VERSION)
|
||||
|
||||
ftag.dist:
|
||||
cvs tag -F $(TAG_VERSION)
|
||||
endif
|
||||
45
make/upload-defs-rpm.mk
Normal file
45
make/upload-defs-rpm.mk
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# this makefile needs
|
||||
# PCKG_ROOT
|
||||
# VERSION
|
||||
# JWB_SCRIPT_DIR
|
||||
|
||||
#UPLOAD_SH = $(JWB_SCRIPT_DIR)/upload.sh
|
||||
#MKSPEC_SH = $(JWB_SCRIPT_DIR)/mkspec-wrapper.sh $(TOPDIR)/make/mkspec.sh
|
||||
|
||||
#FTP_FILE_MODE ?= 640
|
||||
#FTP_DIR_MODE ?= 750
|
||||
#FTP_SRC_GROUP ?= spidsrc
|
||||
#FTP_SRC_USER ?= $(shell whoami)
|
||||
#FTP_RUN_GROUP ?= spidrun
|
||||
#FTP_RUN_USER ?= $(shell whoami)
|
||||
#FTP_DEV_GROUP ?= spiddev
|
||||
#FTP_DEV_USER ?= $(shell whoami)
|
||||
#FTP_HOST ?= pkg.janware.com
|
||||
#FTP_HOST_LOGIN ?= root
|
||||
#
|
||||
#OS_NAME = $(shell echo $(OS_NAME_VERSION) | sed 's/-.*//')
|
||||
#OS_VERSION = $(shell echo $(OS_NAME_VERSION) | sed 's/[^-]\+-//')
|
||||
#
|
||||
## $(FTP_PCKG_DIR)/linux/$(OS_NAME)/$(OS_VERSION)/rpm/src
|
||||
#FTP_PCKG_DIR ?= /pub/packages
|
||||
#PCKG_ROOT ?= $(FTP_PCKG_DIR)/linux/$(OS_NAME)/$(OS_VERSION)
|
||||
##PCKG_ROOT = $(FTP_PCKG_DIR)/$(RPM_PROJECT)
|
||||
#CURRENT_SRC = $(warning PCKG_ROOT=$(PCKG_ROOT))$(PCKG_ROOT)/tgz/$(PCKG_TAR)
|
||||
#CURRENT_RPM_RUN_I386 = $(PCKG_ROOT)/$(RPM_ARCH)/$(PCKG_RPM_RUN_I386)
|
||||
#CURRENT_RPM_DEVEL_I386 = $(PCKG_ROOT)/$(RPM_ARCH)/$(PCKG_RPM_DEVEL_I386)
|
||||
#CURRENT_RPM_SRC = $(PCKG_ROOT)/src/$(PCKG_RPM_SRC)
|
||||
#REMOTE_TARGET_PREFIX = rsync_ssh://$(FTP_HOST_LOGIN)@$(FTP_HOST):/srv/ftp
|
||||
#REMOTE_TARGETS = \
|
||||
# $(REMOTE_TARGET_PREFIX)$(CURRENT_SRC):$(FTP_FILE_MODE):$(FTP_DIR_MODE):$(FTP_SRC_USER).$(FTP_SRC_GROUP) \
|
||||
# $(REMOTE_TARGET_PREFIX)$(CURRENT_RPM_RUN_I386):$(FTP_FILE_MODE):$(FTP_DIR_MODE):$(FTP_RUN_USER).$(FTP_RUN_GROUP)\
|
||||
# $(REMOTE_TARGET_PREFIX)$(CURRENT_RPM_SRC):$(FTP_FILE_MODE):$(FTP_DIR_MODE):$(FTP_SRC_USER).$(FTP_SRC_GROUP)
|
||||
#
|
||||
#ifeq ($(CREATE_DEVEL),true)
|
||||
#REMOTE_TARGETS += \
|
||||
# $(REMOTE_TARGET_PREFIX)$(CURRENT_RPM_DEVEL_I386):$(FTP_FILE_MODE):$(FTP_DIR_MODE):$(FTP_DEV_USER).$(FTP_DEV_GROUP)
|
||||
#endif
|
||||
|
||||
# $(REMOTE_TARGET_PREFIX)$(PCKG_ROOT)/CURRENT_SRC:$(FTP_FILE_MODE):$(FTP_DIR_MODE):$(FTP_SRC_USER).$(FTP_SRC_GROUP) \
|
||||
# $(REMOTE_TARGET_PREFIX)$(PCKG_ROOT)/CURRENT_RPM_SRC:$(FTP_FILE_MODE):$(FTP_DIR_MODE):$(FTP_SRC_USER).$(FTP_SRC_GROUP)
|
||||
# $(REMOTE_TARGET_PREFIX)$(PCKG_ROOT)/CURRENT_RPM_RUN_I386:$(FTP_FILE_MODE):$(FTP_DIR_MODE):$(FTP_RUN_USER).$(FTP_RUN_GROUP) \
|
||||
# $(REMOTE_TARGET_PREFIX)$(PCKG_ROOT)/CURRENT_RPM_DEVEL_I386:$(FTP_FILE_MODE):$(FTP_DIR_MODE):$(FTP_DEV_USER).$(FTP_DEV_GROUP)
|
||||
17
make/upload-rules.mk
Normal file
17
make/upload-rules.mk
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
all:
|
||||
upload.dist:
|
||||
if [ -f configure -o -f configure.ac -o -f configure.ac.tmpl ]; then make config; fi
|
||||
make $(REMOTE_TARGETS)
|
||||
touch $@.done
|
||||
|
||||
yupdate.%.dist:
|
||||
sudo -u root $(HOME)/bin/yupdate.sh -f $(HOME)/.yupdaterc -s $*
|
||||
touch $@
|
||||
|
||||
CURRENT_%:
|
||||
echo $($(notdir $@)) > $@
|
||||
|
||||
clean: upload.clean
|
||||
|
||||
upload.clean:
|
||||
$(RM) -f upload.dist yupdate.*.dist
|
||||
168
scripts/create-mkspec.sh
Normal file
168
scripts/create-mkspec.sh
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
#!/bin/bash
|
||||
|
||||
_cat()
|
||||
{
|
||||
sed 's/^ *|//'
|
||||
}
|
||||
|
||||
cfg_section()
|
||||
{
|
||||
ini_section "$inifile" $@
|
||||
}
|
||||
|
||||
cfg_value()
|
||||
{
|
||||
ini_value "$inifile" $@
|
||||
}
|
||||
|
||||
cfg_escape()
|
||||
{
|
||||
sed 's/\\/\\\\/g; s/\$/\\$/g; s/`/\\`/g'
|
||||
}
|
||||
|
||||
# unneeded but kept, because it might come in handy in the future
|
||||
have_pkg()
|
||||
{
|
||||
echo "$subpackages" | grep -q "\(^[ ]*\|[ ]\+\)$1\([ ]\+\|$\)"
|
||||
return $?
|
||||
}
|
||||
|
||||
subpackage_description()
|
||||
{
|
||||
case $1 in
|
||||
run)
|
||||
echo "Runtime files"
|
||||
;;
|
||||
devel)
|
||||
echo "Development files"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
os_cascade()
|
||||
{
|
||||
# might want to run python3 path/to/projects.py --os=suse-tumbleweed os-cascade
|
||||
# or turn this into a python script and use projects.py as a module.
|
||||
|
||||
if [ "$DISTRIBUTION" ]; then
|
||||
echo os linux $DISTRIBUTION | sed 's/\([^-]\+\)-\([^-]\+\)/\1 \1-\2/g'
|
||||
else
|
||||
echo os linux
|
||||
fi
|
||||
}
|
||||
|
||||
# -- here we go
|
||||
|
||||
echo "== running $0" "$@" >&2
|
||||
|
||||
export LANG=POSIX
|
||||
dir=`dirname $0`
|
||||
inifile="$1"
|
||||
. $dir/ini-tools.sh
|
||||
|
||||
subpackages=`cfg_value global.subpackages`
|
||||
license=`cfg_value global.license`
|
||||
[ "$license" ] || license="janware GmbH proprietary license"
|
||||
vendor=`cfg_value global.vendor`
|
||||
[ "$vendor" ] || vendor="janware GmbH"
|
||||
url=`cfg_value global.url`
|
||||
[ "$url" ] || url="https://janware.com"
|
||||
|
||||
_cat <<- EOT
|
||||
|echo "%define debug_package %{nil}"
|
||||
|# ---------------------------------------
|
||||
|echo "Name: \$NAME"
|
||||
|echo "Summary: `cfg_value summary`"
|
||||
|echo "Version: \$VERSION"
|
||||
|echo "Release: \$RELEASE"
|
||||
|echo "License: $license"
|
||||
|echo "Group: System/Libraries"
|
||||
|[ -n "\$SOURCE" ] && echo "Source: \$SOURCE"
|
||||
|echo "Vendor: $vendor"
|
||||
|echo "URL: $url"
|
||||
|echo "BuildRoot: /var/tmp/%{name}-buildroot"
|
||||
|echo "Distribution: jw / openSUSE Tumbleweed"
|
||||
|echo ""
|
||||
|echo "%description"
|
||||
|echo "`cfg_value description`"
|
||||
|echo ""
|
||||
|# ---------------------------------------
|
||||
|echo "%prep"
|
||||
|echo "%setup -q -n \$NAME-\$V"
|
||||
|echo ""
|
||||
|echo "%build"
|
||||
|echo 'pwd'
|
||||
|echo 'make config'
|
||||
|echo 'make'
|
||||
|echo ""
|
||||
|echo "%install"
|
||||
|echo 'rm -rf \$RPM_BUILD_ROOT'
|
||||
|echo "export ENV_PREFIX=\\\$RPM_BUILD_ROOT"
|
||||
|echo "export INSTALL_LOG=\$INSTALL_LOG"
|
||||
|echo "mkdir -p \`dirname \$INSTALL_LOG\`"
|
||||
|echo "> \$INSTALL_LOG"
|
||||
|echo "make install"
|
||||
|echo "export PATH=$JWB_SCRIPT_DIR:\\\$PATH"
|
||||
|echo "/bin/bash pkg.sh milk-install-log -p \\\$ENV_PREFIX -n \$NAME -t rpm -s \\"$subpackages\\" \$INSTALL_LOG \`dirname \$INSTALL_LOG\`"
|
||||
|echo "exit 0" # <- Cut short CentOS magic appended to install scriptlet, which would generate .pyo files and other cruft.
|
||||
EOT
|
||||
|
||||
for p in $subpackages; do
|
||||
|
||||
P=${p^^}
|
||||
|
||||
_cat <<- EOT
|
||||
|echo ""
|
||||
|echo "# --------------------------------------- subpackage $p"
|
||||
|echo ""
|
||||
|echo "%package -n \$NAME-$p"
|
||||
|echo "Summary: `cfg_value summary`"
|
||||
|echo "Group: `cfg_value global.group`"
|
||||
|[ "\$REQUIRES_$P" ] && echo "Requires: \$REQUIRES_$P"
|
||||
|[ "\$CONFLICTS_$P" ] && echo "Conflicts: \$CONFLICTS_$P"
|
||||
|[ "\$PROVIDES_$P" ] && echo "Provides: \$PROVIDES_$P"
|
||||
|echo ""
|
||||
EOT
|
||||
|
||||
descr=`subpackage_description $p`
|
||||
if [ "$descr" ]; then
|
||||
_cat <<- EOT
|
||||
|echo ""
|
||||
|echo "%description -n \$NAME-$p"
|
||||
|echo "$descr"
|
||||
EOT
|
||||
fi
|
||||
|
||||
for stage in pre preun post postun; do
|
||||
echo "== processing stage $stage: cfg_section pkg.$p.$stage" >&2
|
||||
out=""
|
||||
#for os in '' `os_cascade | sed 's/\(^\| \)/ ./g'`; do
|
||||
for os in '' `os_cascade`; do
|
||||
sec=pkg.$p.$stage
|
||||
if [ "$os" ]; then
|
||||
sec="$sec.$os"
|
||||
head="\n# --- $os\n"
|
||||
else
|
||||
head=""
|
||||
fi
|
||||
cfg_section $sec | grep -q . || continue
|
||||
out="$out$head`cfg_section $sec`"
|
||||
done
|
||||
if [ "$out" ]; then
|
||||
echo -e "$out" >&2
|
||||
_cat <<- EOT
|
||||
|echo ""
|
||||
|echo "%$stage -n \$NAME-$p"
|
||||
EOT
|
||||
echo "cat << EOT"
|
||||
echo -e "$out" | cfg_escape
|
||||
echo "EOT"
|
||||
fi
|
||||
done
|
||||
|
||||
_cat <<- EOT
|
||||
|echo ""
|
||||
|echo "%files -n \$NAME-$p -f \$INSTALL_LOG.\$NAME-$p"
|
||||
|echo '%defattr (-, root, root)'
|
||||
EOT
|
||||
done
|
||||
56
scripts/ini-tools.sh
Normal file
56
scripts/ini-tools.sh
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
ini_section()
|
||||
{
|
||||
local inifile="$1"
|
||||
local sec="$2"
|
||||
cat "$inifile" |
|
||||
cut -d\# -f1 |
|
||||
tr -s '\n' '\n' |
|
||||
sed -n "/^ *\[$sec\]/,/^ *\[/ p" |
|
||||
grep -v '^ *\[' |
|
||||
sed '/^ *$/ d'
|
||||
}
|
||||
|
||||
ini_value()
|
||||
{
|
||||
local inifile="$1"
|
||||
local path="$2"
|
||||
local sec=`echo "$path" | sed 's/\.[^.]\+$//'`
|
||||
local key=`echo "$path" | sed 's/.*\.//'`
|
||||
|
||||
# echo "path=>$path<"
|
||||
# echo "sec=>$sec<"
|
||||
# echo "key=>$key<"
|
||||
|
||||
if [ "$key" = "$path" ]; then
|
||||
ini_section "$inifile" "$path"
|
||||
return 0
|
||||
fi
|
||||
|
||||
ini_section "$inifile" "$sec" | sed "
|
||||
/^ *$key *=/ !d
|
||||
s/^ *$key *= *//
|
||||
s/ *$//
|
||||
/^ *$/ d
|
||||
"
|
||||
}
|
||||
|
||||
ini_has_section()
|
||||
{
|
||||
local inifile="$1"
|
||||
local sec="$2"
|
||||
grep -q "^ *\[$sec\]" $inifile || return 1
|
||||
}
|
||||
|
||||
ini_has_value()
|
||||
{
|
||||
ini_value $@ | grep -q .
|
||||
}
|
||||
|
||||
ini_escape()
|
||||
{
|
||||
cat | sed '
|
||||
s/\$/\\$/g
|
||||
s/`/\\\`/g
|
||||
'
|
||||
}
|
||||
|
||||
130
scripts/mkspec-wrapper.sh
Normal file
130
scripts/mkspec-wrapper.sh
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
#!/bin/bash
|
||||
|
||||
usage()
|
||||
{
|
||||
echo usage: $MYNAME /path/to/mkspec.sh -h [-N name] [-T topdir] [-V version] [-S source] [-R requires] [-P project] >&2
|
||||
[ "$1" ] && exit $1
|
||||
}
|
||||
|
||||
append()
|
||||
{
|
||||
local var=$1
|
||||
shift
|
||||
local tmp=`eval echo \"\\$$var $@\" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//'`
|
||||
eval $var=\"$tmp\"
|
||||
}
|
||||
|
||||
# -- here we go
|
||||
|
||||
#set -x
|
||||
|
||||
MYNAME=`basename $0`
|
||||
ID=`whoami`
|
||||
[ ! "$INSTALL_LOG" ] && INSTALL_LOG=/tmp/rpmbuild-$ID/install.log
|
||||
|
||||
eval set -- `getopt -l "provides-run:" -l "provides-devel:" -o "P:T:V:S:N:hR:D:X:Y:d:" -- "$@"`
|
||||
|
||||
while [ "$1" != -- ]; do
|
||||
echo checking "$1=$2" >&2
|
||||
case $1 in
|
||||
-h)
|
||||
usage 0;;
|
||||
-T)
|
||||
TOPDIR="$2"
|
||||
shift;;
|
||||
-V)
|
||||
V="$2"
|
||||
shift;;
|
||||
-S)
|
||||
SOURCE="$2"
|
||||
shift;;
|
||||
-N)
|
||||
NAME="$2"
|
||||
shift;;
|
||||
-R)
|
||||
append REQUIRES_RUN "$2"
|
||||
shift
|
||||
;;
|
||||
-X)
|
||||
append CONFLICTS_RUN "$2"
|
||||
shift
|
||||
;;
|
||||
-D)
|
||||
append REQUIRES_DEVEL "$2"
|
||||
shift
|
||||
;;
|
||||
-Y)
|
||||
append CONFLICTS_DEVEL "$2"
|
||||
shift
|
||||
;;
|
||||
--provides-run)
|
||||
append PROVIDES_RUN "$2"
|
||||
shift
|
||||
;;
|
||||
--provides-devel)
|
||||
append PROVIDES_DEVEL "$2"
|
||||
shift
|
||||
;;
|
||||
-P)
|
||||
PROJECT="$2"
|
||||
shift;;
|
||||
-d)
|
||||
DISTRIBUTION="$2"
|
||||
shift;;
|
||||
*)
|
||||
usage 1;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
MKSPEC_SH="$1"
|
||||
shift
|
||||
|
||||
[ -z "$TOPDIR" ] && TOPDIR=.
|
||||
|
||||
if [ -z "$V" ]; then
|
||||
if [ -f $TOPDIR/VERSION ]; then
|
||||
VERSION="`cat $TOPDIR/VERSION | cut -d- -f1`"
|
||||
RELEASE="`cat $TOPDIR/VERSION | cut -d- -f2- | sed 's/[-_].*//'`"
|
||||
else
|
||||
VERSION=noversion
|
||||
RELEASE=norelease
|
||||
fi
|
||||
else
|
||||
VERSION="`echo $V | cut -d- -f1`"
|
||||
RELEASE="`cat $TOPDIR/VERSION | cut -d- -f2- | sed 's/[-_].*//'`"
|
||||
fi
|
||||
|
||||
if [ -z "$NAME" ]; then
|
||||
NAME=`pwd | xargs basename`
|
||||
fi
|
||||
|
||||
REQUIRES="$REQUIRES_RUN $REQUIRES_DEVEL"
|
||||
CONFLICTS="$CONFLICTS_RUN $CONFLICTS_DEVEL"
|
||||
#if [ -n "$REQUIRES" ]; then
|
||||
# REQUIRES_RUN=`echo $REQUIRES |
|
||||
# sed -e '
|
||||
# s/\([a-zA-Z-]\+\) *\([<>=]*\) *\([a-zA-Z0-9\.-]*\)/\1-run \2 \3,/g
|
||||
# s/,$//
|
||||
# s/-run-run/-run/
|
||||
# '`
|
||||
# REQUIRES_DEVEL="$REQUIRES_RUN, $NAME-run = $VERSION-$RELEASE, `echo $REQUIRES_RUN | sed -e 's/-run/-devel/g'`"
|
||||
#fi
|
||||
|
||||
#echo "REQUIRES_RUN=\"$REQUIRES_RUN\""
|
||||
#exit
|
||||
|
||||
export \
|
||||
REQUIRES REQUIRES_RUN REQUIRES_DEVEL \
|
||||
CONFLICTS CONFLICTS_RUN CONFLICTS_DEVEL \
|
||||
PROVIDES PROVIDES_RUN PROVIDES_DEVEL \
|
||||
TOPDIR \
|
||||
PROJECT NAME \
|
||||
SOURCE \
|
||||
VERSION RELEASE V \
|
||||
INSTALL_LOG \
|
||||
DISTRIBUTION
|
||||
|
||||
bash $MKSPEC_SH
|
||||
|
||||
1237
scripts/pkg.sh
Normal file
1237
scripts/pkg.sh
Normal file
File diff suppressed because it is too large
Load diff
174
scripts/scm.sh
Normal file
174
scripts/scm.sh
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
#!/bin/bash
|
||||
|
||||
cmd_mv()
|
||||
{
|
||||
local from="$1"
|
||||
local to="$2"
|
||||
case $scm in
|
||||
cvs)
|
||||
cp "$from" "$to"
|
||||
cvs add "$to"
|
||||
cvs remove -f "$from"
|
||||
;;
|
||||
git)
|
||||
git mv "$from" "$to"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
cmd_commit()
|
||||
{
|
||||
C=''
|
||||
for i in "$@"; do
|
||||
C="$C \"${i//\"/\\\"}\""
|
||||
done
|
||||
eval $scm commit "$C"
|
||||
}
|
||||
|
||||
cmd_add()
|
||||
{
|
||||
$scm add "$@"
|
||||
}
|
||||
|
||||
cmd_rm()
|
||||
{
|
||||
case $scm in
|
||||
cvs)
|
||||
cvs remove "$@"
|
||||
;;
|
||||
git)
|
||||
git rm "$@"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
cmd_clean()
|
||||
{
|
||||
case $scm in
|
||||
cvs)
|
||||
while [ "${1:0:1}" = - ]; do
|
||||
shift
|
||||
done
|
||||
set +e
|
||||
local file
|
||||
for file in $@; do
|
||||
if ! grep -q "/$file/" CVS/Entries; then
|
||||
rm -f $file
|
||||
fi
|
||||
done
|
||||
;;
|
||||
git)
|
||||
git clean -x "$@"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
cmd_ls_files()
|
||||
{
|
||||
filter_deleted()
|
||||
{
|
||||
local rc_file="$1"
|
||||
shift
|
||||
local cand
|
||||
for cand in "$@"; do
|
||||
grep -q "^R ./$cand/" $rc_file && continue
|
||||
echo $cand
|
||||
done
|
||||
}
|
||||
|
||||
output()
|
||||
{
|
||||
if [ "$zero_terminate" = 1 ]; then
|
||||
echo -en "$*\x00"
|
||||
else
|
||||
echo "$*"
|
||||
fi
|
||||
}
|
||||
|
||||
list_dirents_cvs()
|
||||
{
|
||||
local dirs=`sed '/^D\// !d; s%^D/%%; s%/.*%%' $1/CVS/Entries`
|
||||
dirs="`filter_deleted $1/CVS/Entries $dirs`"
|
||||
local cands
|
||||
if [ -f $1/CVS/Entries.Log ]; then
|
||||
cands="`sed '/^A D\// !d; s%^A D/%%; s%/.*%%' $1/CVS/Entries.Log`"
|
||||
dirs="$dirs `filter_deleted $1/CVS/Entries.Log $cands`"
|
||||
fi
|
||||
local files=`sed '/^\// !d; s%/%%; s%/.*%%; s%^%%' $1/CVS/Entries`
|
||||
files="`filter_deleted $1/CVS/Entries $files`"
|
||||
local d f
|
||||
for f in $files; do
|
||||
output "$1/$f"
|
||||
done
|
||||
for d in $dirs; do
|
||||
[ "$opt_only_regular_files" = 1 ] || output $1/$d
|
||||
list_dirents_cvs $1/$d
|
||||
done
|
||||
}
|
||||
|
||||
list_dirents_git()
|
||||
{
|
||||
local opts="$git_ls_files_opts"
|
||||
git --version | grep -q "version *1" && opt_no_submodules=1
|
||||
[ "$opt_no_submodules" = 1 ] || opts="$opts --recurse-submodules"
|
||||
git ls-files --recurse-submodules $opts $1
|
||||
}
|
||||
|
||||
list_dirents()
|
||||
{
|
||||
if [ -d $1/CVS ]; then
|
||||
list_dirents_cvs $1
|
||||
return
|
||||
fi
|
||||
git status >/dev/null 2>&1 || {
|
||||
echo "failed to list versioned files in $1: no VCS" >&2
|
||||
exit 1
|
||||
}
|
||||
list_dirents_git $1
|
||||
}
|
||||
|
||||
set -- `getopt fnzt "$@"`
|
||||
|
||||
while [ "$1" != -- ]; do
|
||||
case $1 in
|
||||
-f)
|
||||
opt_only_regular_files=1
|
||||
;;
|
||||
-n)
|
||||
opt_no_submodules=1
|
||||
;;
|
||||
-z)
|
||||
zero_terminate=1
|
||||
git_ls_files_opts="$git_ls_files_opts -z"
|
||||
opt_sort="$opt_sort -z"
|
||||
;;
|
||||
-t)
|
||||
text_files=1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
proj_dir="$1"
|
||||
[ "$proj_dir" ] && cd $proj_dir
|
||||
|
||||
if [ "$text_files" ]; then
|
||||
list_dirents . | sort $opt_sort | xargs file -N | grep ":.*text" | cut -d: -f1
|
||||
else
|
||||
list_dirents . | sort $opt_sort
|
||||
fi
|
||||
}
|
||||
|
||||
# ------- here we go
|
||||
export LANG=POSIX
|
||||
myname=`basename $0`
|
||||
cmd=cmd_${1//-/_}
|
||||
shift
|
||||
if [ -d "CVS" ]; then
|
||||
scm=cvs
|
||||
else
|
||||
scm=git
|
||||
fi
|
||||
|
||||
$cmd "$@"
|
||||
Loading…
Add table
Add a link
Reference in a new issue