Move installer to its own directory.

This commit is contained in:
Michael Tremer
2014-07-30 22:04:35 +02:00
parent 7064bbd991
commit 5315fae6b3
20 changed files with 579 additions and 288 deletions

View File

@@ -78,7 +78,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
tar -x -C /tmp -f /$(SNAME).tar
rm -f /$(SNAME).tar
@mkdir /tmp/sys
cd /tmp && tar cf /install/cdrom/$(SNAME)-$(VERSION).tlz $(TAR_OPTIONS) * && rm -rf *
cd /tmp && tar cf /install/cdrom/distro.img $(TAR_OPTIONS) * && rm -rf *
# Other files
touch /install/cdrom/$(SNAME)-$(VERSION)-core$(CORE).media

View File

@@ -48,26 +48,20 @@ md5 :
$(TARGET) :
@$(PREBUILD)
-mkdir -p /install/initrd/bin
@rm -rf $(DIR_APP) && mkdir $(DIR_APP) && cp -R $(DIR_SRC)/src/install+setup/* $(DIR_APP)
for i in $(DIR_SRC)/langs/*/install/lang_*.c ; do \
cp $$i $(DIR_APP)/libsmooth; \
done
cd $(DIR_APP)/libsmooth && chmod 755 makelangs.pl
cd $(DIR_APP)/libsmooth && make CFLAGS="-Os -fomit-frame-pointer -Wall \
-DNAME='\"$(NAME)\"' -DSNAME='\"$(SNAME)\"' -DVERSION='\"$(VERSION)\"' \
-DSLOGAN='\"$(SLOGAN)\"' -DCONFIG_ROOT='\"$(CONFIG_ROOT)\"'"
cd $(DIR_APP)/install && make CFLAGS="-Os -std=gnu99 -fomit-frame-pointer -Wall \
-DNAME='\"$(NAME)\"' -DSNAME='\"$(SNAME)\"' -DVERSION='\"$(VERSION)\"' \
-DSLOGAN='\"$(SLOGAN)\"' -DCONFIG_ROOT='\"$(CONFIG_ROOT)\"' -DKERNEL_VERSION='\"$(KVER)\"'"
cd $(DIR_APP)/install && install -v -m 0755 installer probenic.sh \
downloadsource.sh mountdest.sh /usr/bin
rm -rvf /usr/lib/dracut/modules.d/99installer
cd $(DIR_APP)/install && cp -rvf dracut-module /usr/lib/dracut/modules.d/99installer
@rm -rf $(DIR_APP) && mkdir $(DIR_APP) && cp -R $(DIR_SRC)/src/installer/* $(DIR_APP)
cd $(DIR_APP) && ./autogen.sh
cd $(DIR_APP) && ./configure \
--prefix=/usr \
--with-distro-name="$(NAME)" \
--with-distro-sname="$(SNAME)" \
--with-distro-slogan="$(SLOGAN)" \
--with-config-root="$(CONFIG_ROOT)"
cd $(DIR_APP) && make $(MAKETUNING)
cd $(DIR_APP) && make install
#Patch ISO Name for download ...
sed -i -e "s|ipfire.iso|download.ipfire.org/releases/ipfire-2.x/$(VERSION)-core$(CORE)/$(SNAME)-$(VERSION).$(MACHINE)-full-core$(CORE).iso|g" \
/usr/bin/downloadsource.sh
#Patch version for mediacheck ...
#sed -i -e "s|ipfire.iso|download.ipfire.org/releases/ipfire-2.x/$(VERSION)-core$(CORE)/$(SNAME)-$(VERSION).$(MACHINE)-full-core$(CORE).iso|g" \
# /usr/bin/downloadsource.sh
@rm -rf $(DIR_APP)
@$(POSTBUILD)

View File

@@ -1,87 +0,0 @@
/* SmoothWall install program.
*
* This program is distributed under the terms of the GNU General Public
* Licence. See the file COPYING for details.
*
* (c) Lawrence Manning, 2001
* Write the config and get password stuff.
*
*/
#include "install.h"
extern FILE *flog;
extern char *mylog;
extern char **ctr;
int write_lang_configs( char *lang)
{
struct keyvalue *kv = initkeyvalues();
/* default stuff for main/settings. */
replacekeyvalue(kv, "LANGUAGE", lang);
replacekeyvalue(kv, "HOSTNAME", SNAME);
replacekeyvalue(kv, "THEME", "ipfire");
writekeyvalues(kv, "/harddisk" CONFIG_ROOT "/main/settings");
freekeyvalues(kv);
return 1;
}
int write_ethernet_configs(struct keyvalue *ethernetkv)
{
/* Write out the network settings we got from a few mins ago. */
writekeyvalues(ethernetkv, "/harddisk" CONFIG_ROOT "/ethernet/settings");
return 1;
}
/* Taken from the cdrom one. */
int getpassword(char *password, char *text)
{
char *values[] = { NULL, NULL, NULL }; /* pointers for the values. */
struct newtWinEntry entries[] =
{
{ ctr[TR_PASSWORD_PROMPT], &values[0], 2 },
{ ctr[TR_AGAIN_PROMPT], &values[1], 2 },
{ NULL, NULL, 0 }
};
char title[STRING_SIZE];
int rc;
int done;
do
{
done = 1;
sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN);
rc = newtWinEntries(title, text,
50, 5, 5, 20, entries, ctr[TR_OK], ctr[TR_CANCEL], NULL);
if (rc != 2)
{
if (strlen(values[0]) == 0 || strlen(values[1]) == 0)
{
errorbox(ctr[TR_PASSWORD_CANNOT_BE_BLANK]);
done = 0;
strcpy(values[0], "");
strcpy(values[1], "");
}
else if (strcmp(values[0], values[1]) != 0)
{
errorbox(ctr[TR_PASSWORDS_DO_NOT_MATCH]);
done = 0;
strcpy(values[0], "");
strcpy(values[1], "");
}
}
}
while (!done);
strncpy(password, values[0], STRING_SIZE);
if (values[0]) free(values[0]);
if (values[1]) free(values[1]);
return rc;
}

View File

@@ -1,90 +0,0 @@
#!/bin/sh
###############################################################################
# #
# IPFire.org - A linux based firewall #
# Copyright (C) 2011 IPFire Team <info@ipfire.org> #
# #
# 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 3 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, see <http://www.gnu.org/licenses/>. #
# #
###############################################################################
if [ -e /var/ipfire/ethernet/scanned_nics ]; then
rm -f /var/ipfire/ethernet/scanned_nics
fi
touch /var/ipfire/ethernet/scanned_nics
for card in `ls /sys/class/net`; do
#Check if this is an Ethernet device (type=1)
if [ `cat /sys/class/net/$card/type` == "1" ]; then
hwaddr=`cat /sys/class/net/$card/address`
#Check that is no VLAN if
if [[ ! "$card" =~ "[.]" ]]; then
#check if this not a bridge
if [ ! -e /sys/class/net/$card/brforward ]; then
#Check if mac is valid (not 00:00... or FF:FF...)
if [ ! "$hwaddr" == "00:00:00:00:00:00" ];then
if [ ! "$hwaddr" == "ff:ff:ff:ff:ff:ff" ];then
driver=`grep DRIVER= /sys/class/net/$card/device/uevent | cut -d"=" -f2`
type=`grep MODALIAS= /sys/class/net/$card/device/uevent | cut -d"=" -f2 | cut -d":" -f1`
#Default if not available in /sys/class/net
if [ "a$type" == "a" ]; then
type="???"
fi
if [ "a$driver" == "a" ]; then
driver="Unknown Network Interface ($card)"
fi
description=`echo $type: $driver`
#Get more details for pci and usb devices
if [ "$type" == "pci" ]; then
slotname=`grep PCI_SLOT_NAME= /sys/class/net/$card/device/uevent | cut -d"=" -f2`
name=`lspci -s $slotname | cut -d':' -f3 | cut -c 2-`
description=`echo $type: $name`
fi
if [ "$type" == "usb" ]; then
bus=`grep DEVICE= /sys/class/net/$card/device/uevent | cut -d"/" -f5`
dev=`grep DEVICE= /sys/class/net/$card/device/uevent | cut -d"/" -f6`
#work around the base8 convert
let bus=`echo 1$bus`-1000
let dev=`echo 1$dev`-1000
name=`lsusb -s $bus:$dev | cut -d':' -f3 | cut -c 6-`
#kernel higher 3.2 changes
if [ "$name" == "" ]; then
vid=`grep PRODUCT= /sys/class/net/$card/device/uevent | cut -d"=" -f2 | cut -d"/" -f1`
pid=`grep PRODUCT= /sys/class/net/$card/device/uevent | cut -d"=" -f2 | cut -d"/" -f2`
name=`lsusb -d $vid:$pid | cut -d':' -f3 | cut -c 6-`
fi
description=`echo $type: $name`
fi
echo desc: \"$description\" >>/var/ipfire/ethernet/scanned_nics
echo driver: $driver >>/var/ipfire/ethernet/scanned_nics
echo network.hwaddr: $hwaddr >>/var/ipfire/ethernet/scanned_nics
fi
fi
fi
fi
fi
done
# Revert Accesspoint marking at mac address
sed -i 's|hwaddr: 06:|hwaddr: 00:|g' /var/ipfire/ethernet/scanned_nics
exit 0

View File

@@ -25,7 +25,7 @@ INCLUDE =
LD = gcc
LDFLAGS =
LIBS = -lnewt -lslang -lpci -ludev -lblkid
LIBS = -lnewt -lslang -lpci -ludev -lblkid -lsmooth
COMPILE = $(CC) -c $(INCLUDE) $(CFLAGS)
@@ -40,7 +40,7 @@ clean :
######
OBJS=main.o config.o ../libsmooth/libsmooth.o unattended.o hw.o
OBJS=main.o unattended.o hw.o
installer: $(OBJS)
$(LINK) $(OBJS) -o $@ $(LIBS)

80
src/installer/Makefile.am Normal file
View File

@@ -0,0 +1,80 @@
# This file is part of the libsmooth library.
#
# libsmooth is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
AM_MAKEFLAGS = --no-print-directory
AUTOMAKE_OPTIONS = color-tests parallel-tests
SUBDIRS = .
# remove targets if the command fails
.DELETE_ON_ERROR:
# keep intermediate files
.SECONDARY:
CLEANFILES =
EXTRA_DIST =
dracutmoduledir = $(prefix)/lib/dracut/modules.d/99installer
AM_CPPFLAGS = \
-include $(top_builddir)/config.h \
-I $(top_srcdir)/include \
$(OUR_CPPFLAGS)
AM_CFLAGS = $(OUR_CFLAGS)
AM_LDFLAGS = $(OUR_LDFLAGS)
bin_PROGRAMS = \
installer
bin_SCRIPTS = \
downloadsource.sh
#- installer -------------------------------------------------------------------
installer_SOURCES = \
hw.c \
hw.h \
main.c \
unattended.c
installer_CFLAGS = \
$(BLKID_CFLAGS) \
$(LIBSMOOTH_CFLAGS) \
$(PCI_CFLAGS) \
$(UDEV_CFLAGS)
installer_LDADD = \
$(BLKID_LIBS) \
$(LIBSMOOTH_LIBS) \
$(NEWT_LIBS) \
$(PCI_LIBS) \
$(UDEV_LIBS)
dracutmodule_DATA = \
dracut-module/70-dhcpcd.exe \
dracut-module/fake-root.sh \
dracut-module/module-setup.sh \
dracut-module/run-installer.sh
#-------------------------------------------------------------------------------
substitutions = \
'|PACKAGE_NAME=$(PACKAGE_NAME)|' \
'|PACKAGE_VERSION=$(PACKAGE_VERSION)|' \
'|prefix=$(prefix)|' \
'|exec_prefix=$(exec_prefix)|' \
'|libdir=$(libdir)|' \
'|includedir=$(includedir)|'
SED_PROCESS = \
$(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
$(SED) $(subst '|,-e 's|@,$(subst =,\@|,$(subst |',|g',$(substitutions)))) < $< > $@
%.pc: %.pc.in Makefile
$(SED_PROCESS)

3
src/installer/autogen.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
autoreconf --force --install -I m4

View File

@@ -0,0 +1,95 @@
# This file is part of the installer.
#
# installer is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
AC_PREREQ([2.64])
AC_INIT([installer],
[001],
[],
[installer],
[http://git.ipfire.org/?p=ipfire-2.x.git;a=summary])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([
foreign
1.11
-Wall
-Wno-portability
silent-rules
tar-pax
no-dist-gzip
dist-xz
subdir-objects
])
AM_SILENT_RULES([yes])
LT_PREREQ(2.2)
LT_INIT([disable-static])
AC_PROG_SED
AC_PROG_CC
AC_PROG_CC_C99
AC_PROG_CC_C_O
AC_PATH_PROG([M4], [m4])
AC_CHECK_HEADERS([libintl.h])
# This makes sure pkg.m4 is available.
m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-config])
save_LIBS="$LIBS"
# newt
LIBS=
AC_SEARCH_LIBS([newtWinMenu], [newt], [], [AC_MSG_ERROR([*** newt library not found])])
NEWT_LIBS="$LIBS"
AC_SUBST(NEWT_LIBS)
LIBS="$save_LIBS"
PKG_CHECK_MODULES(BLKID, [blkid])
PKG_CHECK_MODULES(PCI, [libpci])
PKG_CHECK_MODULES(LIBSMOOTH, [libsmooth])
PKG_CHECK_MODULES(UDEV, [libudev])
AC_ARG_WITH([distro-name],
AS_HELP_STRING([--with-distro-name] [The name of the distribution]),
AC_DEFINE_UNQUOTED([NAME], "$withval", [The name of the distribution]),
AC_MSG_ERROR([*** you need to set the name with --with-distro-name=]))
AC_ARG_WITH([distro-sname],
AS_HELP_STRING([--with-distro-sname] [The short name of the distribution]),
AC_DEFINE_UNQUOTED([SNAME], "$withval", [The sname of the distribution]),
AC_MSG_ERROR([*** you need to set the sname with --with-distro-sname=]))
AC_ARG_WITH([distro-slogan],
AS_HELP_STRING([--with-distro-slogan] [The slogan of the distribution]),
AC_DEFINE_UNQUOTED([SLOGAN], "$withval", [The slogan of the distribution]),
AC_MSG_ERROR([*** you need to set the slogan with --with-distro-slogan=]))
AC_ARG_WITH([config-root],
AS_HELP_STRING([--with-distro-config-root] [The configuration directory]),
AC_DEFINE_UNQUOTED([CONFIG_ROOT], "$withval", [The config-root]),
AC_MSG_ERROR([*** you need to set CONFIG_ROOT with --with-config-root=]))
AC_CONFIG_FILES([
Makefile
])
AC_OUTPUT
AC_MSG_RESULT([
$PACKAGE_NAME $VERSION
CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
])

View File

@@ -15,6 +15,7 @@ depends() {
# called by dracut
install() {
inst /etc/system-release
inst /usr/bin/installer
inst /usr/bin/downloadsource.sh
inst /usr/local/bin/iowrap
@@ -56,6 +57,10 @@ install() {
done
done
# Bash start files
inst_multiple /etc/profile /root/.bash_profile /etc/bashrc /root/.bashrc
inst_dir /etc/profile.d
inst_hook cmdline 99 "$moddir/fake-root.sh"
inst_hook pre-mount 99 "$moddir/run-installer.sh"

View File

@@ -37,8 +37,9 @@
#include <linux/fs.h>
#include <libsmooth.h>
#include "hw.h"
#include "../libsmooth/libsmooth.h"
const char* other_filesystems[] = {
"/dev",
@@ -97,16 +98,16 @@ static int hw_test_source_medium(const char* path) {
// If the source could not be mounted we
// cannot proceed.
if (ret)
if (ret != 0)
return ret;
// Check if the test file exists.
ret = access(SOURCE_TEST_FILE, F_OK);
ret = access(SOURCE_TEST_FILE, R_OK);
// Umount the test device.
hw_umount(SOURCE_MOUNT_PATH);
return ret;
return (ret == 0);
}
char* hw_find_source_medium(struct hw* hw) {
@@ -131,7 +132,7 @@ char* hw_find_source_medium(struct hw* hw) {
strstartswith(dev_path, "/dev/ram") || strstartswith(dev_path, "/dev/md"))
continue;
if (hw_test_source_medium(dev_path)) {
if (hw_test_source_medium(dev_path) == 0) {
ret = strdup(dev_path);
}
@@ -350,7 +351,7 @@ static int hw_calculate_partition_table(struct hw_destination* dest) {
// Determine the size of the target block device
if (dest->is_raid) {
dest->size = (dest->disk1->size >= dest->disk2->size) ?
dest->disk1->size : dest->disk2->size;
dest->disk2->size : dest->disk1->size;
// The RAID will install some metadata at the end of the disk
// and we will save up some space for that.

View File

@@ -8,17 +8,7 @@
*
*/
#include "../libsmooth/libsmooth.h"
#define IDE_EMPTY 0
#define IDE_CDROM 1
#define IDE_HD 2
#define IDE_UNKNOWN 3
/* config.c */
int write_disk_configs(struct devparams *dp);
int write_lang_configs( char *lang);
int write_ethernet_configs(struct keyvalue *ethernetkv);
#include <libsmooth.h>
/* unattended.c */
int unattended_setup(struct keyvalue *unattendedkv);

View File

@@ -0,0 +1,288 @@
dnl Macros to check the presence of generic (non-typed) symbols.
dnl Copyright (c) 2006-2008 Diego Pettenò <flameeyes@gmail.com>
dnl Copyright (c) 2006-2008 xine project
dnl Copyright (c) 2012 Lucas De Marchi <lucas.de.marchi@gmail.com>
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2, or (at your option)
dnl any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
dnl 02110-1301, USA.
dnl
dnl As a special exception, the copyright owners of the
dnl macro gives unlimited permission to copy, distribute and modify the
dnl configure scripts that are the output of Autoconf when processing the
dnl Macro. You need not follow the terms of the GNU General Public
dnl License when using or distributing such scripts, even though portions
dnl of the text of the Macro appear in them. The GNU General Public
dnl License (GPL) does govern all other use of the material that
dnl constitutes the Autoconf Macro.
dnl
dnl This special exception to the GPL applies to versions of the
dnl Autoconf Macro released by this project. When you make and
dnl distribute a modified version of the Autoconf Macro, you may extend
dnl this special exception to the GPL to apply to your modified version as
dnl well.
dnl Check if FLAG in ENV-VAR is supported by compiler and append it
dnl to WHERE-TO-APPEND variable
dnl CC_CHECK_FLAG_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG])
AC_DEFUN([CC_CHECK_FLAG_APPEND], [
AC_CACHE_CHECK([if $CC supports flag $3 in envvar $2],
AS_TR_SH([cc_cv_$2_$3]),
[eval "AS_TR_SH([cc_save_$2])='${$2}'"
eval "AS_TR_SH([$2])='-Werror $3'"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int a = 0; int main(void) { return a; } ])],
[eval "AS_TR_SH([cc_cv_$2_$3])='yes'"],
[eval "AS_TR_SH([cc_cv_$2_$3])='no'"])
eval "AS_TR_SH([$2])='$cc_save_$2'"])
AS_IF([eval test x$]AS_TR_SH([cc_cv_$2_$3])[ = xyes],
[eval "$1='${$1} $3'"])
])
dnl CC_CHECK_FLAGS_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG1 FLAG2])
AC_DEFUN([CC_CHECK_FLAGS_APPEND], [
for flag in $3; do
CC_CHECK_FLAG_APPEND($1, $2, $flag)
done
])
dnl Check if the flag is supported by linker (cacheable)
dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
AC_DEFUN([CC_CHECK_LDFLAGS], [
AC_CACHE_CHECK([if $CC supports $1 flag],
AS_TR_SH([cc_cv_ldflags_$1]),
[ac_save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $1"
AC_LINK_IFELSE([int main() { return 1; }],
[eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"],
[eval "AS_TR_SH([cc_cv_ldflags_$1])="])
LDFLAGS="$ac_save_LDFLAGS"
])
AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes],
[$2], [$3])
])
dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for
dnl the current linker to avoid undefined references in a shared object.
AC_DEFUN([CC_NOUNDEFINED], [
dnl We check $host for which systems to enable this for.
AC_REQUIRE([AC_CANONICAL_HOST])
case $host in
dnl FreeBSD (et al.) does not complete linking for shared objects when pthreads
dnl are requested, as different implementations are present; to avoid problems
dnl use -Wl,-z,defs only for those platform not behaving this way.
*-freebsd* | *-openbsd*) ;;
*)
dnl First of all check for the --no-undefined variant of GNU ld. This allows
dnl for a much more readable commandline, so that people can understand what
dnl it does without going to look for what the heck -z defs does.
for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do
CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"])
break
done
;;
esac
AC_SUBST([LDFLAGS_NOUNDEFINED])
])
dnl Check for a -Werror flag or equivalent. -Werror is the GCC
dnl and ICC flag that tells the compiler to treat all the warnings
dnl as fatal. We usually need this option to make sure that some
dnl constructs (like attributes) are not simply ignored.
dnl
dnl Other compilers don't support -Werror per se, but they support
dnl an equivalent flag:
dnl - Sun Studio compiler supports -errwarn=%all
AC_DEFUN([CC_CHECK_WERROR], [
AC_CACHE_CHECK(
[for $CC way to treat warnings as errors],
[cc_cv_werror],
[CC_CHECK_CFLAGS_SILENT([-Werror], [cc_cv_werror=-Werror],
[CC_CHECK_CFLAGS_SILENT([-errwarn=%all], [cc_cv_werror=-errwarn=%all])])
])
])
AC_DEFUN([CC_CHECK_ATTRIBUTE], [
AC_REQUIRE([CC_CHECK_WERROR])
AC_CACHE_CHECK([if $CC supports __attribute__(( ifelse([$2], , [$1], [$2]) ))],
AS_TR_SH([cc_cv_attribute_$1]),
[ac_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $cc_cv_werror"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])],
[eval "AS_TR_SH([cc_cv_attribute_$1])='yes'"],
[eval "AS_TR_SH([cc_cv_attribute_$1])='no'"])
CFLAGS="$ac_save_CFLAGS"
])
AS_IF([eval test x$]AS_TR_SH([cc_cv_attribute_$1])[ = xyes],
[AC_DEFINE(
AS_TR_CPP([SUPPORT_ATTRIBUTE_$1]), 1,
[Define this if the compiler supports __attribute__(( ifelse([$2], , [$1], [$2]) ))]
)
$4],
[$5])
])
AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [
CC_CHECK_ATTRIBUTE(
[constructor],,
[void __attribute__((constructor)) ctor() { int a; }],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_FORMAT], [
CC_CHECK_ATTRIBUTE(
[format], [format(printf, n, n)],
[void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { fmt = (void *)0; }],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [
CC_CHECK_ATTRIBUTE(
[format_arg], [format_arg(printf)],
[char *__attribute__((format_arg(1))) gettextlike(const char *fmt) { fmt = (void *)0; }],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [
CC_CHECK_ATTRIBUTE(
[visibility_$1], [visibility("$1")],
[void __attribute__((visibility("$1"))) $1_function() { }],
[$2], [$3])
])
AC_DEFUN([CC_ATTRIBUTE_NONNULL], [
CC_CHECK_ATTRIBUTE(
[nonnull], [nonnull()],
[void __attribute__((nonnull())) some_function(void *foo, void *bar) { foo = (void*)0; bar = (void*)0; }],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_UNUSED], [
CC_CHECK_ATTRIBUTE(
[unused], ,
[void some_function(void *foo, __attribute__((unused)) void *bar);],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [
CC_CHECK_ATTRIBUTE(
[sentinel], ,
[void some_function(void *foo, ...) __attribute__((sentinel));],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_DEPRECATED], [
CC_CHECK_ATTRIBUTE(
[deprecated], ,
[void some_function(void *foo, ...) __attribute__((deprecated));],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_ALIAS], [
CC_CHECK_ATTRIBUTE(
[alias], [weak, alias],
[void other_function(void *foo) { }
void some_function(void *foo) __attribute__((weak, alias("other_function")));],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_MALLOC], [
CC_CHECK_ATTRIBUTE(
[malloc], ,
[void * __attribute__((malloc)) my_alloc(int n);],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_PACKED], [
CC_CHECK_ATTRIBUTE(
[packed], ,
[struct astructure { char a; int b; long c; void *d; } __attribute__((packed));],
[$1], [$2])
])
AC_DEFUN([CC_ATTRIBUTE_CONST], [
CC_CHECK_ATTRIBUTE(
[const], ,
[int __attribute__((const)) twopow(int n) { return 1 << n; } ],
[$1], [$2])
])
AC_DEFUN([CC_FLAG_VISIBILITY], [
AC_REQUIRE([CC_CHECK_WERROR])
AC_CACHE_CHECK([if $CC supports -fvisibility=hidden],
[cc_cv_flag_visibility],
[cc_flag_visibility_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $cc_cv_werror"
CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden],
cc_cv_flag_visibility='yes',
cc_cv_flag_visibility='no')
CFLAGS="$cc_flag_visibility_save_CFLAGS"])
AS_IF([test "x$cc_cv_flag_visibility" = "xyes"],
[AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1,
[Define this if the compiler supports the -fvisibility flag])
$1],
[$2])
])
AC_DEFUN([CC_FUNC_EXPECT], [
AC_REQUIRE([CC_CHECK_WERROR])
AC_CACHE_CHECK([if compiler has __builtin_expect function],
[cc_cv_func_expect],
[ac_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $cc_cv_werror"
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[int some_function() {
int a = 3;
return (int)__builtin_expect(a, 3);
}])],
[cc_cv_func_expect=yes],
[cc_cv_func_expect=no])
CFLAGS="$ac_save_CFLAGS"
])
AS_IF([test "x$cc_cv_func_expect" = "xyes"],
[AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1,
[Define this if the compiler supports __builtin_expect() function])
$1],
[$2])
])
AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [
AC_REQUIRE([CC_CHECK_WERROR])
AC_CACHE_CHECK([highest __attribute__ ((aligned ())) supported],
[cc_cv_attribute_aligned],
[ac_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $cc_cv_werror"
for cc_attribute_align_try in 64 32 16 8 4 2; do
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
int main() {
static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0;
return c;
}])], [cc_cv_attribute_aligned=$cc_attribute_align_try; break])
done
CFLAGS="$ac_save_CFLAGS"
])
if test "x$cc_cv_attribute_aligned" != "x"; then
AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX], [$cc_cv_attribute_aligned],
[Define the highest alignment supported])
fi
])

View File

@@ -1,4 +1,3 @@
/* SmoothWall install program.
*
* This program is distributed under the terms of the GNU General Public
@@ -9,8 +8,6 @@
*
*/
#define _GNU_SOURCE
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
@@ -19,7 +16,11 @@
#include "hw.h"
#include "install.h"
// Translation
#include <libintl.h>
#define _(x) dgettext("installer", x)
#define INST_FILECOUNT 21000
#define UNATTENDED_CONF "/cdrom/boot/unattended.conf"
#define LICENSE_FILE "/cdrom/COPYING"
@@ -31,18 +32,6 @@ char **ctr;
extern char url[STRING_SIZE];
struct nic nics[20] = { { "" , "" , "" } }; // only defined for compile
struct knic knics[20] = { { "" , "" , "" , "" } }; // only defined for compile
extern char *en_tr[];
extern char *es_tr[];
extern char *de_tr[];
extern char *fr_tr[];
extern char *nl_tr[];
extern char *pl_tr[];
extern char *ru_tr[];
extern char *tr_tr[];
static int newtChecklist(const char* title, const char* message,
unsigned int width, unsigned int height, unsigned int num_entries,
const char** entries, int* states) {
@@ -89,8 +78,8 @@ static int newtChecklist(const char* title, const char* message,
newtFormAddComponents(form, textbox, subform, NULL);
newtComponent btn_okay = newtButton((width - 18) / 3, height - 4, ctr[TR_OK]);
newtComponent btn_cancel = newtButton((width - 18) / 3 * 2 + 9, height - 4, ctr[TR_CANCEL]);
newtComponent btn_okay = newtButton((width - 18) / 3, height - 4, _("OK"));
newtComponent btn_cancel = newtButton((width - 18) / 3 * 2 + 9, height - 4, _("Cancel"));
newtFormAddComponents(form, btn_okay, btn_cancel, NULL);
newtComponent answer = newtRunForm(form);
@@ -157,10 +146,10 @@ static int newtLicenseBox(const char* title, const char* text, int width, int he
newtFormAddComponent(form, textbox);
char choice;
newtComponent checkbox = newtCheckbox(3, height - 3, ctr[TR_LICENSE_ACCEPT],
newtComponent checkbox = newtCheckbox(3, height - 3, _("I accept this license"),
' ', " *", &choice);
newtComponent btn = newtButton(width - 15, height - 4, ctr[TR_OK]);
newtComponent btn = newtButton(width - 15, height - 4, _("OK"));
newtFormAddComponents(form, checkbox, btn, NULL);
@@ -174,6 +163,19 @@ static int newtLicenseBox(const char* title, const char* text, int width, int he
return ret;
}
int write_lang_configs(const char *lang) {
struct keyvalue *kv = initkeyvalues();
/* default stuff for main/settings. */
replacekeyvalue(kv, "LANGUAGE", lang);
replacekeyvalue(kv, "HOSTNAME", SNAME);
replacekeyvalue(kv, "THEME", "ipfire");
writekeyvalues(kv, "/harddisk" CONFIG_ROOT "/main/settings");
freekeyvalues(kv);
return 1;
}
int main(int argc, char *argv[]) {
struct hw* hw = hw_init();
@@ -181,7 +183,6 @@ int main(int argc, char *argv[]) {
char *langnames[] = { "Deutsch", "English", "Français", "Español", "Nederlands", "Polski", "Русский", "Türkçe", NULL };
char *shortlangnames[] = { "de", "en", "fr", "es", "nl", "pl", "ru", "tr", NULL };
char **langtrs[] = { de_tr, en_tr, fr_tr, es_tr, nl_tr, pl_tr, ru_tr, tr_tr, NULL };
char* sourcedrive = NULL;
int rc = 0;
char commandstring[STRING_SIZE];
@@ -229,7 +230,7 @@ int main(int argc, char *argv[]) {
// check if we have to make an unattended install
if (strstr (line, "unattended") != NULL) {
unattended = 1;
runcommandwithstatus("/bin/sleep 10", "WARNING: Unattended installation will start in 10 seconds...");
runcommandwithstatus("/bin/sleep 10", title, "WARNING: Unattended installation will start in 10 seconds...");
}
// check if we have to patch for serial console
if (strstr (line, "console=ttyS0") != NULL) {
@@ -255,14 +256,15 @@ int main(int argc, char *argv[]) {
langnames, &choice, "Ok", NULL);
}
ctr = langtrs[choice];
strcpy(shortlangname, shortlangnames[choice]);
setlocale(LC_ALL, shortlangnames[choice]);
newtPushHelpLine(ctr[TR_HELPLINE]);
newtPushHelpLine(_("<Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen"));
if (!unattended) {
sprintf(message, ctr[TR_WELCOME], NAME);
newtWinMessage(title, ctr[TR_OK], message);
snprintf(message, sizeof(message),
_("Welcome to the %s installation program. "
"Selecting Cancel on any of the following screens will reboot the computer."), NAME);
newtWinMessage(title, _("Start installation"), message);
}
/* Search for a source drive that holds the right
@@ -271,10 +273,10 @@ int main(int argc, char *argv[]) {
fprintf(flog, "Source drive: %s\n", sourcedrive);
if (!sourcedrive) {
newtWinMessage(title, ctr[TR_OK], ctr[TR_NO_LOCAL_SOURCE]);
runcommandwithstatus("/bin/downloadsource.sh", ctr[TR_DOWNLOADING_ISO]);
newtWinMessage(title, _("OK"), _("No local source media found. Starting download."));
runcommandwithstatus("/bin/downloadsource.sh", title, _("Downloading installation image ..."));
if ((handle = fopen("/tmp/source_device", "r")) == NULL) {
errorbox(ctr[TR_DOWNLOAD_ERROR]);
errorbox(_("Download error"));
goto EXIT;
}
@@ -309,7 +311,7 @@ int main(int argc, char *argv[]) {
fclose(copying);
if (newtLicenseBox(title, discl_msg, 75, 20)) {
errorbox(ctr[TR_LICENSE_NOT_ACCEPTED]);
errorbox(_("License not accepted!"));
goto EXIT;
}
@@ -331,7 +333,7 @@ int main(int argc, char *argv[]) {
while (1) {
// no harddisks found
if (num_disks == 0) {
errorbox(ctr[TR_NO_HARDDISK]);
errorbox(_("No hard disk found."));
goto EXIT;
// exactly one disk has been found
@@ -350,7 +352,10 @@ int main(int argc, char *argv[]) {
}
while (!selected_disks) {
rc = newtChecklist(ctr[TR_DISK_SELECTION], ctr[TR_DISK_SELECTION_MSG],
rc = newtChecklist(_("Disk Selection"),
_("Select the disk(s) you want to install IPFire on. "
"First those will be partitioned, and then the partitions will have a filesystem put on them.\n\n"
"ALL DATA ON THE DISK WILL BE DESTROYED."),
50, 20, num_disks, disk_names, disk_selection);
// Error
@@ -359,7 +364,8 @@ int main(int argc, char *argv[]) {
// Nothing has been selected
} else if (rc == 0) {
errorbox(ctr[TR_NO_DISK_SELECTED]);
errorbox(_("No disk has been selected.\n\n"
"Please select one or more disks you want to install IPFire on."));
} else {
selected_disks = hw_select_disks(disks, disk_selection);
@@ -370,18 +376,21 @@ int main(int argc, char *argv[]) {
num_selected_disks = hw_count_disks(selected_disks);
if (num_selected_disks == 1) {
snprintf(message, sizeof(message), ctr[TR_DISK_SETUP_DESC], (*selected_disks)->description);
rc = newtWinOkCancel(ctr[TR_DISK_SETUP], message, 50, 10,
ctr[TR_DELETE_ALL_DATA], ctr[TR_CANCEL]);
snprintf(message, sizeof(message),
_("The installation program will now prepare the chosen harddisk:\n\n %s\n\n"
"Do you agree to continue?"), (*selected_disks)->description);
rc = newtWinOkCancel(_("Disk Setup"), message, 50, 10,
_("Delete all data"), _("Cancel"));
if (rc == 0)
break;
} else if (num_selected_disks == 2) {
snprintf(message, sizeof(message), ctr[TR_RAID_SETUP_DESC],
(*selected_disks)->description, (*selected_disks + 1)->description);
rc = newtWinOkCancel(ctr[TR_RAID_SETUP], message, 50, 14,
ctr[TR_DELETE_ALL_DATA], ctr[TR_CANCEL]);
snprintf(message, sizeof(message),
_("The installation program will now set up a RAID configuration on the selected harddisks:\n\n %s\n %s\n\n"
"Do you agree to continue?"), (*selected_disks)->description, (*selected_disks + 1)->description);
rc = newtWinOkCancel(_("RAID Setup"), message, 50, 14,
_("Delete all data"), _("Cancel"));
if (rc == 0) {
part_type = HW_PART_TYPE_RAID1;
@@ -391,7 +400,7 @@ int main(int argc, char *argv[]) {
// Currently not supported
} else {
errorbox(ctr[TR_DISK_CONFIGURATION_NOT_SUPPORTED]);
errorbox(_("You disk configuration is currently not supported."));
}
if (selected_disks) {
@@ -405,7 +414,7 @@ int main(int argc, char *argv[]) {
struct hw_destination* destination = hw_make_destination(part_type, selected_disks);
if (!destination) {
errorbox(ctr[TR_DISK_TOO_SMALL]);
errorbox(_("Your harddisk is too small."));
goto EXIT;
}
@@ -418,7 +427,8 @@ int main(int argc, char *argv[]) {
// Warn the user if there is not enough space to create a swap partition
if (!unattended && !*destination->part_swap) {
rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], ctr[TR_CONTINUE_NO_SWAP]);
rc = newtWinChoice(title, _("OK"), _("Cancel"),
_("Your harddisk is very small, but you can continue with an very small swap. (Use with caution)."));
if (rc != 1)
goto EXIT;
@@ -430,10 +440,10 @@ int main(int argc, char *argv[]) {
int fstype;
const char* description;
} filesystems[] = {
{ HW_FS_EXT4, ctr[TR_EXT4FS] },
{ HW_FS_EXT4_WO_JOURNAL, ctr[TR_EXT4FS_WO_JOURNAL] },
{ HW_FS_XFS, ctr[TR_XFS] },
{ HW_FS_REISERFS, ctr[TR_REISERFS] },
{ HW_FS_EXT4, _("ext4 Filesystem") },
{ HW_FS_EXT4_WO_JOURNAL, _("ext4 Filesystem without journal") },
{ HW_FS_XFS, _("XFS Filesystem") },
{ HW_FS_REISERFS, _("ReiserFS Filesystem") },
{ 0, NULL },
};
unsigned int num_filesystems = sizeof(filesystems) / sizeof(*filesystems);
@@ -447,8 +457,8 @@ int main(int argc, char *argv[]) {
fs_names[i] = filesystems[i].description;
}
rc = newtWinMenu(ctr[TR_CHOOSE_FILESYSTEM], ctr[TR_CHOOSE_FILESYSTEM],
50, 5, 5, 6, fs_names, &fs_choice, ctr[TR_OK], ctr[TR_CANCEL], NULL);
rc = newtWinMenu(_("Filesystem Selection"), _("Please choose your filesystem:"),
50, 5, 5, 6, fs_names, &fs_choice, _("OK"), _("Cancel"), NULL);
if (rc == 0)
destination->filesystem = filesystems[fs_choice].fstype;
@@ -459,11 +469,11 @@ int main(int argc, char *argv[]) {
// Setting up RAID if needed.
if (destination->is_raid) {
statuswindow(60, 4, title, ctr[TR_BUILDING_RAID]);
statuswindow(60, 4, title, _("Building RAID..."));
rc = hw_setup_raid(destination);
if (rc) {
errorbox(ctr[TR_UNABLE_TO_BUILD_RAID]);
errorbox(_("Unable to build the RAID."));
goto EXIT;
}
@@ -471,28 +481,28 @@ int main(int argc, char *argv[]) {
}
// Execute the partitioning...
statuswindow(60, 4, title, ctr[TR_PARTITIONING_DISK]);
statuswindow(60, 4, title, _("Partitioning disk..."));
rc = hw_create_partitions(destination);
if (rc) {
errorbox(ctr[TR_UNABLE_TO_PARTITION]);
errorbox(_("Unable to partition the disk."));
goto EXIT;
}
newtPopWindow();
// Execute the formatting...
statuswindow(60, 4, title, ctr[TR_CREATING_FILESYSTEMS]);
statuswindow(60, 4, title, _("Creating filesystems..."));
rc = hw_create_filesystems(destination);
if (rc) {
errorbox(ctr[TR_UNABLE_TO_CREATE_FILESYSTEMS]);
errorbox(_("Unable to create filesystems."));
goto EXIT;
}
rc = hw_mount_filesystems(destination, DESTINATION_MOUNT_PATH);
if (rc) {
errorbox(ctr[TR_UNABLE_TO_MOUNT_FILESYSTEMS]);
errorbox(_("Unable to mount filesystems."));
goto EXIT;
}
@@ -500,12 +510,11 @@ int main(int argc, char *argv[]) {
// Extract files...
snprintf(commandstring, STRING_SIZE,
"/bin/tar -C /harddisk -xvf /cdrom/" SNAME "-" VERSION ".tlz --lzma 2>/dev/null");
"/bin/tar -C /harddisk -xvf /cdrom/distro.img --lzma 2>/dev/null");
if (runcommandwithprogress(60, 4, title, commandstring, INST_FILECOUNT,
ctr[TR_INSTALLING_FILES]))
{
errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]);
_("Installing the system..."))) {
errorbox(_("Unable to install the system."));
goto EXIT;
}
@@ -521,18 +530,17 @@ int main(int argc, char *argv[]) {
/* Build cache lang file */
snprintf(commandstring, STRING_SIZE, "/usr/sbin/chroot /harddisk /usr/bin/perl -e \"require '" CONFIG_ROOT "/lang.pl'; &Lang::BuildCacheLang\"");
if (runcommandwithstatus(commandstring, ctr[TR_INSTALLING_LANG_CACHE]))
{
errorbox(ctr[TR_UNABLE_TO_INSTALL_LANG_CACHE]);
if (runcommandwithstatus(commandstring, title, _("Installing the language cache..."))) {
errorbox(_("Unable to install the language cache."));
goto EXIT;
}
// Installing bootloader...
statuswindow(60, 4, title, ctr[TR_INSTALLING_GRUB]);
statuswindow(60, 4, title, _("Installing the bootloader..."));
rc = hw_install_bootloader(destination);
if (rc) {
errorbox(ctr[TR_UNABLE_TO_INSTALL_GRUB]);
errorbox(_("Unable to install the bootloader."));
goto EXIT;
}
@@ -574,9 +582,13 @@ int main(int argc, char *argv[]) {
mysystem(commandstring);
if (!unattended) {
sprintf(message, ctr[TR_CONGRATULATIONS_LONG],
NAME, SNAME, NAME);
newtWinMessage(ctr[TR_CONGRATULATIONS], ctr[TR_PRESS_OK_TO_REBOOT], message);
snprintf(message, sizeof(message), _("%s was successfully installed. "
"Please remove any installation mediums from this system. "
"Setup will now run where you may configure networking and the system passwords. "
"After Setup has been completed, you should point your web browser at https://%s:444 "
"(or whatever you name your %s), and configure dialup networking (if required) and "
"remote access."), NAME, SNAME, NAME);
newtWinMessage(_("Congratulations!"), _("Reboot"), message);
}
allok = 1;
@@ -585,7 +597,7 @@ EXIT:
fprintf(flog, "Install program ended.\n");
if (!(allok))
newtWinMessage(title, ctr[TR_OK], ctr[TR_PRESS_OK_TO_REBOOT]);
newtWinMessage(title, _("OK"), _("Press Ok to reboot."));
if (allok) {
fflush(flog);

View File

@@ -80,7 +80,7 @@ int unattended_setup(struct keyvalue *unattendedkv) {
replacekeyvalue(ethernetkv, "GREEN_BROADCAST", green_broadcast);
replacekeyvalue(ethernetkv, "CONFIG_TYPE", "0");
replacekeyvalue(ethernetkv, "GREEN_DEV", "eth0");
write_ethernet_configs(ethernetkv);
writekeyvalues(ethernetkv, "/harddisk" CONFIG_ROOT "/ethernet/settings");
freekeyvalues(ethernetkv);
/* timezone */