-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cc
123 lines (112 loc) · 3.56 KB
/
main.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* ipl/installer/main.cc -*- C++ -*- Copyright (c) 2006 Joshua Oreman
* Distributed under the GPL. See COPYING for details.
*/
#include <QApplication>
#include <QPlastiqueStyle>
#include <QHttp>
#include <QMetaType>
#include <QDir>
#include "installer.h"
#include "libtar/libtar.h"
#include "rawpod/rawpod.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef WIN32
/* getopt.c is included in make_fw2.c */
extern "C" char *optarg;
extern "C" int optind, opterr, optopt, optreset;
extern "C" int getopt (int nargc, char *const *nargv, const char *ostr);
#else
#include <getopt.h>
#endif
void usage (int exitcode)
{
fprintf (stderr,
"Usage: installer [-h|-a|-r BACKUP] [-A|-L|-2] [-b BACKUP] [-d DIR] [-l PKGLIST]\n"
#ifdef WIN32
" [-i IPOD] [-w COWFILE] [-C | [-c] [-I COMINT] [-s CSIZE]]\n"
#else
" [-i IPOD] [-w COWFILE] [-C | -c [-I COMINT] [-s CSIZE]]\n"
#endif
"\n"
" Mode:\n"
" -h This help screen.\n"
" -a Auto-pilot install; don't ask any questions. Defaults are the same as\n"
" those for a normal install, except that no backup will be made unless -b\n"
" is specified.\n"
" -A Install loader1 with the Apple firmware as default. [default]\n"
" -L Install loader1 with Linux as default.\n"
" -2 Install loader2.\n"
" -b FILE Back up the iPod firmware to FILE during the install.\n"
" -r FILE Open, restore a backup from FILE, and quit.\n\n"
" Options:\n"
" -d DIR Store temporary files in DIR instead of the current directory.\n"
" -l FILE Use FILE as the package list file.\n"
" -p PROXY Use PROXY as proxy for fetching package list file. Example: user:pass@ip:8080\n"
"\n"
RAWPOD_OPTIONS_USAGE);
exit (exitcode);
}
int main (int argc, char *argv[])
{
InstallerHome = QDir::currentPath();
PackageListFile = "http://ipodlinux.org/w/index.php?title=iPodLinux:Installation_sources&action=raw";
ProxyString = "";
#ifdef __linux__
BlockCache::disable();
#endif
QApplication app (argc, argv);
signed char ch;
while ((ch = getopt (argc, argv, "haAL2b:r:" "d:l:p:" RAWPOD_OPTIONS_STR)) != EOF) switch (ch) {
case 'a':
InstallAutomatically = true;
Mode = StandardInstall;
iPodLoader = Loader2;
iPodDoBackup = false;
break;
case 'A':
iPodLoader = Loader1Apple;
break;
case 'L':
iPodLoader = Loader1Linux;
break;
case '2':
iPodLoader = Loader2;
break;
case 'b':
iPodDoBackup = true;
iPodBackupLocation = QString (optarg);
break;
case 'r':
InstallAutomatically = true;
Mode = Uninstall;
iPodDoBackup = true;
iPodBackupLocation = QString (optarg);
break;
case 'd':
InstallerHome = QString (optarg);
break;
case 'h':
usage (0);
break;
case 'l':
PackageListFile = QString (optarg);
break;
case 'p':
ProxyString = QString (optarg);
break;
default:
if (rawpod_parse_option (ch, optarg))
break;
case '?':
usage (1);
break;
}
#ifdef __linux__
app.setStyle (new QPlastiqueStyle);
#endif
qRegisterMetaType <QHttpResponseHeader> ("QHttpResponseHeader");
Installer *inst = new Installer;
inst->show();
return app.exec();
}