As it seems that creating a GTK terminal widget usable with DFB is not
something is going to be done in short time ( and removing "Execute a
shell" form main-menu is not the optimal solution, as proposed in the
plan for tomorrow's d-i meeting ) i propose this patch to
d-i-utils-shell.postinst from debian-installer-utils package
Index: debian/di-utils-shell.postinst
===================================================================
--- debian/di-utils-shell.postinst (revisione 35117)
+++ debian/di-utils-shell.postinst (copia locale)
@@ -4,6 +4,10 @@
db_capb backup
db_input high di-utils-shell/do-shell
-db_go || exit 10
-
-debconf-disconnect /bin/sh || true
+if [ "$DEBIAN_FRONTEND" = gtk ] ; then
+ db_go || true
+ chvt 2
+else
+ db_go || exit
+ debconf-disconnect /bin/sh || true
+elif
when the user presses "Execute a shell", the "chvt 2" command is run and
the console is switched to VT2.
As the original chvt tool from console-tools depends from a couple of
libraries, i've rewritten it (source code attached below) taking source
code from the original console-tools package.
I've tested this solution and it works well; we should also provide a
way for the user to get back to the VT where the g-i runs, as actually
he's told to press run "exit" to get back to the instalation even if the
GTK frontend i used.
If the patch is accepted, someone should also choose where to place the
chvt.c sourcecode.
friendly
Attilio
/**
* @chvt.c Command-line terminal switcher
*
* Copyright (C) 2006 Attilio Fiandrotti <[EMAIL PROTECTED]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* This application is a patchwork of source code from package "console-tools"
* (for more informations about the original package see author's page
* http://www.multimania.com/ydirson/en/lct/) and it's meant to be used
* in the debian-installer while not relying on external libraries.
*
**/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/vt.h>
#include <linux/kd.h>
int get_console_fd(char* tty_name);
int is_a_console(int fd);
static int open_a_console(char *fnam);
int main(int argc, char *argv[])
{
int fd, num ;
char console_name[16];
if ( argc < 2 ) {
printf ("Usage %s [vt_number]\n", argv[0]);
exit(0);
}
num = atoi(argv[1]);
sprintf(console_name,"/dev/tty%d",num);
if (-1 == (fd = get_console_fd(console_name))) exit (1);
if (ioctl(fd,VT_ACTIVATE,num))
{
perror("chvt: VT_ACTIVATE");
exit(1);
}
if (ioctl(fd,VT_WAITACTIVE,num))
{
perror("VT_WAITACTIVE");
exit(1);
}
exit(0);
}
int is_a_console(int fd)
{
char arg;
arg = 0;
return (ioctl(fd, KDGKBTYPE, &arg) == 0
&& ((arg == KB_101) || (arg == KB_84)));
}
static int open_a_console(char *fnam)
{
int fd;
/* try read-only */
fd = open(fnam, O_RDWR);
/* if failed, try read-only */
if (fd < 0 && errno == EACCES)
fd = open(fnam, O_RDONLY);
/* if failed, try write-only */
if (fd < 0 && errno == EACCES)
fd = open(fnam, O_WRONLY);
/* if failed, fail */
if (fd < 0)
return -1;
/* if not a console, fail */
if (! is_a_console(fd))
{
close(fd);
return -1;
}
/* success */
return fd;
}
int get_console_fd(char* tty_name)
{
int fd;
if (tty_name)
{
if (-1 == (fd = open_a_console(tty_name)))
return -1;
else
return fd;
}
fd = open_a_console("/dev/tty");
if (fd >= 0)
return fd;
fd = open_a_console("/dev/tty0");
if (fd >= 0)
return fd;
fd = open_a_console("/dev/console");
if (fd >= 0)
return fd;
for (fd = 0; fd < 3; fd++)
if (is_a_console(fd))
return fd;
fprintf(stderr,
"Couldnt get a file descriptor referring to the console\n");
return -1; /* total failure */
}