#!/bin/sh #---------------------------------------------------------------------------- # /var/install/bin/get-url - help script to get index.txt # # Creation: 2012-02-26 hbfl # Last Update: $Id$ # # Copyright (c) 2012-@@YEAR@@ the eisfair team, team(at)eisfair(dot)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 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # set package name package_name="url" # include config . /etc/config.d/${package_name} . /var/install/include/eislib . /var/install/include/eismanlib #debug=true if ${debug:-false} then exec 2>/tmp/$(basename ${0})-trace$$.log set -x ask_debug=true export ask_debug fi # check for CUI menu if $(grep -qE "^MENU=['\"]/var/install/bin/show-menu.cui['\"]" /etc/config.d/setup) then browser="/var/install/bin/browse-packages.cui.sh" else browser="/var/install/bin/browse-packages" fi gotoyx() { echo -e "\033[$1;$2H\c"; } url_file=/var/install/url ASK=/var/install/bin/ask idx=1 while [ ${idx} -le ${URL_N} ] do eval url_path='${URL_'${idx}'_PATH}' eval url_name='${URL_'${idx}'_NAME}' if [ -z "${_url_install}" ] then _url_install=${url_name}%${url_path} else _url_install=$(echo "${_url_install}";echo "${url_name}%${url_path}") fi idx=$((${idx} + 1)) done clrhome mecho --info "Install package from URL" echo mecho --stdbr " Available package sources:" echo techo --begin '3 4r 2 1 70*' idx=1 echo "${_url_install}" | while read line do # set IFS to % without techo line _OLD_IFS=${IFS} IFS='%' set -- ${line} IFS=${_OLD_IFS} _name="${1}" _url="${2}" if [ -n "${_name}" ] then _show_name="${_name}" else _show_name="${_url}" fi techo --row "" "${idx}." --link '>' "" "${_show_name}" idx=$((${idx} + 1)) done echo echo echo techo --end gotoyx $((${_EISLIB_SCREENSIZE_Y} - 2)) 1 echo line_count=$((4 + $(echo "${_url_install}" | wc -l))) # set info line to screen is $_line_count + 2 -gt $LINES if [ ${_EISLIB_SCREENSIZE_Y} -lt $((${line_count} + 2)) ] then mecho --info "Use SHIFT + PAGE-UP to scroll up" else echo fi _ask_tmpfile=$(mktemp -t XXXXXXXXXXXXX) ${ASK} "Select" "" "1-$(echo "${_url_install}" | wc -l)" "^$=Return" "0=Exit" >${_ask_tmpfile} rc=${?} _selected_entry=$(cat ${_ask_tmpfile}) rm -f ${_ask_tmpfile} # if ask break, ask returned 255 if [ ${rc} = 255 ] then _selected_entry=0 fi case ${_selected_entry} in '') exit 0 ;; 0) exit 127 ;; *) # get action line _selected_project="$(echo "${_url_install}" | sed -n "${_selected_entry}p" | sed 's/^ *//')" # set IFS to : without techo line _OLD_IFS=${IFS} IFS='%' set -- ${_selected_project} IFS=${_OLD_IFS} _name="${1}" _url="${2}" echo "${_url}" > ${url_file} ;; esac # added url to url-search, if not included # and rebuild packages database if ! grep -q ${_url} /var/install/url-search then echo ${_url} >> /var/install/url-search eisman update __url=true fi eisman query --unstable --url $(dirname ${_url}) > /tmp/query.txt ${browser} --install /tmp/query.txt _inst_ret="${?}" rm -f /tmp/query.txt # remove url entry from url-search, if added if ${__url:-false} then ___url="$(echo "${_url}" | sed 's|/|\\/|g')" sed -i "/${___url}/d" /var/install/url-search fi # if browse-packages end with 0=Exit # then return 127 if [ ${_inst_ret} -eq 127 ] then exit 127 fi # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------