1 | /* rpackagemanager.h |
---|
2 | * |
---|
3 | * Copyright (c) 2000, 2001 Conectiva S/A |
---|
4 | * 2002 Michael Vogt |
---|
5 | * |
---|
6 | * Author: Alfredo K. Kojima <kojima@conectiva.com.br> |
---|
7 | * Michael Vogt <mvo@debian.org> |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License as |
---|
11 | * published by the Free Software Foundation; either version 2 of the |
---|
12 | * License, or (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
---|
22 | * USA |
---|
23 | */ |
---|
24 | |
---|
25 | // We need a different package manager, since we need to do the |
---|
26 | // DoInstall() process in two steps when forking. Without that, |
---|
27 | // the forked package manager would be updated with the new |
---|
28 | // information, and the original Synaptic process wouldn't be |
---|
29 | // aware about it. |
---|
30 | // |
---|
31 | // Very unfortunately, we *do* need to access stuff which is |
---|
32 | // declared as protected in the packagemanager.h header. To do |
---|
33 | // that, we need this awful hack. Make sure to include all headers |
---|
34 | // included by packagemanager.h before the hack, so that we reduce |
---|
35 | // the impact of it. In the future, we must ask the APT maintainers |
---|
36 | // to export the functionality we need, so that we may avoid this |
---|
37 | // ugly hack. |
---|
38 | |
---|
39 | #include <string> |
---|
40 | #include <apt-pkg/pkgcache.h> |
---|
41 | #include <apt-pkg/progress.h> |
---|
42 | #include <apt-pkg/configuration.h> |
---|
43 | |
---|
44 | #define protected public |
---|
45 | #include <apt-pkg/packagemanager.h> |
---|
46 | #undef protected |
---|
47 | |
---|
48 | #ifndef RPACKAGEMANAGER_H |
---|
49 | #define RPACKAGEMANAGER_H |
---|
50 | |
---|
51 | class RPackageManager { |
---|
52 | |
---|
53 | protected: |
---|
54 | |
---|
55 | pkgPackageManager::OrderResult Res; |
---|
56 | |
---|
57 | public: |
---|
58 | |
---|
59 | pkgPackageManager *pm; |
---|
60 | |
---|
61 | pkgPackageManager::OrderResult DoInstallPreFork() { |
---|
62 | pm->Progress = new InstPercentProgress(*_config); |
---|
63 | Res = pm->OrderInstall(); |
---|
64 | return Res; |
---|
65 | }; |
---|
66 | #ifdef WITH_DPKG_STATUSFD |
---|
67 | pkgPackageManager::OrderResult DoInstallPostFork(int statusFd=-1) { |
---|
68 | return (pm->Go(statusFd) == false) ? pkgPackageManager::Failed : Res; |
---|
69 | }; |
---|
70 | #else |
---|
71 | pkgPackageManager::OrderResult DoInstallPostFork() { |
---|
72 | return (pm->Go() == false) ? pkgPackageManager::Failed : Res; |
---|
73 | }; |
---|
74 | #endif |
---|
75 | |
---|
76 | RPackageManager(pkgPackageManager *pm) : pm(pm) {}; |
---|
77 | ~RPackageManager() { delete pm->Progress; }; |
---|
78 | |
---|
79 | }; |
---|
80 | |
---|
81 | #endif |
---|
82 | |
---|
83 | // vim:ts=3:sw=3:et |
---|