FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 02-16-2008, 02:06 PM
Chantry Xavier
 
Default Add new SharedPkgCache option.

As it was already mentioned several times, the new -Sc behavior in 3.1 is
great, but only when the package cache is not shared.

When this option is enabled, -Sc will clean packages that are no longer
available in any sync db, rather than packages that are no longer in the
local db. The resulting behavior should be better for shared cache.

Ref :
http://www.archlinux.org/pipermail/pacman-dev/2008-February/011140.html

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
---
doc/pacman.8.txt | 3 ++
doc/pacman.conf.5.txt | 8 ++++++
src/pacman/conf.h | 9 +++++--
src/pacman/pacman.c | 3 ++
src/pacman/sync.c | 58 +++++++++++++++++++++++++++++++++---------------
5 files changed, 60 insertions(+), 21 deletions(-)

diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt
index f6eb69c..611fa3e 100644
--- a/doc/pacman.8.txt
+++ b/doc/pacman.8.txt
@@ -241,6 +241,9 @@ Sync Options[[SO]]
packages that are no longer installed; use two to remove all packages
from the cache. In both cases, you will have a yes or no option to
remove packages and/or unused downloaded databases.
++
+If you use a network shared cache, see the 'SharedPkgCache' option in
+linkmanacman.conf[5].

*-e, --dependsonly*::
Install all dependencies of a package, but not the specified package
diff --git a/doc/pacman.conf.5.txt b/doc/pacman.conf.5.txt
index e8f7454..c1b76e8 100644
--- a/doc/pacman.conf.5.txt
+++ b/doc/pacman.conf.5.txt
@@ -131,6 +131,14 @@ Options
than the percent of each individual download target. The progress
bar is still based solely on the current file download.

+*SharedPkgCache*::
+ If set, the '-Sc' operation will clean outdated packages (not present in
+ any sync database), rather than packages that are no longer installed
+ (not present in the local database).
+ This is especially useful when the package cache is shared among multiple
+ machines, where the local databases are usually different, but the sync
+ databases used could be the same.
+
Repository Sections
-------------------
Each repository section defines a section name and at least one location where
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index f804f56..a54a9f1 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -67,9 +67,12 @@ typedef struct __config_t {
unsigned short chomp; /* I Love Candy! */
unsigned short usecolor; /* enable colorful output */
unsigned short showsize; /* show individual package sizes */
- unsigned short totaldownload; /* When downloading, display the amount
- downloaded, rate, ETA, and percent
- downloaded of the total download list */
+ /* When downloading, display the amount downloaded, rate, ETA, and percent
+ * downloaded of the total download list */
+ unsigned short totaldownload;
+ /* if the cache is shared, -Sc will clean outdated packages rather than
+ * packages that are no longer installed */
+ unsigned short sharedpkgcache;
} config_t;

/* Operations */
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 377ea3f..7753833 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -638,6 +638,9 @@ static int _parseconfig(const char *file, const char *givensection,
} else if(strcmp(key, "TotalDownload") == 0 || strcmp(upperkey, "TOTALDOWNLOAD") == 0) {
config->totaldownload = 1;
pm_printf(PM_LOG_DEBUG, "config: totaldownload
");
+ } else if(strcmp(key, "SharedPkgCache") == 0 || strcmp(upperkey, "SHAREDPKGCACHE") == 0) {
+ config->sharedpkgcache = 1;
+ pm_printf(PM_LOG_DEBUG, "config: usedelta
");
} else {
pm_printf(PM_LOG_ERROR, _("config file %s, line %d: directive '%s' not recognized.
"),
file, linenum, key);
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 27218d6..cf11710 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -125,13 +125,17 @@ static int sync_cleancache(int level)
/* incomplete cleanup */
DIR *dir;
struct dirent *ent;
- /* Let's vastly improve the way this is done. Before, we went by package
- * name. Instead, let's only keep packages we have installed. Open up each
- * package and see if it has an entry in the local DB; if not, delete it.
- */
+ /* Open up each package and see if it has an entry in the local DB; if not,
+ * delete it. */
printf(_("Cache directory: %s
"), cachedir);
- if(!yesno(_("Do you want to remove uninstalled packages from cache? [Y/n] "))) {
- return(0);
+ if(config->sharedpkgcache) {
+ if(!yesno(_("Do you want to remove outdated packages from cache? [Y/n] "))) {
+ return(0);
+ }
+ } else {
+ if(!yesno(_("Do you want to remove uninstalled packages from cache? [Y/n] "))) {
+ return(0);
+ }
}
printf(_("removing old packages from cache... "));

@@ -145,13 +149,14 @@ static int sync_cleancache(int level)
/* step through the directory one file at a time */
while((ent = readdir(dir)) != NULL) {
char path[PATH_MAX];
- pmpkg_t *localpkg = NULL, *dbpkg = NULL;
+ int delete = 1;
+ pmpkg_t *localpkg = NULL, *pkg = NULL;

if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) {
continue;
}
/* build the full filepath */
- snprintf(path, PATH_MAX, "%s/%s", cachedir, ent->d_name);
+ snprintf(path, PATH_MAX, "%s%s", cachedir, ent->d_name);

/* attempt to load the package, skip file on failures as we may have
* files here that aren't valid packages. we also don't need a full
@@ -159,19 +164,36 @@ static int sync_cleancache(int level)
if(alpm_pkg_load(path, 0, &localpkg) != 0 || localpkg == NULL) {
continue;
}
- /* check if this package is in the local DB */
- dbpkg = alpm_db_get_pkg(db_local, alpm_pkg_get_name(localpkg));
- if(dbpkg == NULL) {
- /* delete package, not present in local DB */
- unlink(path);
- } else if(alpm_pkg_vercmp(alpm_pkg_get_version(localpkg),
- alpm_pkg_get_version(dbpkg)) != 0) {
- /* delete package, it was found but version differs */
- unlink(path);
+ if(config->sharedpkgcache) {
+ /* check if this package is in a sync DB */
+ alpm_list_t *sync_dbs = alpm_option_get_syncdbs();
+ alpm_list_t *j;
+
+ for(j = sync_dbs; j; j = alpm_list_next(j)) {
+ pmdb_t *db = alpm_list_getdata(j);
+ pkg = alpm_db_get_pkg(db, alpm_pkg_get_name(localpkg));
+ if(pkg != NULL && alpm_pkg_vercmp(alpm_pkg_get_version(localpkg),
+ alpm_pkg_get_version(pkg)) == 0) {
+ /* package was found in a sync DB and version matches, keep it */
+ delete = 0;
+ break;
+ }
+ }
+ } else {
+ /* check if this package is in the local DB */
+ pkg = alpm_db_get_pkg(db_local, alpm_pkg_get_name(localpkg));
+ if(pkg != NULL && alpm_pkg_vercmp(alpm_pkg_get_version(localpkg),
+ alpm_pkg_get_version(pkg)) == 0) {
+ /* package was found in local DB and version matches, keep it */
+ delete = 0;
+ }
}
- /* else version was the same, so keep the package */
/* free the local file package */
alpm_pkg_free(localpkg);
+
+ if(delete) {
+ unlink(path);
+ }
}
printf(_("done.
"));
} else {
--
1.5.4


_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 02-17-2008, 02:37 PM
"Roman Kyrylych"
 
Default Add new SharedPkgCache option.

2008/2/16, Chantry Xavier <shiningxc@gmail.com>:
> As it was already mentioned several times, the new -Sc behavior in 3.1 is
> great, but only when the package cache is not shared.
>
> When this option is enabled, -Sc will clean packages that are no longer
> available in any sync db, rather than packages that are no longer in the
> local db. The resulting behavior should be better for shared cache.
>

Great name! :-)

BTW, I've just realized that there might be a problem with "no longer
in any sync db" that, I think was not in 3.0's -Sc:
if SystemA has core,extra,community enabled and SystemB only
core&extra then doing -Sc on SystemB will cleanup community packages
from the shared cache.
I don't know if it's worth to fix this by using a more complicated
(filename comparison, AFAIR) aproach like in 3.0. :-/

--
Roman Kyrylych (*оман Кирилич)
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 02-17-2008, 02:46 PM
Xavier
 
Default Add new SharedPkgCache option.

On Sun, Feb 17, 2008 at 05:37:13PM +0200, Roman Kyrylych wrote:
> 2008/2/16, Chantry Xavier <shiningxc@gmail.com>:
> > As it was already mentioned several times, the new -Sc behavior in 3.1 is
> > great, but only when the package cache is not shared.
> >
> > When this option is enabled, -Sc will clean packages that are no longer
> > available in any sync db, rather than packages that are no longer in the
> > local db. The resulting behavior should be better for shared cache.
> >
>
> Great name! :-)
>
> BTW, I've just realized that there might be a problem with "no longer
> in any sync db" that, I think was not in 3.0's -Sc:
> if SystemA has core,extra,community enabled and SystemB only
> core&extra then doing -Sc on SystemB will cleanup community packages
> from the shared cache.
> I don't know if it's worth to fix this by using a more complicated
> (filename comparison, AFAIR) aproach like in 3.0. :-/
>

Indeed, that's a problem, but don't know if it's a big one. I would think
it's rather common to use the same set of sync db on a set of machines
sharing pkg cache. And that approach is indeed much simpler.

I mentioned this in the man page, that this option is rather meant for setup
where same sync dbs are used.

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 02-17-2008, 03:14 PM
"Roman Kyrylych"
 
Default Add new SharedPkgCache option.

2008/2/17, Xavier <shiningxc@gmail.com>:
> On Sun, Feb 17, 2008 at 05:37:13PM +0200, Roman Kyrylych wrote:
> > 2008/2/16, Chantry Xavier <shiningxc@gmail.com>:
> > > As it was already mentioned several times, the new -Sc behavior in 3.1 is
> > > great, but only when the package cache is not shared.
> > >
> > > When this option is enabled, -Sc will clean packages that are no longer
> > > available in any sync db, rather than packages that are no longer in the
> > > local db. The resulting behavior should be better for shared cache.
> > >
> >
> > Great name! :-)
> >
> > BTW, I've just realized that there might be a problem with "no longer
> > in any sync db" that, I think was not in 3.0's -Sc:
> > if SystemA has core,extra,community enabled and SystemB only
> > core&extra then doing -Sc on SystemB will cleanup community packages
> > from the shared cache.
> > I don't know if it's worth to fix this by using a more complicated
> > (filename comparison, AFAIR) aproach like in 3.0. :-/
> >
>
> Indeed, that's a problem, but don't know if it's a big one. I would think
> it's rather common to use the same set of sync db on a set of machines
> sharing pkg cache. And that approach is indeed much simpler.
>
> I mentioned this in the man page, that this option is rather meant for setup
> where same sync dbs are used.

Ah, OK, didn't read that. :-)
Then we can forget about this corner case,
it can be worked around by cache cleanup scripts based on filename parsing
(available on BBS and ML).

--
Roman Kyrylych (*оман Кирилич)
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 02-18-2008, 05:37 AM
"Dan McGee"
 
Default Add new SharedPkgCache option.

On Feb 17, 2008 10:14 AM, Roman Kyrylych <roman.kyrylych@gmail.com> wrote:
> 2008/2/17, Xavier <shiningxc@gmail.com>:
> > On Sun, Feb 17, 2008 at 05:37:13PM +0200, Roman Kyrylych wrote:
> > > 2008/2/16, Chantry Xavier <shiningxc@gmail.com>:
> > > > As it was already mentioned several times, the new -Sc behavior in 3.1 is
> > > > great, but only when the package cache is not shared.
> > > >
> > > > When this option is enabled, -Sc will clean packages that are no longer
> > > > available in any sync db, rather than packages that are no longer in the
> > > > local db. The resulting behavior should be better for shared cache.
> > > >
> > >
> > > Great name! :-)
> > >
> > > BTW, I've just realized that there might be a problem with "no longer
> > > in any sync db" that, I think was not in 3.0's -Sc:
> > > if SystemA has core,extra,community enabled and SystemB only
> > > core&extra then doing -Sc on SystemB will cleanup community packages
> > > from the shared cache.
> > > I don't know if it's worth to fix this by using a more complicated
> > > (filename comparison, AFAIR) aproach like in 3.0. :-/
> > >
> >
> > Indeed, that's a problem, but don't know if it's a big one. I would think
> > it's rather common to use the same set of sync db on a set of machines
> > sharing pkg cache. And that approach is indeed much simpler.
> >
> > I mentioned this in the man page, that this option is rather meant for setup
> > where same sync dbs are used.
>
> Ah, OK, didn't read that. :-)
> Then we can forget about this corner case,
> it can be worked around by cache cleanup scripts based on filename parsing
> (available on BBS and ML).

And now we are back to the whole reason why I think this is a
pointless problem to solve. :P

Once you venture into the shared cache realm, I just don't see a need
for pacman to hand-hold you.

So we have Xav and Roman in support of this, and me against it. I
don't want to say "majority rules" here, but I would like to get a few
more voices on this one. Aaron?

-Dan

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 02-18-2008, 07:06 AM
"Roman Kyrylych"
 
Default Add new SharedPkgCache option.

2008/2/18, Dan McGee <dpmcgee@gmail.com>:
> On Feb 17, 2008 10:14 AM, Roman Kyrylych <roman.kyrylych@gmail.com> wrote:
> > 2008/2/17, Xavier <shiningxc@gmail.com>:
> > > On Sun, Feb 17, 2008 at 05:37:13PM +0200, Roman Kyrylych wrote:
> > > > 2008/2/16, Chantry Xavier <shiningxc@gmail.com>:
> > > > > As it was already mentioned several times, the new -Sc behavior in 3.1 is
> > > > > great, but only when the package cache is not shared.
> > > > >
> > > > > When this option is enabled, -Sc will clean packages that are no longer
> > > > > available in any sync db, rather than packages that are no longer in the
> > > > > local db. The resulting behavior should be better for shared cache.
> > > > >
> > > >
> > > > Great name! :-)
> > > >
> > > > BTW, I've just realized that there might be a problem with "no longer
> > > > in any sync db" that, I think was not in 3.0's -Sc:
> > > > if SystemA has core,extra,community enabled and SystemB only
> > > > core&extra then doing -Sc on SystemB will cleanup community packages
> > > > from the shared cache.
> > > > I don't know if it's worth to fix this by using a more complicated
> > > > (filename comparison, AFAIR) aproach like in 3.0. :-/
> > > >
> > >
> > > Indeed, that's a problem, but don't know if it's a big one. I would think
> > > it's rather common to use the same set of sync db on a set of machines
> > > sharing pkg cache. And that approach is indeed much simpler.
> > >
> > > I mentioned this in the man page, that this option is rather meant for setup
> > > where same sync dbs are used.
> >
> > Ah, OK, didn't read that. :-)
> > Then we can forget about this corner case,
> > it can be worked around by cache cleanup scripts based on filename parsing
> > (available on BBS and ML).
>
> And now we are back to the whole reason why I think this is a
> pointless problem to solve. :P

Not pointless at all, Xavier's solution will work on majority of
configurations with a shared cache (that have the same set of repos
enabled).

>
> Once you venture into the shared cache realm, I just don't see a need
> for pacman to hand-hold you.

It's useful for users that don't use a shared cache, but want to keep
non-installed but up-to-date packages in cache (e.g. me :-P) - there
are some valid reasons for doing this.

>
> So we have Xav and Roman in support of this, and me against it. I
> don't want to say "majority rules" here, but I would like to get a few
> more voices on this one. Aaron?



--
Roman Kyrylych (*оман Кирилич)
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 02-18-2008, 09:05 AM
Xavier
 
Default Add new SharedPkgCache option.

On Mon, Feb 18, 2008 at 10:06:35AM +0200, Roman Kyrylych wrote:
>
> Not pointless at all, Xavier's solution will work on majority of
> configurations with a shared cache (that have the same set of repos
> enabled).
>
> It's useful for users that don't use a shared cache, but want to keep
> non-installed but up-to-date packages in cache (e.g. me :-P) - there
> are some valid reasons for doing this.
>

Ah. Then the SharedPkgCache name is not so great :/
I also thought of "CleanOutdated".

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 

Thread Tools




All times are GMT. The time now is 11:23 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org