1
0
Просмотр исходного кода

Add simple autologin program to be started by getty

@upstream
dir 7 лет назад
Родитель
Сommit
70d717e763

+ 33 - 0
package/autologin/Makefile

@@ -0,0 +1,33 @@
+# This file is part of the OpenADK project. OpenADK is copyrighted
+# material, please see the LICENCE file in the top-level directory.
+
+include $(ADK_TOPDIR)/rules.mk
+
+PKG_NAME:=		autologin
+PKG_VERSION:=		1.0
+PKG_RELEASE:=		1
+PKG_DESCR:=		tool to automatically login a user with getty
+PKG_SECTION:=		sys/misc
+
+PKG_NOPARALLEL:=	1
+NO_DISTFILES:=		1
+
+include $(ADK_TOPDIR)/mk/package.mk
+
+$(eval $(call PKG_template,AUTOLOGIN,autologin,$(PKG_VERSION)-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION}))
+
+CONFIG_STYLE:=          manual
+BUILD_STYLE:=		manual
+INSTALL_STYLE:=         manual
+
+TARGET_CPPFLAGS+=	-I../autologin
+TARGET_CPPFLAGS+=	-D_GNU_SOURCE
+
+do-build:
+	$(CC) src/autologin.c -o $(WRKBUILD)/autologin
+
+autologin-install:
+	$(INSTALL_DIR) $(IDIR_AUTOLOGIN)/bin
+	$(INSTALL_BIN) $(WRKBUILD)/autologin $(IDIR_AUTOLOGIN)/bin
+
+include ${ADK_TOPDIR}/mk/pkg-bottom.mk

+ 10 - 0
package/autologin/src/autologin.c

@@ -0,0 +1,10 @@
+// This file is part of the OpenADK project. OpenADK is copyrighted
+// material, please see the LICENCE file in the top-level directory.
+
+#include <unistd.h>
+#include <stdio.h>
+
+int main()
+{
+  return execlp("login\0","login\0","-f\0", "root\0" ,0);
+}

+ 7 - 0
package/base-files/Makefile

@@ -27,6 +27,12 @@ else
 ADK_RUNTIME_DEV_MDEV_LOGGING_LINE:=''
 endif
 
+ifeq ($(ADK_RUNTIME_GETTY_SERIAL_AUTOLOGIN),y)
+ADK_RUNTIME_GETTY_SERIAL_AUTOLOGIN_STANZA:= -n -l autologin
+else
+ADK_RUNTIME_GETTY_SERIAL_AUTOLOGIN_STANZA:=
+endif
+
 do-install:
 	$(CP) ./src/* $(IDIR_BASE_FILES)
 	mkdir -p $(IDIR_BASE_FILES)/{etc,dev,boot,root,sys,proc,tmp,run,var,mnt,media}
@@ -83,6 +89,7 @@ endif
 	    cat ./files/inittab.serial >> $(IDIR_BASE_FILES)/etc/inittab
 	$(SED) 's#@DEVICE@#$(ADK_RUNTIME_CONSOLE_SERIAL_DEVICE)#g' $(IDIR_BASE_FILES)/etc/inittab
 	$(SED) 's#@SPEED@#$(ADK_RUNTIME_CONSOLE_SERIAL_SPEED)#' $(IDIR_BASE_FILES)/etc/inittab
+	$(SED) 's#@AUTOLOGIN@#$(ADK_RUNTIME_GETTY_SERIAL_AUTOLOGIN_STANZA)#' $(IDIR_BASE_FILES)/etc/inittab
 endif
 ifeq ($(ADK_RUNTIME_INIT_SYSVINIT),y)
 	cp ./files/inittab.sysvinit $(IDIR_BASE_FILES)/etc/inittab

+ 1 - 1
package/base-files/files/inittab.serial

@@ -1 +1 @@
-@DEVICE@::respawn:/sbin/getty -i -L @DEVICE@ @SPEED@ vt100
+@DEVICE@::respawn:/sbin/getty -i -L @DEVICE@ @SPEED@ vt100 @AUTOLOGIN@

+ 5 - 0
target/config/Config.in.runtime

@@ -367,6 +367,11 @@ config ADK_RUNTIME_GETTY_SERIAL
 	help
 	  Start getty on serial console.
 
+config ADK_RUNTIME_GETTY_SERIAL_AUTOLOGIN
+       bool "run autologin on serial getty"
+       depends on ADK_RUNTIME_GETTY_SERIAL
+       select ADK_PACKAGE_AUTOLOGIN
+
 config ADK_RUNTIME_CONSOLE_VGA_DEVICE
 	string "VGA console device"
 	depends on ADK_TARGET_WITH_VGA || ADK_TARGET_GENERIC