scm.sh: Honor -f in git, derive release hash from VCS file ids #110
5 changed files with 59 additions and 12 deletions
|
|
@ -113,7 +113,7 @@ reverse = $(if $(wordlist 2,2,$(1)),$(call reverse,$(wordli
|
||||||
make_subdirs = set -e; for D in $(SUBDIRS) ; do make -C $$D ; done
|
make_subdirs = set -e; for D in $(SUBDIRS) ; do make -C $$D ; done
|
||||||
make_subdirs_target = set -e; for D in $(SUBDIRS) ; do make -C $$D $@; done
|
make_subdirs_target = set -e; for D in $(SUBDIRS) ; do make -C $$D $@; done
|
||||||
install_local_cfg = $(INSTALL) -p -o $(CFGOWNER) -g $(CFGGROUP) -m $(CFGMODE) $< $@
|
install_local_cfg = $(INSTALL) -p -o $(CFGOWNER) -g $(CFGGROUP) -m $(CFGMODE) $< $@
|
||||||
cvs_files = sh $(JWB_SCRIPT_DIR)/scm.sh ls-files -f
|
cvs_files = sh $(JWB_SCRIPT_DIR)/scm.sh ls-files
|
||||||
add_flavour_prefix = $(SED) "s/\([^ ][^ ]*\) *\([<>=]*\) *\([^ ]*\)/$(FLAVOUR_PREFIX)\1 \2 \3/g"
|
add_flavour_prefix = $(SED) "s/\([^ ][^ ]*\) *\([<>=]*\) *\([^ ]*\)/$(FLAVOUR_PREFIX)\1 \2 \3/g"
|
||||||
beautify_lib_path = $(SED) 's/:/\n + /g'
|
beautify_lib_path = $(SED) 's/:/\n + /g'
|
||||||
find_files = $(wildcard $(addsuffix /$(1),$(patsubst :, ,$(2))))
|
find_files = $(wildcard $(addsuffix /$(1),$(patsubst :, ,$(2))))
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ list-text-files echo-text-files:
|
||||||
$(Q)$(LIST_VCS_FILES) -ft
|
$(Q)$(LIST_VCS_FILES) -ft
|
||||||
|
|
||||||
tar-files:
|
tar-files:
|
||||||
$(Q)$(LIST_VCS_FILES) $(TOPDIR) -f | xargs tar -C $(TOPDIR) -cf -
|
$(Q)$(LIST_VCS_FILES) $(TOPDIR) | xargs tar -C $(TOPDIR) -cf -
|
||||||
|
|
||||||
cpio-files:
|
cpio-files:
|
||||||
$(Q)$(LIST_VCS_FILES) $(TOPDIR) -f | cpio --directory=$(TOPDIR) -o -H newc
|
$(Q)$(LIST_VCS_FILES) $(TOPDIR) | cpio --directory=$(TOPDIR) -o -H newc
|
||||||
|
|
||||||
endif # ifndef LIST_FILES_MK_INCLUDED
|
endif # ifndef LIST_FILES_MK_INCLUDED
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@ RELEASES_FILE = $(TOPDIR)/RELEASES$(FLAVOUR_SUFFIX)
|
||||||
RELEASES ?= $(shell $(PKG_SH_EXE) version \
|
RELEASES ?= $(shell $(PKG_SH_EXE) version \
|
||||||
-p $(OS_NAME_VERSION)/$(PKG_ARCH) $(RELEASES_FILE) read | $(SED) 's/-dev//')
|
-p $(OS_NAME_VERSION)/$(PKG_ARCH) $(RELEASES_FILE) read | $(SED) 's/-dev//')
|
||||||
PKG_CHECK_VCS_SYNC_BEFORE_RELEASE ?= true
|
PKG_CHECK_VCS_SYNC_BEFORE_RELEASE ?= true
|
||||||
HASH = $(shell $(cvs_files) -z | \
|
HASH = $(shell $(cvs_files) -s -z | \
|
||||||
grep -vz "CHANGES\|VERSION\|HASH\|MD5SUMS\|RELEASES" | \
|
grep -vz "CHANGES\|VERSION\|HASH\|MD5SUMS\|RELEASES" | \
|
||||||
xargs -0 md5sum | md5sum | $(SED) 's/ .*//')
|
md5sum | $(SED) 's/ .*//')
|
||||||
LOCAL_REPO ?= /srv/dav/pub/local/packages/suse/$(OS_NAME_VERSION)
|
LOCAL_REPO ?= /srv/dav/pub/local/packages/suse/$(OS_NAME_VERSION)
|
||||||
|
|
||||||
PACKAGE_VCS_FILES ?= false
|
PACKAGE_VCS_FILES ?= false
|
||||||
|
|
|
||||||
|
|
@ -101,18 +101,22 @@ scm_files()
|
||||||
{
|
{
|
||||||
(
|
(
|
||||||
cd $TOPDIR
|
cd $TOPDIR
|
||||||
/bin/bash $JWB_SCRIPT_DIR/scm.sh ls-files -f "$@"
|
/bin/bash $JWB_SCRIPT_DIR/scm.sh ls-files "$@"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
calculate_hash()
|
calculate_hash()
|
||||||
{
|
{
|
||||||
(
|
local h
|
||||||
|
h=`(
|
||||||
|
set -o pipefail
|
||||||
cd $TOPDIR
|
cd $TOPDIR
|
||||||
scm_files -z | \
|
scm_files -s -z | \
|
||||||
grep -vz "CHANGES\|VERSION\|HASH\|MD5SUMS\|RELEASES" | \
|
grep -vz "CHANGES\|VERSION\|HASH\|MD5SUMS\|RELEASES" | \
|
||||||
xargs -0 md5sum | md5sum | sed 's/ .*//'
|
md5sum | sed 's/ .*//'
|
||||||
)
|
)` || fatal "failed to calculate source hash"
|
||||||
|
[ -n "$h" ] || fatal "failed to calculate source hash"
|
||||||
|
echo $h
|
||||||
}
|
}
|
||||||
|
|
||||||
check_scm()
|
check_scm()
|
||||||
|
|
@ -180,6 +184,7 @@ check_next_version()
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
local h=`calculate_hash`
|
local h=`calculate_hash`
|
||||||
|
[ -n "$h" ] || fatal "failed to calculate source hash"
|
||||||
if [ ! -f $TOPDIR/HASH ]; then
|
if [ ! -f $TOPDIR/HASH ]; then
|
||||||
echo "+ $PKG_PROJECT has no HASH file, needs release" >&2
|
echo "+ $PKG_PROJECT has no HASH file, needs release" >&2
|
||||||
echo $v
|
echo $v
|
||||||
|
|
@ -602,6 +607,7 @@ upload_pkg()
|
||||||
local p
|
local p
|
||||||
local v=`read_map $TOPDIR/VERSION | sed 's/-dev//'`
|
local v=`read_map $TOPDIR/VERSION | sed 's/-dev//'`
|
||||||
local h=`calculate_hash`
|
local h=`calculate_hash`
|
||||||
|
[ -n "$h" ] || fatal "failed to calculate source hash"
|
||||||
case $PKG_FORMAT in
|
case $PKG_FORMAT in
|
||||||
rpm)
|
rpm)
|
||||||
server=pkg.janware.com
|
server=pkg.janware.com
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,17 @@ cmd_ls_files()
|
||||||
local opts="$git_ls_files_opts"
|
local opts="$git_ls_files_opts"
|
||||||
git --version | grep -q "version *1" && opt_no_submodules=1
|
git --version | grep -q "version *1" && opt_no_submodules=1
|
||||||
[ "$opt_no_submodules" = 1 ] || opts="$opts --recurse-submodules"
|
[ "$opt_no_submodules" = 1 ] || opts="$opts --recurse-submodules"
|
||||||
|
if [ "$opt_only_regular_files" != 1 ]; then
|
||||||
git ls-files --recurse-submodules $opts $1
|
git ls-files --recurse-submodules $opts $1
|
||||||
|
else
|
||||||
|
local entry meta
|
||||||
|
while IFS= read -r -d '' entry; do
|
||||||
|
meta=${entry%%$'\t'*}
|
||||||
|
case ${meta%% *} in
|
||||||
|
100644|100755) output "${entry#*$'\t'}" ;;
|
||||||
|
esac
|
||||||
|
done < <(git ls-files -s -z --recurse-submodules $opts $1)
|
||||||
|
fi
|
||||||
if [ "$include_vcs_files" = 1 -a -d .git ]; then
|
if [ "$include_vcs_files" = 1 -a -d .git ]; then
|
||||||
output_find .git
|
output_find .git
|
||||||
fi
|
fi
|
||||||
|
|
@ -140,7 +150,33 @@ cmd_ls_files()
|
||||||
list_dirents_git $1
|
list_dirents_git $1
|
||||||
}
|
}
|
||||||
|
|
||||||
set -- `getopt fnzta "$@"`
|
list_dirents_git_ids()
|
||||||
|
{
|
||||||
|
local entry meta mode sha
|
||||||
|
while IFS= read -r -d '' entry; do
|
||||||
|
meta=${entry%%$'\t'*}
|
||||||
|
mode=${meta%% *}
|
||||||
|
sha=${meta##* }
|
||||||
|
[ "$opt_no_submodules" = 1 ] && [ "$mode" = 160000 ] && continue
|
||||||
|
[ "$opt_only_regular_files" = 1 ] && [ "$mode" != 100644 ] && [ "$mode" != 100755 ] && continue
|
||||||
|
output "$sha ${entry#*$'\t'}"
|
||||||
|
done < <(git ls-tree -r -z HEAD "$1")
|
||||||
|
}
|
||||||
|
|
||||||
|
list_dirents_ids()
|
||||||
|
{
|
||||||
|
if [ -d $1/CVS ]; then
|
||||||
|
echo "failed to list file ids in $(realpath $1): $scm has no file ids" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
git -C $1 status >/dev/null 2>&1 || {
|
||||||
|
echo "failed to list file ids in $(realpath $1): no VCS" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
list_dirents_git_ids $1
|
||||||
|
}
|
||||||
|
|
||||||
|
set -- `getopt fnzsta "$@"`
|
||||||
|
|
||||||
while [ "$1" != -- ]; do
|
while [ "$1" != -- ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
|
|
@ -150,6 +186,9 @@ cmd_ls_files()
|
||||||
-n)
|
-n)
|
||||||
opt_no_submodules=1
|
opt_no_submodules=1
|
||||||
;;
|
;;
|
||||||
|
-s)
|
||||||
|
show_ids=1
|
||||||
|
;;
|
||||||
-z)
|
-z)
|
||||||
zero_terminate=1
|
zero_terminate=1
|
||||||
git_ls_files_opts="$git_ls_files_opts -z"
|
git_ls_files_opts="$git_ls_files_opts -z"
|
||||||
|
|
@ -171,6 +210,8 @@ cmd_ls_files()
|
||||||
|
|
||||||
if [ "$text_files" ]; then
|
if [ "$text_files" ]; then
|
||||||
list_dirents . | sort $opt_sort | xargs file -N | grep ":.*text" | cut -d: -f1
|
list_dirents . | sort $opt_sort | xargs file -N | grep ":.*text" | cut -d: -f1
|
||||||
|
elif [ "$show_ids" = 1 ]; then
|
||||||
|
list_dirents_ids . | sort $opt_sort -k2
|
||||||
else
|
else
|
||||||
list_dirents . | sort $opt_sort
|
list_dirents . | sort $opt_sort
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue