]> pd.if.org Git - zpackage/commitdiff
add conflict checking for installs
authorNathan Wagner <nw@hydaspes.if.org>
Tue, 21 Aug 2018 19:17:28 +0000 (19:17 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Tue, 21 Aug 2018 19:17:28 +0000 (19:17 +0000)
zpm-install

index 40e5a4353bcba237d7e805c2dcd95a899b016a2a..af14c4d364de847df6591293b583a539cab34d12 100755 (executable)
@@ -242,6 +242,49 @@ do_upgrade() {
        EOS
 }
 
+conflicts() {
+       echo conflict check $pkg $pkgfile
+       #newver=$1
+       {
+       zpm shell $pkgfile<<-EOS
+               .separator " "
+               select hash,path from packagefiles
+               where package||'-'||version||'-'||release = '$pkg'
+               and filetype = 'r'
+               ;
+       EOS
+       } | while read hash path; do
+               rpath=$pkgroot$path
+               if [ -f $rpath ]; then
+                       ihash=$(zpm hash $rpath)
+                       if [ $ihash != $hash ]; then
+                               die $path already exists
+                       fi
+               elif [ -d $rpath ]; then
+                       die $path already exists
+               fi
+       done
+
+       {
+       zpm shell $pkgfile<<-EOS
+               .separator " "
+               select path from packagefiles
+               where package||'-'||version||'-'||release = '$pkg'
+               and filetype = 'd'
+               ;
+       EOS
+       } | while read hash path; do
+               rpath=$pkgroot$path
+               if [ -f $rpath ]; then
+                       die $path already exists
+               elif [ -d $rpath ]; then
+                       die $path already exists
+               elif [ -e $rpath ]; then
+                       die $path already exists
+               fi
+       done
+}
+
 for pkg in $pkglist; do
        pname=$(pkgname $pkg)
        curver=$(zpm findpkg $ZPMDB $pname)
@@ -277,6 +320,8 @@ for pkg in $pkglist; do
 
        # check for conflicts
 
+       conflicts $pkgroot $pkg
+
        # mark package in localdb as installing
        # zpm setmark installing $pkg
        # install all the files for a package
@@ -286,12 +331,14 @@ for pkg in $pkglist; do
        echo $filecount files
        #die 'aborting for test'
        #pathlist
+       zpm pkg $pkg status installing
        pathlist | xargs zpm ipkgfile ${user+-u $user} ${group+-g $group} -R "$pkgroot" -f $pkgfile -- $pkg
 
        # TODO find scripts marked as post-install
        # TODO if this is an upgrade, run post-upgrade
 
        # mark as ready for install
+       zpm pkg $pkg status installed
        #zpm setmark ready $pkg
 done