diff options
Diffstat (limited to 'src/core/libs')
-rw-r--r-- | src/core/libs/lib-blockdevices-filesystems.sh | 13 | ||||
-rw-r--r-- | src/core/libs/lib-misc.sh | 13 | ||||
-rw-r--r-- | src/core/libs/lib-network.sh | 16 | ||||
-rw-r--r-- | src/core/libs/lib-pacman.sh | 8 | ||||
-rw-r--r-- | src/core/libs/lib-software.sh | 4 | ||||
-rw-r--r-- | src/core/libs/lib-ui-interactive.sh | 38 | ||||
-rw-r--r-- | src/core/libs/lib-ui.sh | 2 |
7 files changed, 49 insertions, 45 deletions
diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index 5fa0815..3b43541 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # FORMAT DEFINITIONS: @@ -649,7 +649,7 @@ process_filesystem () reiserfs) yes | mkreiserfs $part $opts >$LOG 2>&1; ret=$? ;; ext2) mke2fs "$part" $opts >$LOG 2>&1; ret=$? ;; ext3) mke2fs -j $part $opts >$LOG 2>&1; ret=$? ;; - ext4) mkfs.ext4 $part $opts >$LOG 2>&1; ret=$? ;; + ext4) mkfs.ext4 $part $opts >$LOG 2>&1; ret=$? ;; #TODO: installer.git uses mke2fs -t ext4 -O dir_index,extent,uninit_bg , which is best? vfat) mkfs.vfat $part $opts >$LOG 2>&1; ret=$? ;; swap) mkswap $part $opts >$LOG 2>&1; ret=$? ;; dm_crypt) [ -z "$fs_params" ] && fs_params='-c aes-xts-plain -y -s 512'; @@ -739,6 +739,8 @@ get_filesystem_program () # $2 standard SI for 1000*n, IEC for 1024*n (optional. defaults to SI) # --> Note that if you do SI on a partition, you get the size of the entire disk, so for now you need IEC for single partitions # output will be in $BLOCKDEVICE_SIZE in MB/MiB +# WARNING: hdparm works - by design - only for ide/sata. not scsi et al +# TODO: clean up all disk size related stuff. see http://bugs.archlinux.org/task/12949 get_blockdevice_size () { [ -b "$1" ] || die_error "get_blockdevice_size needs a blockdevice as \$1 ($1 given)" @@ -749,8 +751,9 @@ get_blockdevice_size () BLOCKDEVICE_SIZE=$(hdparm -I $1 | grep -F '1000*1000' | sed "s/^.*:[ \t]*\([0-9]*\) MBytes.*$/\1/") elif [ "$standard" = IEC ] then - blocks=`fdisk -s $1` || show_warning "Fdisk problem" "Something failed when trying to do fdisk -s $1" - #NOTE: on some interwebs they say 1 block = 512B, on other internets they say 1 block = 1kiB. 1kiB seems to work for me. don't sue me if it doesn't for you - BLOCKDEVICE_SIZE=$(($blocks/1024)) + #NOTE: unreliable method: on some interwebs they say 1 block = 512B, on other internets they say 1 block = 1kiB. 1kiB seems to work for me. don't sue me if it doesn't for you + #blocks=`fdisk -s $1` || show_warning "Fdisk problem" "Something failed when trying to do fdisk -s $1" + #BLOCKDEVICE_SIZE=$(($blocks/1024)) + BLOCKDEVICE_SIZE=$((`fdisk -l $1 | sed -n '2p' | cut -d' ' -f5`/1024)) fi } diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh index 29e4c2e..01c291f 100644 --- a/src/core/libs/lib-misc.sh +++ b/src/core/libs/lib-misc.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # run a process in the background, and log it's stdout and stderr to a specific logfile @@ -14,7 +14,7 @@ run_background () debug "run_background called. identifier: $1, command: $2, logfile: $3" ( \ - touch $RUNTIME_DIR/$1-running + touch $RUNTIME_DIR/.$1-running debug "run_background starting $1: $2 >>$3 2>&1" [ -f $3 ] && echo -e "\n\n\n" >>$3 echo "STARTING $1 . Executing $2 >>$3 2>&1\n" >> $3; @@ -23,7 +23,7 @@ run_background () read $var_exit <<< $? #TODO: bash complains about 'not a valid identifier' debug "run_background done with $1: exitcode (\$$1_exitcode): "${!var_exit}" .Logfile $3" #TODO ${!var_exit} doesn't show anything --> maybe fixed now echo >> $3 - rm -f $RUNTIME_DIR/$1-running + rm -f $RUNTIME_DIR/.$1-running ) & sleep 2 @@ -36,7 +36,7 @@ wait_for () { [ -z "$1" ] && die_error "wait_for needs an identifier to known on which command to wait!" - while [ -f $RUNTIME_DIR/$1-running ] + while [ -f $RUNTIME_DIR/.$1-running ] do #TODO: follow_progress dialog mode = nonblocking (so check and sleep is good), cli mode (tail -f )= blocking? (so check is probably not needed as it will be done) sleep 1 @@ -62,8 +62,9 @@ check_is_in () } -# cleans up file in the runtime directory who can be deleted +# cleans up file in the runtime directory who can be deleted, make dir first if needed cleanup_runtime () { + mkdir -p $RUNTIME_DIR || die_error "Cannot create $RUNTIME_DIR" rm -rf $RUNTIME_DIR/.dia* &>/dev/null -}
\ No newline at end of file +} diff --git a/src/core/libs/lib-network.sh b/src/core/libs/lib-network.sh index ab91069..9ed96b2 100644 --- a/src/core/libs/lib-network.sh +++ b/src/core/libs/lib-network.sh @@ -13,18 +13,18 @@ target_configure_network() PROXY_HTTP="$2" PROXY_FTP="$3" if [ "$1" = fixed ]; then - sed -i "s#eth0=\"eth0#$INTERFACE=\"$INTERFACE#g" ${var_TARGET_DIR}/etc/rc.conf - sed -i "s# 192.168.0.2 # $IPADDR #g" ${var_TARGET_DIR}/etc/rc.conf - sed -i "s# 255.255.255.0 # $SUBNET #g" ${var_TARGET_DIR}/etc/rc.conf - sed -i "s# 192.168.0.255\"# $BROADCAST\"#g" ${var_TARGET_DIR}/etc/rc.conf - sed -i "s#eth0)#$INTERFACE)#g" ${var_TARGET_DIR}/etc/rc.conf + sed -i "s#eth0=\"eth0#$INTERFACE=\"$INTERFACE#g" ${var_TARGET_DIR}/etc/rc.conf + sed -i "s#$INTERFACE 192.168.0.2#$INTERFACE $IPADDR#g" ${var_TARGET_DIR}/etc/rc.conf + sed -i "s#netmask 255.255.255.0#netmask $SUBNET#g" ${var_TARGET_DIR}/etc/rc.conf + sed -i "s#broadcast 192.168.0.255#broadcast $BROADCAST#g" ${var_TARGET_DIR}/etc/rc.conf + sed -i "s#INTERFACES=(eth0)#INTERFACES=($INTERFACE)#g" ${var_TARGET_DIR}/etc/rc.conf if [ "$GW" != "" ]; then - sed -i "s#gw 192.168.0.1#gw $GW#g" ${var_TARGET_DIR}/etc/rc.conf - sed -i "s#!gateway#gateway#g" ${var_TARGET_DIR}/etc/rc.conf + sed -i "s#gw 192.168.0.1#gw $GW#g" ${var_TARGET_DIR}/etc/rc.conf + sed -i "s#!gateway#gateway#g" ${var_TARGET_DIR}/etc/rc.conf fi echo "nameserver $DNS" >> ${var_TARGET_DIR}/etc/resolv.conf else - sed -i "s#eth0=\"eth0.*#$INTERFACE=\"dhcp\"#g" ${var_TARGET_DIR}/etc/rc.conf + sed -i "s#eth0=\"eth0.*#$INTERFACE=\"dhcp\"#g" ${var_TARGET_DIR}/etc/rc.conf fi if [ "$PROXY_HTTP" != "" ]; then diff --git a/src/core/libs/lib-pacman.sh b/src/core/libs/lib-pacman.sh index f318aa8..4497074 100644 --- a/src/core/libs/lib-pacman.sh +++ b/src/core/libs/lib-pacman.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # taken and slightly modified from the quickinst script. # don't know why one should need a static pacman because we already have a working one on the livecd. @@ -78,7 +78,7 @@ do then add_pacman_repo target ${repo} "Include = $var_MIRRORLIST" else - add_pacman_repo target ${repo} "Server = ${serverurl}" + add_pacman_repo target ${repo} "Server = ${serverurl/\/\$repo\//\/$repo\/}" # replace literal '/$repo/' in the serverurl string by "/$repo/" where $repo is our variable. fi done # Set up the necessary directories for pacman use @@ -86,7 +86,7 @@ done [ ! -d "${var_TARGET_DIR}/var/lib/pacman" ] && mkdir -m 755 -p "${var_TARGET_DIR}/var/lib/pacman" infofy "Refreshing package database..." - $PACMAN_TARGET -Sy >$LOG 2>&1 || return 1 + $PACMAN_TARGET -Sy >$LOG 2>&1 || return 1 #TODO: make sure this also goes into the logfile. actually we should do this for many commands. return 0 } @@ -97,7 +97,7 @@ list_pacman_repos () [ "$1" != runtime -a "$1" != target ] && die_error "list_pacman_repos needs target/runtime argument" [ "$1" = target ] && conf=/tmp/pacman.conf [ "$1" = runtime ] && conf=/etc/pacman.conf - grep '\[.*\]' $conf | grep -v options | sed 's/\[//g' | sed 's/\]//g' + grep '\[.*\]' $conf | grep -v options | grep -v '^#' | sed 's/\[//g' | sed 's/\]//g' } diff --git a/src/core/libs/lib-software.sh b/src/core/libs/lib-software.sh index 6b4a1a8..726d20f 100644 --- a/src/core/libs/lib-software.sh +++ b/src/core/libs/lib-software.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash TMP_MKINITCPIO_LOG=$RUNTIME_DIR/mkinitcpio.log TMP_PACMAN_LOG=$RUNTIME_DIR/pacman.log @@ -26,7 +26,7 @@ run_mkinitcpio() installpkg() { notify "Package installation will begin now. You can watch the output in the progress window. Please be patient." target_special_fs on - run_background pacman-installpkg "$PACMAN_TARGET -S $TARGET_PACKAGES" $TMP_PACMAN_LOG #TODO: There may be something wrong here. See http://projects.archlinux.org/?p=installer.git;a=commitdiff;h=f504e9ecfb9ecf1952bd8dcce7efe941e74db946 ASKDEV (Simo) + run_background pacman-installpkg "$PACMAN_TARGET --noconfirm -S $TARGET_PACKAGES" $TMP_PACMAN_LOG #TODO: There may be something wrong here. See http://projects.archlinux.org/?p=installer.git;a=commitdiff;h=f504e9ecfb9ecf1952bd8dcce7efe941e74db946 ASKDEV (Simo) follow_progress " Installing... Please Wait " $TMP_PACMAN_LOG wait_for pacman-installpkg diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 70ef739..8fdc5dc 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash #TODO: get backend code out of here!! @@ -709,11 +709,8 @@ interactive_install_grub() { bootdev=$(mount | grep $var_TARGET_DIR/boot | cut -d' ' -f 1) if [ "$grubdev" != "" -o "$bootdev" != "" ]; then subdir= - if [ "$bootdev" != "" ]; then - grubdev=$(mapdev $bootdev) - else - subdir="/boot" - fi + [ -n "$bootdev" ] && grubdev=$(mapdev $bootdev) || subdir="/boot" + # keep the file from being completely bogus if [ "$grubdev" = "DEVICE NOT FOUND" ]; then notify "Your root boot device could not be autodetected by setup. Ensure you adjust the 'root (hd0,0)' line in your GRUB config accordingly." @@ -867,29 +864,32 @@ interactive_select_mirror() { ask_option no "Mirror selection" "Select an FTP/HTTP mirror" $MIRRORS "Custom" "_" || return 1 local _server=$ANSWER_OPTION if [ "${_server}" = "Custom" ]; then - ask_string "Enter the full URL to core repo." "ftp://ftp.archlinux.org/core/os/i686" || return 1 - var_SYNC_URL=$ANSWER_STRING + ask_string "Enter the full URL to core repo." "ftp://ftp.archlinux.org/core/os/$var_ARCH" || return 1 + var_SYNC_URL=${ANSWER_STRING/\/core\///\$repo/} #replace '/core/' by '/$repo/' else # Form the full URL for our mirror by grepping for the server name in - # our mirrorlist and pulling the full URL out. Substitute 'core' in - # for the repository name, and ensure that if it was listed twice we - # only return one line for the mirror. - var_SYNC_URL=$(egrep -o "${_server}.*" "${var_MIRRORLIST}" | sed 's/\$repo/core/g' | head -n1) + # our mirrorlist and pulling the full URL out. + # Ensure that if it was listed twice we only return one line for the mirror. + var_SYNC_URL=$(egrep -o "${_server}.*" "${var_MIRRORLIST}" | head -n1) fi echo "Using mirror: $var_SYNC_URL" >$LOG } -# geteditor(). taken from original setup code. +# geteditor(). # prompts the user to choose an editor # sets EDITOR global variable # interactive_get_editor() { - ask_option no "Text editor selection" "Select a Text Editor to Use" \ - "1" "nano (easier)" \ - "2" "vi" + unset EDITOR_OPTS + which nano &>/dev/null && EDITOR_OPTS+=("nano" "nano (easier)") + which joe &>/dev/null && EDITOR_OPTS+=("joe" "joe's editor") + which vi &>/dev/null && EDITOR_OPTS+=("vi" "vi (advanced)") + ask_option no "Text editor selection" "Select a Text Editor to Use" "${EDITOR_OPTS[@]}" + #TODO: this code could be a little bit cleaner. case $ANSWER_OPTION in - "1") EDITOR="nano" ;; - "2") EDITOR="vi" ;; - *) EDITOR="nano" ;; + "nano") EDITOR="nano" ;; + "joe") EDITOR="joe" ;; + "vi") EDITOR="vi" ;; + *) EDITOR="nano" ;; esac } diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index ac73b3e..2315394 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # TODO: implement 'retry until user does it correctly' everywhere # TODO: at some places we should check if $1 etc is only 1 word because we often depend on that # TODO: standardize. eg everything $1= question/title, $2=default |