RPM database is inconsistent when a running instance of zypper was interrupted

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi , 

I recently encountered a problem using zypper install my package. I hope to get your help, thank you very much.

Product: SUSE Linux Enterprise Server 11 SP3  (x86_64)

Other Software and Versions Being Used: zypper-1.6.327-9.9 rpm-4.4.2.3-37.56.1 rpm-python-4.4.2.3-37.46.7 libzypp-9.38.8-0.7.1

Steps to reproduce: 
step 1. I build a custom RPM package, then build a zypper repo.
            custom RPM name: upg-client-1.0.0-1.x86_64
            zypper repo:   zypper ar file:///usr/src/packages/RPMS/ myrepo
                                   zypper refresh
step 2. Write two Bash scripts for testing (contexts of these scripts shown in Additional Information), one for installing upg-client RPM and another for reproduce this problem.

step 3. Run installing script, then run reproduce script.  When the installing script is stopped, we can see that "rpm -qa |grep upg-client " and "rpm -q upg-client" is inconsistent.

Additional:
[script for installing upg-client RPM:]

#!/bin/bash

LOG_FILE=/home/cps/auto_run_new_2.log
count=1
touch $LOG_FILE
while true;
do

rpm -q upg-client
if [ $? -ne 0 ];then
    echo "[`date`] upg-client-1.0.0-1.x86_64 not install, now install" >>  $LOG_FILE
    zypper -n --gpg-auto-import-keys --no-gpg-checks in upg-client-1.0.0-1.x86_64
    if [ $? -ne 0 ];then
        echo "[`date`] install upg-client-1.0.0-1.x86_64 failed" >>  $LOG_FILE
#        exit 1
    fi
fi

echo "==============sleep================="
echo "[`date`] =======sleeping 6======="  >> $LOG_FILE
sleep 3

XXX=`sudo rpm -qa| grep upg-client`
YYY=`sudo rpm -q upg-client`
if [ x$XXX = x$YYY ];then
    echo "[`date`] auto:$count======ok======= " >>  $LOG_FILE
    ((count++))
else
    if [ x$XXX = x ];then
        echo "[`date`] auto:$count======ok======="  >> $LOG_FILE
        ((count++))
    else
        echo "[`date`] error"
        exit 1
    fi
fi

echo ===remove=======
zypper -n --gpg-auto-import-keys --no-gpg-checks remove -u upg-client-1.0.0-1.x86_64
if [ $? -ne 0 ];then
    echo "[`date`] uninstall upg-client-1.0.0-1.x86_64 failed" >> $LOG_FILE
    exit 1
fi
done

=============Dividing line================
[script for reproduce the problem:]

#!/bin/bash
while true
do
#find child rpm process
pid=`ps aux| grep /var/cache/zypp/packages/myrepo/x86_64/upg-client-1.0.0-1.x86_64.rpm | grep '\-U' | awk '{print $2}'`
if [ x$pid != x ];then
    kill -9 $pid
    echo yes
else
    echo no
fi
sleep 0.5
done

=============Dividing line================
[SPEC of upg-client package, we can run "dd if=/dev/zero of=./xxx bs=10M count=1" to create file "xxx"]

Name:upg-client
Summary:TEST
Version:1.0.0
Release:1
Group:NCU
License:GPL
Vendor:NCU
Source0:        upg-client-%{version}.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root

%description
upg-client

%prep

%setup -q -n %{name}-%{version}

%install
file_list=$(find .)
rm -rf %{buildroot}
for file in $file_list
do
    if [ -d $file ];then
        install -d %{buildroot}/$file
    elif [ -f $file ];then
        install -c -m 755 $file %{buildroot}/$file
    fi
done
%post
%files
%dir /usr/local/bin/upg-client
/usr/local/bin/upg-client/xxx

%changelog
* Tue Nov 17 2015 EDU
- test
_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list




[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux