Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 May 2005 08:50:05 +0900 (JST)
From:      KOMATSU Shinichiro <koma2@lovepeers.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/81454: portupgrade leaves temporary directory when -b option is specified
Message-ID:  <20050524235005.AFAF756508@ksta.ms.u-tokyo.ac.jp>
Resent-Message-ID: <200505250000.j4P00Q1n039080@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         81454
>Category:       ports
>Synopsis:       portupgrade leaves temporary directory when -b option is specified
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 25 00:00:25 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     KOMATSU Shinichiro
>Release:        FreeBSD 5.4-RELEASE amd64
>Organization:
>Environment:
FreeBSD 5.4-RELEASE amd64

>Description:

portupgrade keeps bacup packages of the old versions
in temporary directory when it is run with -b option.

Since portupgrade-20041226_2, this temporary directory is created by mktemp(1)
instead of /var/tmp, and removed at the end of the portupgrade process.
But as the backup packages are kept in that directory,
rmdir fails as follows:

    --->  [Executing a command as root: sudo /usr/bin/install -m 644 /tmp/portupgrade18478.1 /var/tmp/portupgrade.results]
    ** Could not clean up temporary directory: Directory not empty - /var/tmp/portupgradeMmWsL1P6

>How-To-Repeat:

Run portupgrade >= 20041226_2 with -b option.

>Fix:

If the following patch is applied,
the backup packages are moved to the directory
specified by PKG_BACKUP_DIR environment variable
at end of the portupgrade process,
and the temporary directory becomes empty before removed.

I am wondering whether PKG_BACKUP_DIR should have the default value,
and what directory if it should have.
So, I decided to keep the old behavior if PKG_BACKUP_DIR is not set
(i.e rmdir fails at the end), but this should be changed.

--- bin/portupgrade.orig	Wed May 25 08:14:13 2005
+++ bin/portupgrade	Wed May 25 08:14:34 2005
@@ -1597,6 +1597,18 @@
   timer_end(time_key)
 end
 
+def backup_pkg(pkgfile)
+  if $backup_packages
+    if ENV['PKG_BACKUP_DIR']
+      xsystem! '/bin/mkdir', '-p', ENV['PKG_BACKUP_DIR'] \
+	unless File.directory?(ENV['PKG_BACKUP_DIR'])
+      xsystem! '/bin/mv', '-f', pkgfile, ENV['PKG_BACKUP_DIR']
+    end
+  else
+    xsystem! '/bin/rm', '-rf', pkgfile, pkgdir 
+  end
+end
+
 # raises:
 #   BackupError, UninstallError
 def uninstall_pkg(pkgname, logfile = nil, extra_flags = '')
@@ -1661,8 +1673,7 @@
       end
 
       $pkgdb_update = true
-
-      xsystem! '/bin/rm', '-rf', backup_pkgfile, pkgdir unless $backup_packages
+      backup_pkg(backup_pkgfile)
       xsystem! '/bin/mv', '-f', backup_dir, pkgdir
     when :cleanup
       progress_message "Removing temporary backup files" if $verbose
@@ -1671,6 +1682,7 @@
       files << backup_pkgfile unless $backup_packages
 
       system! '/bin/rm', '-rf', *files
+      backup_pkg(backup_pkgfile)
     end
   }
 ensure
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050524235005.AFAF756508>