#!/bin/sh
#----------------------------------------------------------------------------
# /var/install/bin/pre-setup-packages-install-from-url-section-menu
#
# - setup.packages.menu -> Install package from URL section : setup.packages.install.from.url.section.menu
#
## Creation: 2016-08-19 hbfl
# Last Update: $Id$
#
# Copyright (c) 2016-@@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.
#----------------------------------------------------------------------------
# include eislib
. /var/install/include/eislib
#debug=true
if ${debug:-false}
then
exec 2>/tmp/$(basename ${0})-trace$$.log
set -x
ask_debug=true
export ask_debug
fi
search_file=/etc/eisman/url.conf
temp_search_file=/etc/eisman/temp_url.conf
# ---------------------------------------------------------------------------
# check valid section
# ---------------------------------------------------------------------------
check_section()
{
_section_invalid='true'
if echo "${VALID_SECTIONS}" | grep -q "^${_sec}$"
then
_section_invalid='false'
fi
}
# ---------------------------------------------------------------------------
# create menu
# ---------------------------------------------------------------------------
create_menu()
{
{
echo "
List packages by section"
echo "url"
echo ""
echo ""
_section=$(eisman sections --unstable --url="$(dirname ${url})")
echo ""
echo ""
for _sec in ${_section}
do
_sec_first=$(echo ${_sec} | cut -c1 | tr [:lower:] [:upper:])
_sec_secon=$(echo ${_sec} | cut -c2-)
check_section
if ${_section_invalid}
then
echo ""
else
echo ""
fi
done
} > "${menu_file}"
chmod 0640 ${menu_file}
}
# ---------------------------------------------------------------------------
# main
# ---------------------------------------------------------------------------
main()
{
. /tmp/install-url.txt
local action="${3}"
menu_file="${4}"
argument=$(echo "${6}" | sed 's|"||g ; s| ||g' | cut -d '-' -f 1)
eval url='$'URL_PATH_"${argument}"
case "${url}" in
"file:///media/cdrom/"*)
mount_cdrom
;;
"file:///media/usb/"*)
mount_usb
;;
esac
if [ -f ${search_file} ]
then
# added url to /etc/eisman/temp-url.conf, if not included
# and rebuild packages database
if ! grep -q ${url} ${search_file}
then
if [ -f ${temp_search_file} ]
then
if ! grep -q ${url} ${temp_search_file}
then
echo "highest ${url}" >> ${temp_search_file}
eisman update
fi
else
echo "highest ${url}" >> ${temp_search_file}
eisman update
fi
# echo "$(dirname ${url})" >>/tmp/install-search-url.txt
# chmod 0640 /tmp/install-search-url.txt
fi
fi
if [ "${action}" = "menu" ]
then
create_menu
fi
exit 0
}
# ---------------------------------------------------------------------------
# call function main
# ---------------------------------------------------------------------------
main "${@}"
# ---------------------------------------------------------------------------
# end
# ---------------------------------------------------------------------------