]>
git.saurik.com Git - apt.git/blob - methods/aptmethod.h
1 #ifndef APT_APTMETHOD_H
2 #define APT_APTMETHOD_H
4 #include <apt-pkg/acquire-method.h>
5 #include <apt-pkg/configuration.h>
6 #include <apt-pkg/error.h>
12 #include <sys/types.h>
18 class aptMethod
: public pkgAcqMethod
20 char const * const Binary
;
23 virtual bool Configuration(std::string Message
) APT_OVERRIDE
25 if (pkgAcqMethod::Configuration(Message
) == false)
28 std::string
const conf
= std::string("Binary::") + Binary
;
29 _config
->MoveSubTree(conf
.c_str(), NULL
);
36 bool CalculateHashes(FetchItem
const * const Itm
, FetchResult
&Res
) const
38 Hashes
Hash(Itm
->ExpectedHashes
);
40 if (Fd
.Open(Res
.Filename
, FileFd::ReadOnly
) == false || Hash
.AddFD(Fd
) == false)
46 void Warning(const char *Format
,...)
49 va_start(args
,Format
);
50 PrintStatus("104 Warning", Format
, args
);
54 bool TransferModificationTimes(char const * const From
, char const * const To
, time_t &LastModified
)
56 if (strcmp(To
, "/dev/null") == 0)
60 if (lstat(To
, &Buf2
) != 0 || S_ISLNK(Buf2
.st_mode
))
64 if (stat(From
, &Buf
) != 0)
65 return _error
->Errno("stat",_("Failed to stat"));
67 // we don't use utimensat here for compatibility reasons: #738567
68 struct timeval times
[2];
69 times
[0].tv_sec
= Buf
.st_atime
;
70 LastModified
= times
[1].tv_sec
= Buf
.st_mtime
;
71 times
[0].tv_usec
= times
[1].tv_usec
= 0;
72 if (utimes(To
, times
) != 0)
73 return _error
->Errno("utimes",_("Failed to set modification time"));
77 aptMethod(char const * const Binary
, char const * const Ver
, unsigned long const Flags
) :
78 pkgAcqMethod(Ver
, Flags
), Binary(Binary
)
81 std::locale::global(std::locale(""));
83 setlocale(LC_ALL
, "");