2 * dpkg - main program for package management
3 * update.c - options which update the ‘available’ database
5 * Copyright © 1995 Ian Jackson <ijackson@chiark.greenend.org.uk>
7 * This is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
30 #include <dpkg/i18n.h>
31 #include <dpkg/dpkg.h>
32 #include <dpkg/dpkg-db.h>
33 #include <dpkg/options.h>
38 updateavailable(const char *const *argv
)
40 const char *sourcefile
= argv
[0];
46 switch (cipaction
->arg_int
) {
48 if (sourcefile
) badusage(_("--%s takes no arguments"),cipaction
->olong
);
50 case act_avreplace
: case act_avmerge
:
51 if (sourcefile
== NULL
)
54 badusage(_("--%s takes at most one Packages-file argument"),
58 internerr("unknown action '%d'", cipaction
->arg_int
);
62 const char *dbdir
= dpkg_db_get_dir();
64 if (access(dbdir
, W_OK
)) {
66 ohshite(_("unable to access dpkg database directory '%s' for bulk available update"),
69 ohshit(_("required write access to dpkg database directory '%s' for bulk available update"),
75 switch (cipaction
->arg_int
) {
77 printf(_("Replacing available packages info, using %s.\n"),sourcefile
);
80 printf(_("Updating available packages info, using %s.\n"),sourcefile
);
85 internerr("unknown action '%d'", cipaction
->arg_int
);
88 availfile
= dpkg_db_get_path(AVAILFILE
);
90 if (cipaction
->arg_int
== act_avmerge
)
91 parsedb(availfile
, pdb_parse_available
, NULL
);
93 if (cipaction
->arg_int
!= act_avclear
)
94 count
+= parsedb(sourcefile
,
95 pdb_parse_available
| pdb_ignoreolder
| pdb_dash_is_stdin
,
99 writedb(availfile
, wdb_dump_available
);
105 if (cipaction
->arg_int
!= act_avclear
)
106 printf(P_("Information about %d package was updated.\n",
107 "Information about %d packages was updated.\n", count
), count
);
115 forgetold(const char *const *argv
)
118 badusage(_("--%s takes no arguments"), cipaction
->olong
);
120 warning(_("obsolete '--%s' option; unavailable packages are automatically cleaned up"),