diff --git a/Ongoing-fixes-on-rhbz#2100617.patch b/Ongoing-fixes-on-rhbz#2100617.patch new file mode 100644 index 0000000..4736898 --- /dev/null +++ b/Ongoing-fixes-on-rhbz#2100617.patch @@ -0,0 +1,57 @@ +From 3589b183d18d0ed839b947b973ce53b4d73836eb Mon Sep 17 00:00:00 2001 +From: Jiri Vanek +Date: Mon, 3 Oct 2022 18:53:30 +0200 +Subject: [PATCH] Ongoing fixes on rhbz#2100617 + +- properly elaborat eonl on one file $x instead of $@ +- proeprly cleanup config dir +- do not check switch for existence but jsut use it +--- + copy_jdk_configs_fixFiles.sh | 20 +++++++++++++++----- + 1 file changed, 15 insertions(+), 5 deletions(-) + +diff --git copy_jdk_configs_fixFiles.sh copy_jdk_configs_fixFiles.sh +index 0e4ce9f..2e5d603 100755 +--- copy_jdk_configs_fixFiles.sh ++++ copy_jdk_configs_fixFiles.sh +@@ -37,17 +37,23 @@ mvDebug() { + } + + rmDebug() { ++ local switch="" + for x in "$@" ; do +- if isJavaConfig "$x" ; then +- cmdvDebug rm "$@" ++ if [[ $x == -* ]] ; then ++ switch="$switch $x" ++ elif isJavaConfig "$x" ; then ++ cmdvDebug rm $switch "$x" + fi + done + } + + rmdirDebug() { ++ local switch="" + for x in "$@" ; do +- if isJavaConfig "$x" ; then +- cmdvDebug rmdir "$@" ++ if [[ $x == -* ]] ; then ++ switch="$switch $x" ++ elif isJavaConfig "$x" ; then ++ cmdvDebug rmdir $switch "$x" + fi + done + } +@@ -55,7 +61,11 @@ rmdirDebug() { + #we should be pretty strict about removing once used (even "used" [with fail]) config file, as it may corrupt another installation + clean(){ + debug "cleanup: removing $config" +- rmDebug -rf $config ++ if [ "x$debug" == "xtrue" ] ; then ++ rm -rf $config -v ++ else ++ rm -rf $config 1>/dev/null 2>&1 ++ fi + } + + if [ "x" == "x$config" ] ; then diff --git a/copy-jdk-configs.spec b/copy-jdk-configs.spec index 9d2ea1d..16fa513 100644 --- a/copy-jdk-configs.spec +++ b/copy-jdk-configs.spec @@ -1,15 +1,20 @@ %global pretrans_install %(cat %{SOURCE0} | sed s/%%/%%%%/g | sed s/\\^%%%%/^%%/g) Name: copy-jdk-configs -Version: 4.0 +Version: 4.1 Release: 1 Summary: JDKs Configuration File License: BSD -URL: https://pagure.io/copy_jdk_configs -Source0: %{URL}/blob/88d3ed89f30d8b0eb4877d860fa8d951f224f156/f/copy_jdk_configs.lua -Source1: %{URL}/blob/88d3ed89f30d8b0eb4877d860fa8d951f224f156/f/LICENSE -Source2: %{URL}/blob/88d3ed89f30d8b0eb4877d860fa8d951f224f156/f/copy_jdk_configs_fixFiles.sh +URL: https://github.com/rh-openjdk/copy_jdk_configs +Source0: %{URL}/raw/copy_jdk_configs-%{version}/copy_jdk_configs.lua +Source1: %{URL}/raw/copy_jdk_configs-%{version}/LICENSE +Source2: %{URL}/raw/copy_jdk_configs-%{version}/copy_jdk_configs_fixFiles.sh + +Patch0: Ongoing-fixes-on-rhbz#2100617.patch + BuildArch: noarch Requires: lua lua-posix +Requires: findutils +OrderWithRequires: findutils %description Utility script for transferring JDK configuration files when updating or @@ -17,6 +22,8 @@ archiving. Repair rpmnew file created by error by using scrip %prep cp -a %{SOURCE1} . +cp -a %{SOURCE2} . +%patch0 -p0 %build %pretrans -p @@ -36,7 +43,7 @@ end %install install -D %{SOURCE0} $RPM_BUILD_ROOT/%{_libexecdir}/copy_jdk_configs.lua -install -D %{SOURCE2} $RPM_BUILD_ROOT/%{_libexecdir}/copy_jdk_configs_fixFiles.sh +install -D %{_builddir}/copy_jdk_configs_fixFiles.sh $RPM_BUILD_ROOT/%{_libexecdir}/copy_jdk_configs_fixFiles.sh %posttrans rm "%{rpm_state_dir}/copy_jdk_configs.lua" 2> /dev/null || : @@ -46,7 +53,10 @@ rm "%{rpm_state_dir}/copy_jdk_configs.lua" 2> /dev/null || : %license LICENSE %changelog -* Thu Jan 06 2020 xu_ping - 4.0-1 +* Wed Oct 25 2023 xu_ping<707078654@qq.com> - 4.1-1 +- update to 4.1 + +* Mon Jan 06 2020 xu_ping - 4.0-1 - Upgrade 4.0 to fix Packaging scriptlets assume global 'arg' in Lua environment * Thu Nov 28 2019 gulining - 3.7-3 diff --git a/copy-jdk-configs.yaml b/copy-jdk-configs.yaml index 36025ab..fa25a6b 100644 --- a/copy-jdk-configs.yaml +++ b/copy-jdk-configs.yaml @@ -1,4 +1,4 @@ version_control: git -src_repo: https://pagure.io/copy_jdk_configs.git +src_repo: https://github.com/rh-openjdk/copy_jdk_configs.git tag_prefix: ^copy_jdk_configs- seperator: . diff --git a/copy_jdk_configs.lua b/copy_jdk_configs.lua old mode 100755 new mode 100644 diff --git a/copy_jdk_configs_fixFiles.sh b/copy_jdk_configs_fixFiles.sh old mode 100755 new mode 100644 index 7e87be8..0e4ce9f --- a/copy_jdk_configs_fixFiles.sh +++ b/copy_jdk_configs_fixFiles.sh @@ -10,6 +10,20 @@ debug(){ debug "cjc: bash debug is on" +isJavaConfig() { + local arg="${1}" + local relpath=`realpath -s $arg` + local realink=`readlink -f $arg` + if [[ ${relpath} = /usr/lib/jvm/java* || ${relpath} = /etc/java/java* ]] ; then + if [[ ${realink} = /usr/lib/jvm/java* || ${realink} = /etc/java/java* ]] ; then + debug "$arg / ${relpath} / ${realink} is correct jdk folder" + return 0 + fi + fi + debug "$arg / ${relpath} / ${realink} is not jdk folder, file/dir should be skipped" + return 1 +} + cmdvDebug() { if [ "x$debug" == "xtrue" ] ; then "$@" -v @@ -23,11 +37,19 @@ mvDebug() { } rmDebug() { - cmdvDebug rm "$@" + for x in "$@" ; do + if isJavaConfig "$x" ; then + cmdvDebug rm "$@" + fi + done } rmdirDebug() { - cmdvDebug rmdir "$@" + for x in "$@" ; do + if isJavaConfig "$x" ; then + cmdvDebug rmdir "$@" + fi + done } #we should be pretty strict about removing once used (even "used" [with fail]) config file, as it may corrupt another installation @@ -225,9 +247,12 @@ done debug "cleaning legacy leftowers" if [ "x$debug" == "xtrue" ] ; then - find $sourceSearchPath -empty -type d -delete + emptyCandidates=`find $sourceSearchPath -empty -type d` else - find $sourceSearchPath -empty -type d -delete 2>/dev/null >/dev/null + emptyCandidates=`find $sourceSearchPath -empty -type d 2>/dev/null` +fi +if [ ! "x$emptyCandidates" == "x" ] ; then + rmdirDebug $emptyCandidates fi rmdirDebug $sourceSearchPath