[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.42

1.42    ! martin      1: /*     $NetBSD: menus.mi,v 1.41 2011/04/08 15:53:44 martin 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:  *
                     19:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     20:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     21:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     22:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     23:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     24:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     25:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     26:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     27:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     28:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     29:  * POSSIBILITY OF SUCH DAMAGE.
                     30:  */
                     31:
                     32: /*
                     33:  * Menu system definitions -- machine and language independent
                     34:  *
1.6       dsl        35:  * Some menus may be called directly in the code rather than via the
                     36:  * menu system.
                     37:  *
1.1       dsl        38:  *  This file must be first in the sed command line.
                     39:  *
                     40:  */
                     41:
                     42: {
                     43: #include <stdio.h>
                     44: #include <time.h>
                     45: #include <curses.h>
                     46: #include "defs.h"
                     47: #include "md.h"
                     48: #include "msg_defs.h"
                     49: #include "menu_defs.h"
                     50:
1.25      dsl        51: static void
                     52: src_legend(menudesc *menu, const char *legend, const char *text)
                     53: {
1.26      dsl        54:         wprintw(menu->mw, "%-25s %.50s", MSG_XLAT(legend), MSG_XLAT(text));
                     55: }
                     56:
                     57: static void
                     58: src_prompt(const char *prompt, char *buf, size_t size)
                     59: {
                     60:        msg_prompt_win(prompt, -1, 12, 0, 0, buf, buf, size);
1.25      dsl        61: }
1.1       dsl        62: }
                     63:
                     64: default y=12, no exit, scrollable;
                     65:
                     66: allow dynamic menus;
1.4       dsl        67: allow dynamic messages;
1.41      martin     68: error action {
                     69:        fprintf (stderr, "Could not initialize menu system, please check "
                     70:            "your terminal type.\n");
                     71:        exit(4);
                     72: };
1.5       dsl        73:
1.15      dsl        74: menu selfskind, title MSG_Select_the_type, exitstring MSG_unchanged, y=6, x=30;
1.10      dsl        75:        display action {
1.15      dsl        76:                partinfo *p = arg;
                     77:                switch (p->pi_fstype) {
1.10      dsl        78:                case FS_UNUSED: menu->cursel = 0; break;
1.15      dsl        79:                case FS_BSDFFS:
                     80:                    menu->cursel = p->pi_flags & PIF_FFSv2 ? 2 : 1;
                     81:                    break;
                     82:                case FS_SWAP:   menu->cursel = 3; break;
                     83:                case FS_MSDOS:  menu->cursel = 4; break;
                     84:                case FS_BSDLFS: menu->cursel = 5; break;
                     85:                default :       menu->cursel = 6; break;
1.10      dsl        86:                };
                     87:        };
                     88:        option "unused", exit, action
1.11      dsl        89:            { memset(arg, 0, sizeof (partinfo)); };
1.20      dsl        90:        option "FFSv1", exit, action { set_ptype(arg, FS_BSDFFS, 0); };
                     91:        option "FFSv2", exit, action { set_ptype(arg, FS_BSDFFS, PIF_FFSv2); };
                     92:        option "swap",  exit, action { set_ptype(arg, FS_SWAP, 0); };
                     93:        option "msdos", exit, action { set_ptype(arg, FS_MSDOS, 0); };
                     94:        option "LFS",   exit, action { set_ptype(arg, FS_BSDLFS, 0); };
1.10      dsl        95:        option MSG_other_types, action
                     96:            { extern int all_fstype_menu;
                     97:              m->opts[m->cursel].opt_menu = all_fstype_menu; };
1.5       dsl        98:
1.11      dsl        99: menu selbsize, title MSG_Select_file_system_block_size, y=10, x=40;
                    100:        display action {
                    101:                partinfo *pi = arg;
                    102:                int b;
                    103:                b = ffs(pi->pi_fsize * pi->pi_frag / 4096) - 1;
                    104:                if (b < 0 || b >= menu->numopts)
                    105:                        b = 1;
                    106:                menu->cursel = b;
                    107:        };
                    108:        option  "4096", exit, action { set_bsize(arg, 4096); };
1.5       dsl       109:        option  "8192", exit, action { set_bsize(arg, 8192); };
                    110:        option "16384", exit, action { set_bsize(arg, 16384); };
                    111:        option "32768", exit, action { set_bsize(arg, 32768); };
                    112:
1.11      dsl       113: menu selfsize, title MSG_Select_file_system_fragment_size, y=11, x=40;
                    114:        display action {
                    115:                partinfo *pi = arg;
                    116:                int b;
                    117:                b = ffs(pi->pi_fsize / 512) - 1;
                    118:                if (b < 0 || b >= menu->numopts)
                    119:                        b = 1;
                    120:                menu->cursel = b;
                    121:        };
                    122:        option   "512", exit, action { set_fsize(arg, 512); };
                    123:        option  "1024", exit, action { set_fsize(arg, 1024); };
                    124:        option  "2048", exit, action { set_fsize(arg, 2048); };
                    125:        option  "4096", exit, action { set_fsize(arg, 4096); };
                    126:        option  "8192", exit, action { set_fsize(arg, 8192); };
                    127:        option "16384", exit, action { set_fsize(arg, 16384); };
                    128:        option "32768", exit, action { set_fsize(arg, 32768); };
                    129:
1.12      dsl       130: menu mountoptions, title MSG_toggle, y=5, x=30, exitstring MSG_unchanged;
1.22      xtraeme   131:        display action {
                    132:                static int actual_numopt;
                    133:                if (!actual_numopt)
                    134:                        actual_numopt = menu->numopts;
                    135:                menu->numopts = actual_numopt -
                    136:                        (((partinfo *)arg)->pi_fstype !=  FS_BSDFFS);
                    137:        };
1.33      simonb    138:        option "log", exit, action
                    139:                { ((partinfo *)arg)->pi_flags ^= PIF_LOG; };
1.11      dsl       140:        option "async", exit, action
                    141:                { ((partinfo *)arg)->pi_flags ^= PIF_ASYNC; };
                    142:        option "noatime", exit, action
                    143:                { ((partinfo *)arg)->pi_flags ^= PIF_NOATIME; };
1.12      dsl       144:        option "nodev", exit, action
                    145:                { ((partinfo *)arg)->pi_flags ^= PIF_NODEV; };
1.11      dsl       146:        option "nodevmtime", exit, action
                    147:                { ((partinfo *)arg)->pi_flags ^= PIF_NODEVMTIME; };
1.12      dsl       148:        option "noexec", exit, action
                    149:                { ((partinfo *)arg)->pi_flags ^= PIF_NOEXEC; };
                    150:        option "nosuid", exit, action
                    151:                { ((partinfo *)arg)->pi_flags ^= PIF_NOSUID; };
1.6       dsl       152:
1.13      dsl       153: menu netbsd, title MSG_NetBSD_VERSION_Install_System, y=-1,
1.6       dsl       154:     exit, exitstring MSG_Exit_Install_System;
                    155:        display action  { toplevel(); };
                    156:        option MSG_Install_NetBSD_to_hard_disk,
                    157:                action { do_install(); };
                    158:        option MSG_Upgrade_NetBSD_on_a_hard_disk,
                    159:                action { do_upgrade(); };
                    160:        option MSG_Re_install_sets_or_install_additional_sets,
                    161:                action { do_reinstall_sets(); };
                    162:        option MSG_Reboot_the_computer, exit,
                    163:                action (endwin) { system("/sbin/reboot -q"); };
                    164:        option MSG_Utility_menu, sub menu utility;
                    165:
1.42    ! martin    166: menu utility, title MSG_NetBSD_VERSION_Utilities, exit,
        !           167:                exitstring MSG_exit_utility_menu;
1.30      dsl       168:        display action  { toplevel(); };
1.6       dsl       169:        option MSG_Run_bin_sh,
                    170:                action (endwin) { system("/bin/sh"); };
                    171:        option MSG_Set_timezone,
1.7       dsl       172:                action { set_timezone(); };
1.6       dsl       173:        option MSG_Configure_network,
                    174:                action {
                    175:                        extern int network_up;
                    176:
                    177:                        network_up = 0;
                    178:                        config_network();
                    179:                };
                    180: /*     option MSG_Partition a disk; XXX add later.  */
                    181:        option MSG_Logging_functions, action { do_logging(); };
                    182:        option MSG_Halt_the_system, exit,
                    183:                action (endwin) { system("/sbin/halt -q"); };
                    184:
1.16      dsl       185: menu yesno, y=-10;
1.15      dsl       186:        display action { menu->title = arg ? arg : MSG_yes_or_no; };
1.6       dsl       187:        option MSG_Yes, exit, action  {yesno = 1;};
                    188:        option MSG_No,  exit, action  {yesno = 0;};
                    189:
1.16      dsl       190: menu noyes, y=-10;
1.15      dsl       191:        display action { menu->title = arg ? arg : MSG_yes_or_no; };
1.6       dsl       192:        option MSG_No,  exit, action  {yesno = 0;};
                    193:        option MSG_Yes, exit, action  {yesno = 1;};
                    194:
1.16      dsl       195: menu ok, no shortcut, y=-10;
1.15      dsl       196:        display action { menu->title = arg; };
                    197:        option MSG_Hit_enter_to_continue, exit;
1.6       dsl       198:
1.18      dsl       199: menu layout, sub menu, y=-1, title  MSG_Choose_your_installation;
1.10      dsl       200:        option MSG_Set_Sizes,     exit, action { layoutkind = 1; };
1.7       dsl       201:        option MSG_Use_Existing,  exit, action { layoutkind = 4; };
1.6       dsl       202:
1.18      dsl       203: menu sizechoice, sub menu, y=0, title MSG_Choose_your_size_specifier;
1.10      dsl       204:        display action {
                    205:                if (sizemult == current_cylsize)
                    206:                        menu->cursel = 1;
                    207:                else if (sizemult == 1)
                    208:                        menu->cursel = 2;
                    209:                };
1.6       dsl       210:        option MSG_Megabytes, exit, action
                    211:                { sizemult = MEG / sectorsize;
                    212:                  multname = msg_string(MSG_megname);
                    213:                };
                    214:        option MSG_Cylinders, exit, action
                    215:                { sizemult = current_cylsize;
                    216:                  multname = msg_string(MSG_cylname);
                    217:                };
                    218:        option MSG_Sectors, exit, action
                    219:                { sizemult = 1;
                    220:                  multname = msg_string(MSG_secname);
                    221:                };
                    222:
1.24      dsl       223: menu distmedium, title MSG_Select_medium, y=-5;
1.19      dsl       224:        option MSG_cdrom,     exit, action { *(int *)arg = get_via_cdrom(); };
                    225:        option MSG_ftp,       exit, action { *(int *)arg = get_via_ftp("ftp"); };
                    226:        option MSG_http,      exit, action { *(int *)arg = get_via_ftp("http"); };
1.14      dsl       227:        option MSG_nfs,       exit, action { *(int *)arg = get_via_nfs(); };
                    228:        option MSG_floppy,    exit, action { *(int *)arg = get_via_floppy(); };
                    229:        option MSG_local_fs,  exit, action { *(int *)arg = get_via_localfs(); };
                    230:        option MSG_local_dir, exit, action { *(int *)arg = get_via_localdir();};
1.23      dsl       231:        option MSG_Skip_set,  exit, action { *(int *)arg = SET_SKIP; };
                    232:        option MSG_Skip_group,exit, action { *(int *)arg = SET_SKIP_GROUP; };
                    233:        option MSG_Abandon,   exit, action { *(int *)arg = SET_ABANDON; };
1.6       dsl       234:
                    235: menu distset, title MSG_Select_your_distribution;
1.28      hubertf   236:        display action { msg_display (MSG_distset); };
                    237:        option MSG_Full_installation, exit, action { init_set_status(0);  };
1.40      joerg     238:        option MSG_Full_installation_nox, exit, action { init_set_status(SFLAG_NOX); };
                    239:        option MSG_Minimal_installation, exit, action { init_set_status(SFLAG_MINIMAL); };
                    240:        option MSG_Custom_installation, exit, action { init_set_status(SFLAG_MINIMAL); customise_sets(); };
1.6       dsl       241:
1.25      dsl       242: menu ftpsource, y=-4, x=0, w=70, no box, no clear,
                    243:            exitstring MSG_Get_Distribution;
                    244:        display action { msg_display(MSG_ftpsource, arg); };
1.26      dsl       245:        option {src_legend(menu, MSG_Host, ftp.host);},
                    246:                action { src_prompt(MSG_Host, ftp.host, sizeof ftp.host); };
                    247:        option {src_legend(menu, MSG_Base_dir, ftp.dir);},
                    248:                action { src_prompt(MSG_Base_dir, ftp.dir, sizeof ftp.dir); };
                    249:        option {src_legend(menu, MSG_Set_dir, set_dir);},
                    250:                action { src_prompt(MSG_Set_dir, set_dir, sizeof set_dir); };
                    251:        option {src_legend(menu, MSG_User, ftp.user);},
                    252:                action { src_prompt(MSG_User, ftp.user, sizeof ftp.user);
1.23      dsl       253:                        ftp.pass[0] = 0;
1.6       dsl       254:                };
1.26      dsl       255:        option {src_legend(menu, MSG_Password,
1.25      dsl       256:                    strcmp(ftp.user, "ftp") == 0 || ftp.pass[0] == 0
                    257:                        ? ftp.pass : msg_string(MSG_hidden));},
                    258:                action { if (strcmp(ftp.user, "ftp") == 0)
1.26      dsl       259:                        src_prompt(MSG_email, ftp.pass, sizeof ftp.pass);
1.6       dsl       260:                  else {
1.17      dsl       261:                        msg_prompt_noecho(MSG_Password, "",
1.23      dsl       262:                                        ftp.pass, sizeof ftp.pass);
1.6       dsl       263:                  }
                    264:                };
1.26      dsl       265:        option {src_legend(menu, MSG_Proxy, ftp.proxy);},
                    266:                action { src_prompt(MSG_Proxy, ftp.proxy, sizeof ftp.proxy);
1.23      dsl       267:                  if (strcmp(ftp.proxy, "") == 0) {
1.6       dsl       268:                        unsetenv("ftp_proxy");
1.19      dsl       269:                        unsetenv("http_proxy");
                    270:                  } else {
1.23      dsl       271:                        setenv("ftp_proxy", ftp.proxy, 1);
                    272:                        setenv("http_proxy", ftp.proxy, 1);
1.19      dsl       273:                  }
1.6       dsl       274:                };
1.26      dsl       275:        option {src_legend(menu, MSG_Xfer_dir, xfer_dir);},
                    276:                action { src_prompt(MSG_Xfer_dir, xfer_dir, sizeof xfer_dir); };
                    277:        option {src_legend(menu, MSG_delete_xfer_file,
                    278:                        clean_xfer_dir ? MSG_Yes : MSG_No);},
                    279:                action {process_menu(MENU_yesno, deconst(MSG_delete_xfer_file));
                    280:                        clean_xfer_dir = yesno; };
1.6       dsl       281:
1.25      dsl       282: menu nfssource, y=-4, x=0, w=70, no box, no clear,
                    283:            exitstring MSG_Continue;
                    284:        display action { msg_display(MSG_nfssource); };
                    285:        option {src_legend(menu, MSG_Host, nfs_host);},
1.26      dsl       286:                action { src_prompt(MSG_Host, nfs_host, sizeof nfs_host); };
1.25      dsl       287:        option {src_legend(menu, MSG_Base_dir, nfs_dir);},
1.26      dsl       288:                action { src_prompt(MSG_Base_dir, nfs_dir, sizeof nfs_dir); };
1.25      dsl       289:        option {src_legend(menu, MSG_Set_dir, set_dir);},
1.26      dsl       290:                action { src_prompt(MSG_Set_dir, set_dir, sizeof set_dir); };
1.6       dsl       291:
                    292: menu fdremount, title MSG_What_do_you_want_to_do;
1.23      dsl       293:        option MSG_Try_again, exit, action { *(int *)arg = SET_CONTINUE; };
                    294:        option MSG_Set_finished, exit, action { *(int *)arg = SET_OK; };
1.27      dsl       295:        option MSG_Abort_fetch, exit, action { *(int *)arg = SET_RETRY; };
1.23      dsl       296:
                    297: menu fdok, title MSG_What_do_you_want_to_do;
                    298:        option MSG_OK, exit, action { *(int *)arg = SET_CONTINUE; };
                    299:        option MSG_Set_finished, exit, action { *(int *)arg = SET_OK; };
1.27      dsl       300:        option MSG_Abort_fetch, exit, action { *(int *)arg = SET_RETRY; };
1.6       dsl       301:
1.27      dsl       302: menu fd_type, title MSG_fd_type, y=16;
                    303:        option "msdos", exit, action { fd_type = "msdos"; };
                    304:        option "ffs",   exit, action { fd_type = "ffs"; };
                    305: .if ADOS_FLOPPY
                    306:        option "ados",  exit, action { fd_type = "ados"; };
                    307: .endif
                    308:
1.26      dsl       309: menu floppysource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
                    310:        display action { msg_display(MSG_floppysource); };
                    311:        option {src_legend(menu, MSG_Device, fd_dev);},
                    312:                action { src_prompt(MSG_dev, fd_dev, sizeof fd_dev); };
1.27      dsl       313:        option {src_legend(menu, MSG_fd_type, fd_type);}, sub menu fd_type;
1.26      dsl       314:        option {src_legend(menu, MSG_Xfer_dir, xfer_dir);},
                    315:                action { src_prompt(MSG_Xfer_dir, xfer_dir, sizeof xfer_dir); };
                    316:        option {src_legend(menu, MSG_delete_xfer_file,
                    317:                        clean_xfer_dir ? MSG_Yes : MSG_No);},
                    318:                action {process_menu(MENU_yesno, deconst(MSG_delete_xfer_file));
                    319:                        clean_xfer_dir = yesno; };
                    320:
1.25      dsl       321: menu cdromsource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
1.38      martin    322:        display action { msg_display_add(MSG_cdromsource); };
1.25      dsl       323:        option {src_legend(menu, MSG_Device, cdrom_dev);},
1.26      dsl       324:                action { src_prompt(MSG_dev, cdrom_dev, sizeof cdrom_dev); };
1.25      dsl       325:        option {src_legend(menu, MSG_Set_dir, set_dir);},
1.26      dsl       326:                action { src_prompt(MSG_Set_dir, set_dir, sizeof set_dir); };
1.6       dsl       327:
1.25      dsl       328: menu localfssource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
                    329:        display action { msg_display(MSG_localfssource); };
                    330:        option {src_legend(menu, MSG_Device, localfs_dev);},
1.26      dsl       331:                action { src_prompt(MSG_dev, localfs_dev, sizeof localfs_dev);};
1.25      dsl       332:        option {src_legend(menu, MSG_File_system, localfs_fs);},
1.26      dsl       333:                action { src_prompt(MSG_filesys, localfs_fs, sizeof localfs_fs); };
1.25      dsl       334:        option {src_legend(menu, MSG_Base_dir, localfs_dir);},
1.26      dsl       335:                action { src_prompt(MSG_Base_dir, localfs_dir, sizeof localfs_dir);};
1.25      dsl       336:        option {src_legend(menu, MSG_Set_dir, set_dir);},
1.26      dsl       337:                action { src_prompt(MSG_Set_dir, set_dir, sizeof set_dir); };
1.6       dsl       338:
1.25      dsl       339: menu localdirsource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
                    340:        display action { msg_display(MSG_localdir); };
                    341:        option {src_legend(menu, MSG_Base_dir, localfs_dir);},
1.26      dsl       342:                action { src_prompt(MSG_Base_dir, localfs_dir, 60); };
1.25      dsl       343:        option {src_legend(menu, MSG_Set_dir, set_dir);},
1.26      dsl       344:                action { src_prompt(MSG_Set_dir, set_dir, 60); };
1.6       dsl       345:
                    346: menu namesrv6, title MSG_Select_IPv6_DNS_server;
                    347:        option "ns-wide.wide.ad.jp", exit, action
                    348:                {
                    349: #ifdef INET6
1.35      hubertf   350:                  strlcpy(net_namesvr6, "2001:200:0:1::f", sizeof(net_namesvr6));
1.6       dsl       351:                  yesno = 1;
                    352: #else
                    353:                  yesno = 0;
                    354: #endif
                    355:                };
                    356:        option "light.imasy.or.jp", exit, action
                    357:                {
                    358: #ifdef INET6
1.35      hubertf   359:                  strlcpy(net_namesvr6, "2001:200:300:1:2a0:c9ff:fe61:6521",
1.6       dsl       360:                      sizeof(net_namesvr6));
                    361:                  yesno = 1;
                    362: #else
                    363:                  yesno = 0;
                    364: #endif
                    365:                };
                    366:        option MSG_other, exit, action
                    367:                { yesno = 0; };
                    368:
                    369: menu rootsh, title MSG_Root_shell;
1.21      dsl       370:        option "/bin/sh",  exit, action {*(const char **)arg = "/bin/sh";};
                    371:        option "/bin/ksh", exit, action {*(const char **)arg = "/bin/ksh";};
                    372:        option "/bin/csh", exit, action {*(const char **)arg = "/bin/csh";};

CVSweb <webmaster@jp.NetBSD.org>