[BACK]Return to menus.mi CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / distrib / utils / sysinst

Annotation of src/distrib/utils/sysinst/menus.mi, Revision 1.18

1.18    ! dsl         1: /*     $NetBSD: menus.mi,v 1.17 2004/06/05 21:18:59 dsl Exp $  */
1.1       dsl         2:
                      3: /*-
                      4:  * Copyright (c) 2003 The NetBSD Foundation, Inc.
                      5:  * All rights reserved.
                      6:  *
                      7:  * This code is derived from software contributed to The NetBSD Foundation
                      8:  * by David Laight.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  * 3. All advertising materials mentioning features or use of this software
                     19:  *    must display the following acknowledgement:
                     20:  *        This product includes software developed by the NetBSD
                     21:  *        Foundation, Inc. and its contributors.
                     22:  * 4. Neither the name of The NetBSD Foundation nor the names of its
                     23:  *    contributors may be used to endorse or promote products derived
                     24:  *    from this software without specific prior written permission.
                     25:  *
                     26:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     27:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     28:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     29:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     30:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     31:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     32:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     33:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     34:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     35:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     36:  * POSSIBILITY OF SUCH DAMAGE.
                     37:  */
                     38:
                     39: /*
                     40:  * Menu system definitions -- machine and language independent
                     41:  *
1.6       dsl        42:  * Some menus may be called directly in the code rather than via the
                     43:  * menu system.
                     44:  *
1.1       dsl        45:  *  This file must be first in the sed command line.
                     46:  *
                     47:  */
                     48:
                     49: {
                     50: #include <stdio.h>
                     51: #include <time.h>
                     52: #include <curses.h>
                     53: #include "defs.h"
                     54: #include "md.h"
                     55: #include "msg_defs.h"
                     56: #include "menu_defs.h"
                     57:
                     58: }
                     59:
                     60: default y=12, no exit, scrollable;
                     61:
                     62: allow dynamic menus;
1.4       dsl        63: allow dynamic messages;
1.5       dsl        64:
                     65:
1.15      dsl        66: menu selfskind, title MSG_Select_the_type, exitstring MSG_unchanged, y=6, x=30;
1.10      dsl        67:        display action {
1.15      dsl        68:                partinfo *p = arg;
                     69:                switch (p->pi_fstype) {
1.10      dsl        70:                case FS_UNUSED: menu->cursel = 0; break;
1.15      dsl        71:                case FS_BSDFFS:
                     72:                    menu->cursel = p->pi_flags & PIF_FFSv2 ? 2 : 1;
                     73:                    break;
                     74:                case FS_SWAP:   menu->cursel = 3; break;
                     75:                case FS_MSDOS:  menu->cursel = 4; break;
                     76:                case FS_BSDLFS: menu->cursel = 5; break;
                     77:                default :       menu->cursel = 6; break;
1.10      dsl        78:                };
                     79:        };
                     80:        option "unused", exit, action
1.11      dsl        81:            { memset(arg, 0, sizeof (partinfo)); };
1.15      dsl        82:        option "FFSv1", exit, action
                     83:            { set_ptype(arg, FS_BSDFFS, 0, 8192); };
                     84:        option "FFSv2", exit, action
                     85:            { set_ptype(arg, FS_BSDFFS, PIF_FFSv2, 8192); };
1.5       dsl        86:        option "swap", exit, action
1.15      dsl        87:            { set_ptype(arg, FS_SWAP, 0, 0); };
1.5       dsl        88:        option "msdos", exit, action
1.15      dsl        89:            { set_ptype(arg, FS_MSDOS, 0, 0); };
                     90:        option "LFS", exit, action
                     91:            { set_ptype(arg, FS_BSDLFS, 0, 8192); };
1.10      dsl        92:        option MSG_other_types, action
                     93:            { extern int all_fstype_menu;
                     94:              m->opts[m->cursel].opt_menu = all_fstype_menu; };
1.5       dsl        95:
1.11      dsl        96: menu selbsize, title MSG_Select_file_system_block_size, y=10, x=40;
                     97:        display action {
                     98:                partinfo *pi = arg;
                     99:                int b;
                    100:                b = ffs(pi->pi_fsize * pi->pi_frag / 4096) - 1;
                    101:                if (b < 0 || b >= menu->numopts)
                    102:                        b = 1;
                    103:                menu->cursel = b;
                    104:        };
                    105:        option  "4096", exit, action { set_bsize(arg, 4096); };
1.5       dsl       106:        option  "8192", exit, action { set_bsize(arg, 8192); };
                    107:        option "16384", exit, action { set_bsize(arg, 16384); };
                    108:        option "32768", exit, action { set_bsize(arg, 32768); };
                    109:
1.11      dsl       110: menu selfsize, title MSG_Select_file_system_fragment_size, y=11, x=40;
                    111:        display action {
                    112:                partinfo *pi = arg;
                    113:                int b;
                    114:                b = ffs(pi->pi_fsize / 512) - 1;
                    115:                if (b < 0 || b >= menu->numopts)
                    116:                        b = 1;
                    117:                menu->cursel = b;
                    118:        };
                    119:        option   "512", exit, action { set_fsize(arg, 512); };
                    120:        option  "1024", exit, action { set_fsize(arg, 1024); };
                    121:        option  "2048", exit, action { set_fsize(arg, 2048); };
                    122:        option  "4096", exit, action { set_fsize(arg, 4096); };
                    123:        option  "8192", exit, action { set_fsize(arg, 8192); };
                    124:        option "16384", exit, action { set_fsize(arg, 16384); };
                    125:        option "32768", exit, action { set_fsize(arg, 32768); };
                    126:
1.12      dsl       127: menu mountoptions, title MSG_toggle, y=5, x=30, exitstring MSG_unchanged;
1.11      dsl       128:        option "async", exit, action
                    129:                { ((partinfo *)arg)->pi_flags ^= PIF_ASYNC; };
                    130:        option "noatime", exit, action
                    131:                { ((partinfo *)arg)->pi_flags ^= PIF_NOATIME; };
1.12      dsl       132:        option "nodev", exit, action
                    133:                { ((partinfo *)arg)->pi_flags ^= PIF_NODEV; };
1.11      dsl       134:        option "nodevmtime", exit, action
                    135:                { ((partinfo *)arg)->pi_flags ^= PIF_NODEVMTIME; };
1.12      dsl       136:        option "noexec", exit, action
                    137:                { ((partinfo *)arg)->pi_flags ^= PIF_NOEXEC; };
                    138:        option "nosuid", exit, action
                    139:                { ((partinfo *)arg)->pi_flags ^= PIF_NOSUID; };
1.11      dsl       140:        option "softdep", exit, action
                    141:                { ((partinfo *)arg)->pi_flags ^= PIF_SOFTDEP; };
1.6       dsl       142:
1.13      dsl       143: menu netbsd, title MSG_NetBSD_VERSION_Install_System, y=-1,
1.6       dsl       144:     exit, exitstring MSG_Exit_Install_System;
                    145:        display action  { toplevel(); };
                    146:        option MSG_Install_NetBSD_to_hard_disk,
                    147:                action { do_install(); };
                    148:        option MSG_Upgrade_NetBSD_on_a_hard_disk,
                    149:                action { do_upgrade(); };
                    150:        option MSG_Re_install_sets_or_install_additional_sets,
                    151:                action { do_reinstall_sets(); };
                    152:        option MSG_Reboot_the_computer, exit,
                    153:                action (endwin) { system("/sbin/reboot -q"); };
                    154:        option MSG_Utility_menu, sub menu utility;
                    155:
                    156: menu utility, title MSG_NetBSD_VERSION_Utilities, exit;
                    157:        option MSG_Run_bin_sh,
                    158:                action (endwin) { system("/bin/sh"); };
                    159:        option MSG_Set_timezone,
1.7       dsl       160:                action { set_timezone(); };
1.6       dsl       161:        option MSG_Configure_network,
                    162:                action {
                    163:                        extern int network_up;
                    164:
                    165:                        network_up = 0;
                    166:                        config_network();
                    167:                };
                    168: /*     option MSG_Partition a disk; XXX add later.  */
                    169:        option MSG_Logging_functions, action { do_logging(); };
                    170:        option MSG_Halt_the_system, exit,
                    171:                action (endwin) { system("/sbin/halt -q"); };
                    172:
1.16      dsl       173: menu yesno, y=-10;
1.15      dsl       174:        display action { menu->title = arg ? arg : MSG_yes_or_no; };
1.6       dsl       175:        option MSG_Yes, exit, action  {yesno = 1;};
                    176:        option MSG_No,  exit, action  {yesno = 0;};
                    177:
1.16      dsl       178: menu noyes, y=-10;
1.15      dsl       179:        display action { menu->title = arg ? arg : MSG_yes_or_no; };
1.6       dsl       180:        option MSG_No,  exit, action  {yesno = 0;};
                    181:        option MSG_Yes, exit, action  {yesno = 1;};
                    182:
1.16      dsl       183: menu ok, no shortcut, y=-10;
1.15      dsl       184:        display action { menu->title = arg; };
                    185:        option MSG_Hit_enter_to_continue, exit;
1.6       dsl       186:
1.18    ! dsl       187: menu layout, sub menu, y=-1, title  MSG_Choose_your_installation;
1.10      dsl       188:        option MSG_Set_Sizes,     exit, action { layoutkind = 1; };
1.7       dsl       189:        option MSG_Use_Existing,  exit, action { layoutkind = 4; };
1.6       dsl       190:
1.18    ! dsl       191: menu sizechoice, sub menu, y=0, title MSG_Choose_your_size_specifier;
1.10      dsl       192:        display action {
                    193:                if (sizemult == current_cylsize)
                    194:                        menu->cursel = 1;
                    195:                else if (sizemult == 1)
                    196:                        menu->cursel = 2;
                    197:                };
1.6       dsl       198:        option MSG_Megabytes, exit, action
                    199:                { sizemult = MEG / sectorsize;
                    200:                  multname = msg_string(MSG_megname);
                    201:                };
                    202:        option MSG_Cylinders, exit, action
                    203:                { sizemult = current_cylsize;
                    204:                  multname = msg_string(MSG_cylname);
                    205:                };
                    206:        option MSG_Sectors, exit, action
                    207:                { sizemult = 1;
                    208:                  multname = msg_string(MSG_secname);
                    209:                };
                    210:
                    211: menu distmedium, title MSG_Select_medium;
1.14      dsl       212:        display action { umount_mnt2(); msg_display(MSG_distmedium); };
                    213:        option MSG_ftp,       exit, action { *(int *)arg = get_via_ftp(); };
                    214:        option MSG_nfs,       exit, action { *(int *)arg = get_via_nfs(); };
                    215:        option MSG_cdrom,     exit, action { *(int *)arg = get_via_cdrom(); };
                    216:        option MSG_floppy,    exit, action { *(int *)arg = get_via_floppy(); };
                    217:        option MSG_local_fs,  exit, action { *(int *)arg = get_via_localfs(); };
                    218:        option MSG_local_dir, exit, action { *(int *)arg = get_via_localdir();};
                    219:        option MSG_none,      exit, action { *(int *)arg = -2; };
1.6       dsl       220:
                    221: menu distset, title MSG_Select_your_distribution;
                    222:        display action { msg_display (MSG_distset); };
                    223:        option MSG_Full_installation, exit;
                    224:        option MSG_Custom_installation, exit, action { customise_sets(); };
                    225:
                    226: menu ftpsource, title MSG_Change;
1.7       dsl       227:        display action {
                    228:                msg_clear();
1.17      dsl       229:                msg_table_add(MSG_ftpsource, ftp_host, ftp_dir, set_dir,
                    230:                    ftp_user, strcmp(ftp_user, "ftp") == 0 || ftp_pass[0] == 0
1.7       dsl       231:                        ? ftp_pass : msg_string(MSG_hidden),
                    232:                    ftp_proxy);
1.6       dsl       233:                };
                    234:        option MSG_Host, action
1.17      dsl       235:                { msg_prompt_win(MSG_Host, -1, 12, 0, 0,
                    236:                                ftp_host, ftp_host, sizeof ftp_host); };
                    237:        option MSG_Base_dir, action
                    238:                { msg_prompt_win(MSG_Base_dir, -1, 12, 0, 0,
                    239:                                ftp_dir, ftp_dir, sizeof ftp_dir); };
                    240:        option MSG_Set_dir, action
                    241:                { msg_prompt_win(MSG_Set_dir, -1, 12, 0, 0,
                    242:                                set_dir, set_dir, sizeof set_dir); };
1.6       dsl       243:        option MSG_User, action
1.17      dsl       244:                { msg_prompt_win(MSG_User, -1, 12, 0, 0,
                    245:                                ftp_user, ftp_user, sizeof ftp_user);
1.7       dsl       246:                        ftp_pass[0] = 0;
1.6       dsl       247:                };
                    248:        option MSG_Password, action
                    249:                { if (strcmp(ftp_user, "ftp") == 0)
1.17      dsl       250:                        msg_prompt_win(MSG_email, -1, 12, 0, 0,
                    251:                                        ftp_pass, ftp_pass, sizeof ftp_pass);
1.6       dsl       252:                  else {
1.17      dsl       253:                        msg_prompt_noecho(MSG_Password, "",
                    254:                                        ftp_pass, sizeof ftp_pass);
1.6       dsl       255:                  }
                    256:                };
                    257:        option MSG_Proxy, action
1.17      dsl       258:                { msg_prompt_win(MSG_Proxy, -1, 12, 0, 0,
                    259:                                ftp_proxy, ftp_proxy, sizeof ftp_proxy);
1.6       dsl       260:                  if (strcmp(ftp_proxy, "") == 0)
                    261:                        unsetenv("ftp_proxy");
                    262:                  else
                    263:                        setenv("ftp_proxy", ftp_proxy, 1);
                    264:                };
                    265:        option MSG_Get_Distribution, exit;
                    266:
                    267: menu nfssource, title MSG_Change;
                    268:        display action
1.17      dsl       269:                { msg_display(MSG_nfssource, nfs_host, nfs_dir, set_dir); };
1.6       dsl       270:        option MSG_Host, action
1.17      dsl       271:                { msg_prompt_win(MSG_Host, -1, 12, 0, 0,
                    272:                                nfs_host, nfs_host, sizeof nfs_host); };
                    273:        option MSG_Base_dir, action
                    274:                { msg_prompt_win(MSG_Base_dir, -1, 12, 0, 0,
                    275:                                nfs_dir, nfs_dir, sizeof nfs_dir); };
                    276:        option MSG_Set_dir, action
                    277:                { msg_prompt_win(MSG_Set_dir, -1, 12, 0, 0,
                    278:                                set_dir, set_dir, sizeof set_dir); };
1.6       dsl       279:        option MSG_Continue, exit;
                    280:
                    281: menu nfsbadmount, title MSG_What_do_you_want_to_do;
                    282:        option MSG_Try_again, exit, sub menu nfssource, action
                    283:                { yesno = 1; ignorerror = 0; };
                    284:        option MSG_Give_up, exit, action
                    285:                { yesno = 0; ignorerror = 0; };
                    286:        option MSG_Ignore_continue_anyway, exit, action
                    287:                { yesno = 1; ignorerror = 1; };
                    288:
                    289:
                    290: menu fdremount, title MSG_What_do_you_want_to_do;
                    291:        option MSG_Try_again, exit, action { yesno = 1; };
                    292:        option MSG_Set_finished, exit, action { yesno = 2; };
                    293:        option MSG_Abort_install, exit, action { yesno = 0; };
                    294:
                    295: menu fdok, title MSG_Hit_enter_to_continue;
                    296:        option MSG_OK, exit, action { yesno = 1; };
                    297:        option MSG_Set_finished, exit, action { yesno = 2; };
                    298:        option MSG_Abort_install, exit, action { yesno = 0; };
                    299:
                    300: menu crypttype, title MSG_Password_cipher, y=16;
                    301:        option MSG_DES, exit, action { yesno = 1; };
                    302:        option MSG_MD5, exit, action { yesno = 2; };
                    303:        option MSG_Blowfish_2_7_round, exit, action { yesno = 3; };
                    304:        option MSG_do_not_change, exit, action { yesno = 0; };
                    305:
                    306: menu cdromsource, title MSG_Change;
                    307:        display action
1.17      dsl       308:                { msg_display(MSG_cdromsource, cdrom_dev, set_dir); };
1.6       dsl       309:        option MSG_Device, action
1.17      dsl       310:                { msg_prompt_win(MSG_dev, -1, 12, 0, 0,
                    311:                                cdrom_dev, cdrom_dev, sizeof cdrom_dev); };
                    312:        option MSG_Set_dir, action
                    313:                { msg_prompt_win(MSG_Set_dir, -1, 12, 0, 0,
                    314:                                set_dir, set_dir, sizeof set_dir); };
1.6       dsl       315:        option MSG_Continue, exit;
                    316:
                    317: menu cdrombadmount, title MSG_What_do_you_want_to_do;
1.17      dsl       318:        display action
                    319:                { msg_display(MSG_cdrombadmount, cdrom_dev); };
                    320:        option MSG_Try_again, exit, action
                    321:                { yesno = 1; };
1.6       dsl       322:        option MSG_Give_up, exit, action
1.17      dsl       323:                { yesno = 0; };
1.6       dsl       324:
                    325:
                    326: menu localfssource, title MSG_Change;
                    327:        display action
1.17      dsl       328:                { msg_display(MSG_localfssource, localfs_dev, localfs_fs,
                    329:                                localfs_dir, set_dir); };
1.6       dsl       330:        option MSG_Device, action
1.17      dsl       331:                { msg_prompt_win(MSG_dev, -1, 12, 0, 0,
                    332:                                localfs_dev, localfs_dev, sizeof localfs_dev);};
1.6       dsl       333:        option MSG_File_system, action
1.17      dsl       334:                { msg_prompt_win(MSG_filesys, -1, 12, 0, 0,
                    335:                                localfs_fs, localfs_fs, sizeof localfs_fs); };
                    336:        option MSG_Base_dir, action
                    337:                { msg_prompt_win(MSG_Base_dir, -1, 12, 0, 0,
                    338:                                localfs_dir, localfs_dir, sizeof localfs_dir);};
                    339:        option MSG_Set_dir, action
                    340:                { msg_prompt_win(MSG_Set_dir, -1, 12, 0, 0,
                    341:                                set_dir, set_dir, sizeof set_dir); };
1.6       dsl       342:        option MSG_Continue, exit;
                    343:
                    344: menu localfsbadmount, title MSG_What_do_you_want_to_do;
                    345:        option MSG_Try_again, exit, sub menu localfssource, action
                    346:                { yesno = 1; ignorerror = 0; };
                    347:        option MSG_Give_up, exit, action
                    348:                { yesno = 0; ignorerror = 0; };
                    349:        option MSG_Ignore_continue_anyway, exit, action
                    350:                { yesno = 1; ignorerror = 1; };
                    351:
                    352: menu localdirsource, title MSG_Change;
                    353:        display action
1.17      dsl       354:                { msg_display(MSG_localdir, localfs_dir, set_dir); };
                    355:        option MSG_Base_dir, action
                    356:            { msg_prompt_win(MSG_Base_dir, -1, 12, 0, 0, localfs_dir, localfs_dir, 60); };
                    357:        option MSG_Set_dir, action
                    358:            { msg_prompt_win(MSG_Set_dir, -1, 12, 0, 0, set_dir, set_dir, 60); };
1.6       dsl       359:        option MSG_Continue, exit;
                    360:
                    361: menu namesrv6, title MSG_Select_IPv6_DNS_server;
                    362:        option "ns9.iij.ad.jp", exit, action
                    363:                {
                    364: #ifdef INET6
                    365:                  strlcpy(net_namesvr6, "2001:240::1", sizeof(net_namesvr6));
                    366:                  yesno = 1;
                    367: #else
                    368:                  yesno = 0;
                    369: #endif
                    370:                };
                    371:        option "ns-wide.wide.ad.jp", exit, action
                    372:                {
                    373: #ifdef INET6
                    374:                  strlcpy(net_namesvr6, "2001:200:0:1::3", sizeof(net_namesvr6));
                    375:                  yesno = 1;
                    376: #else
                    377:                  yesno = 0;
                    378: #endif
                    379:                };
                    380:        option "light.imasy.or.jp", exit, action
                    381:                {
                    382: #ifdef INET6
                    383:                  strlcpy(net_namesvr6, "3ffe:505:0:1:2a0:c9ff:fe61:6521",
                    384:                      sizeof(net_namesvr6));
                    385:                  yesno = 1;
                    386: #else
                    387:                  yesno = 0;
                    388: #endif
                    389:                };
                    390:        option MSG_other, exit, action
                    391:                { yesno = 0; };
                    392:
                    393: menu rootsh, title MSG_Root_shell;
                    394:        option "/bin/csh", exit, action {shellpath = "/bin/csh";};
                    395:        option "/bin/ksh", exit, action {shellpath = "/bin/ksh";};
                    396:        option "/bin/sh",  exit, action {shellpath = "/bin/sh";};
                    397:
                    398: menu extract, title MSG_Select_set_extraction_verbosity;
1.17      dsl       399:        display action { menu->cursel = *(int *)arg; };
                    400:        option MSG_Progress_bar, exit, action { *(int *)arg = 0; };
                    401:        option MSG_Silent,       exit, action { *(int *)arg = 1; };
                    402:        option MSG_Verbose,      exit, action { *(int *)arg = 2; };

CVSweb <webmaster@jp.NetBSD.org>