FS#5887 - Pacman: Error checking when removing packages

Attached to Project: Pacman
Opened by Chris Mortimore (chrismortimore) - Friday, 24 November 2006, 22:11 GMT
Last edited by Aaron Griffin (phrakture) - Thursday, 08 February 2007, 08:10 GMT
Task Type Feature Request
Category
Status Closed
Assigned To Aaron Griffin (phrakture)
Architecture not specified
Severity Medium
Priority Normal
Reported Version 0.7.2 Gimmick
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Request: Error checking when removing packages. Problems occur when the filesystems are mounted read only, and "pacman -R [package]" is ran. Pacman tries to remove [package], errors about a read only filesystem are thrown to the screen, but pacman still removes the package from the database. This means that the files remain orphaned on the system. I consider this a bug, but tomk considers it a feature request.

Discussed in this thread: http://bbs.archlinux.org/viewtopic.php?t=27233&highlight=
This task depends upon

This task blocks these from closing
 FS#6316 - Pacman 3 release bugcatcher 
Closed by  Dan McGee (toofishes)
Monday, 12 February 2007, 00:38 GMT
Reason for closing:  Fixed
Additional comments about closing:  Fixed in pacman CVS.
Comment by Georg Grabler (STiAT) - Wednesday, 07 February 2007, 18:06 GMT
with the c system procedure (system call)

access (path, W_OK);

you could simply check if the filesystem in this path is writable (even the file), doing this for all files in the list before starting to remove (even one) file of the package:

for (lp = alpm_list_last(info->files; lp; lp = lp->prev) {
if (access(lp->data)) { // don't know if lp->data holds the full path...
return (1); // error case - file not writable, can't delete
}
}

for(lp = alpm_list_last(info->files); lp; lp = lp->prev) {
unlink_file(info, lp, targ, trans, filenum, &position);
}

A bit sad you have to go trough the list twice, but the only way in my eyes.

Kind regards,
Georg
Comment by Georg Grabler (STiAT) - Wednesday, 07 February 2007, 18:07 GMT
if (access(lp->data, W_OK)) {

of course, sometimes a bit of a brainless fast-writer.
Comment by Aaron Griffin (phrakture) - Thursday, 08 February 2007, 08:10 GMT
Added in CVS using mostly what Georg suggested above.
Comment by Dan McGee (toofishes) - Monday, 12 February 2007, 00:38 GMT
Tested by remounting /boot and trying to install kernel26. Pacman now prints an error message stating the mount is read-only.

Loading...