YaST Commits
Threads by month
- ----- 2024 -----
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
August 2008
- 26 participants
- 953 discussions
[yast-commit] r50487 - in /trunk/storage: libstorage/src/Storage.cc storage/src/modules/Storage.ycp
by aschnell@svn.opensuse.org 29 Aug '08
by aschnell@svn.opensuse.org 29 Aug '08
29 Aug '08
Author: aschnell
Date: Fri Aug 29 15:55:06 2008
New Revision: 50487
URL: http://svn.opensuse.org/viewcvs/yast?rev=50487&view=rev
Log:
- refactoring
Modified:
trunk/storage/libstorage/src/Storage.cc
trunk/storage/storage/src/modules/Storage.ycp
Modified: trunk/storage/libstorage/src/Storage.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.c…
==============================================================================
--- trunk/storage/libstorage/src/Storage.cc (original)
+++ trunk/storage/libstorage/src/Storage.cc Fri Aug 29 15:55:06 2008
@@ -4349,18 +4349,17 @@
string Storage::getAllUsedFs() const
- {
- list<FsType> fs;
+{
+ set<FsType> fs;
ConstVolPair p = volPair( Volume::notDeleted );
for( ConstVolIterator v=p.begin(); v!=p.end(); ++v )
{
FsType t = v->getFs();
- if( t!=FSUNKNOWN && t!=FSNONE &&
- find( fs.begin(), fs.end(), t )==fs.end() )
- fs.push_back(t);
+ if (t!=FSUNKNOWN && t!=FSNONE)
+ fs.insert(t);
}
string ret;
- for( list<FsType>::const_iterator i=fs.begin(); i!=fs.end(); ++i )
+ for( set<FsType>::const_iterator i=fs.begin(); i!=fs.end(); ++i )
{
if( !ret.empty() )
ret += ' ';
@@ -4368,7 +4367,8 @@
}
y2mil( "ret:" << ret );
return( ret );
- }
+}
+
bool
Storage::getFsCapabilities (FsType fstype, FsCapabilities& fscapabilities) const
Modified: trunk/storage/storage/src/modules/Storage.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/modules/Stor…
==============================================================================
--- trunk/storage/storage/src/modules/Storage.ycp (original)
+++ trunk/storage/storage/src/modules/Storage.ycp Fri Aug 29 15:55:06 2008
@@ -6386,48 +6386,24 @@
return( ret );
}
+
global string GetUsedFs()
{
if (!InitLibstorage(false))
return nil;
- string r = LibStorage::StorageInterface::getAllUsedFs( sint );
- list<string> lr = sort(splitstring(r," \t"));
- r = mergestring( lr, " " );
- y2milestone( "GetUsedFs ret:%1", r );
- return( r );
+ string r = LibStorage::StorageInterface::getAllUsedFs(sint);
+ y2milestone("GetUsedFs ret:%1", r);
+ return r;
}
-list FindUsedFsLine( map file )
- {
- list ret = [];
- list<list> t = maplist( integer k, map e, file["l"]:$[],
- ``([k, e["line"]:""]));
- t = filter( list e, t, ``(search(e[1]:"","USED_FS_LIST")==0));
- y2milestone( "FindUsedFsLine t:%1", t );
- ret = t[0]:[];
- y2milestone( "FindUsedFsLine ret:%1", ret );
- return( ret );
- }
global void SaveUsedFs()
- {
- y2milestone( "SaveUsedFs" );
- string s = GetUsedFs();
- map file = $[];
- AsciiFile::ReadFile( file, "/etc/sysconfig/storage" );
- list l = FindUsedFsLine( file );
- string e = "USED_FS_LIST=\"" + s + "\"";
- integer lineno = l[0]:(size(file["l"]:$[]) + 1);
- if( size(l)==0 )
- file["l",lineno] = $[];
- if( file["l",lineno,"line"]:""!=e )
- {
- file["l",lineno,"line"] = e;
- file["l",lineno,"changed"] = true;
- AsciiFile::RewriteFile( file, "/etc/sysconfig/storage" );
- }
- }
+{
+ y2milestone("SaveUsedFs");
+ SCR::Write(.sysconfig.storage.USED_FS_LIST, GetUsedFs());
+}
+
global boolean Storage::IsPersistent( map p )
{
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r50486 - in /branches/tmp/lslezak/core: dbus/namespace_service/ liby2dbus/src/
by lslezak@svn.opensuse.org 29 Aug '08
by lslezak@svn.opensuse.org 29 Aug '08
29 Aug '08
Author: lslezak
Date: Fri Aug 29 15:40:09 2008
New Revision: 50486
URL: http://svn.opensuse.org/viewcvs/yast?rev=50486&view=rev
Log:
- created a base class DBusServerBase for all DBus services, moving the
shared code there
Added:
branches/tmp/lslezak/core/liby2dbus/src/DBusArgument.cc
branches/tmp/lslezak/core/liby2dbus/src/DBusArgument.h
branches/tmp/lslezak/core/liby2dbus/src/DBusServerBase.cc
branches/tmp/lslezak/core/liby2dbus/src/DBusServerBase.h
branches/tmp/lslezak/core/liby2dbus/src/DBusSignature.cc
branches/tmp/lslezak/core/liby2dbus/src/DBusSignature.h
Modified:
branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc
branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.h
branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.cc
branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.h
branches/tmp/lslezak/core/liby2dbus/src/Makefile.am
Modified: branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/dbus/namespa…
==============================================================================
--- branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc (original)
+++ branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc Fri Aug 29 15:40:09 2008
@@ -14,36 +14,16 @@
#include <y2/Y2Function.h>
#include <y2/Y2PluginComponent.h>
-#ifdef HAVE_POLKIT
-#include "PolKit.h"
-#endif
-
#include <ycp/y2log.h>
#include <ycp/YCPVoid.h>
#include <ycp/pathsearch.h>
-extern "C"
-{
-// nanosleep()
-#include <time.h>
-// stat()
-#include <sys/stat.h>
-}
-
-// ostringstream
-#include <sstream>
+#include <functional>
-static bool finish = false;
-
-
-DBusModulesServer::DBusModulesServer(const std::string &name_space)
+DBusModulesServer::DBusModulesServer(const std::string &name_space) : e(this)
{
- dbus_threads_init_default();
-
- y2internal("Starting DBus service for namespace %s", name_space.c_str());
-
// create the namespace
- YBlockPtr block = Bytecode::readModule (name_space);
+ YBlockPtr block = Bytecode::readModule(name_space);
if (block == NULL)
{
@@ -85,319 +65,80 @@
{
}
-
-bool DBusModulesServer::connect()
-{
- if (!ns)
- {
- y2milestone("Could not load the namespace, not connecting to DBus");
- return false;
- }
-
- // connect to DBus, request a service name
- return connection.connect(DBUS_BUS_SYSTEM, "org.opensuse.yast.modules");
-}
-
-// set 30 second timer
-void DBusModulesServer::resetTimer()
+void DBusModulesServer::registerFunctions(const std::string &interface_prefix)
{
- ::alarm(30);
-}
-
-// NOTE: this is a signal handler, do only really necessary tasks here!
-// be aware of non-reentrant functions!
-void sig_timer(int signal, siginfo_t *info, void *data)
-{
- if (signal == SIGALRM)
- {
- // set the finish flag for the main loop
- finish = true;
- }
-}
-
-void DBusModulesServer::registerSignalHandler()
-{
- struct sigaction new_action, old_action;
-
- // use sa_sigaction parameter
- new_action.sa_flags = SA_SIGINFO;
- new_action.sa_sigaction = &sig_timer;
- ::sigemptyset(&new_action.sa_mask);
-
- if (::sigaction(SIGALRM, &new_action, &old_action))
- {
- y2error("Cannot register SIGALRM handler!");
- }
-}
-
-bool DBusModulesServer::canFinish()
-{
- // check if clients are still running,
- // remove finished clients
- for(Clients::iterator it = clients.begin();
- it != clients.end();)
+ if (ns)
{
- DBusCaller caller = it->second;
-
- if (!caller.isRunning())
- {
- Clients::iterator remove_it(it);
-
- // move the current iterator
- it++;
-
- y2milestone("Removing client %s (pid %d) from list", (remove_it->first).c_str(), caller.getPid());
-
- clients.erase(remove_it);
- }
- else
- {
- // the process is still running
- // no need to check the other clients
- // we have to still run for at least this client
- y2debug("Client %s PID %d is still running", (it->first).c_str(), caller.getPid());
- break;
- }
- }
-
- // if there is no client the server can be finished
- return clients.size() == 0;
-}
-
-/**
- * Server that exposes a method call and waits for it to be called
- */
-void DBusModulesServer::run(bool forever)
-{
- y2milestone("Listening for incoming DBus messages...");
-
- if (forever)
- y2milestone("Timer disabled");
- else
- registerSignalHandler();
+ unsigned symbols = ns->symbolCount();
+ unsigned index = 0;
- // mainloop
- while (true)
- {
- // the time is over
- if (finish)
+ while(index < symbols)
{
- y2milestone("Timout signal received");
+ SymbolEntryPtr symbol = ns->symbolEntry(index);
- if (canFinish())
- {
- break;
- }
- else
+ if (symbol)
{
- // reset the flag
- finish = false;
-
- // set a new timer
- resetTimer();
- }
- }
-
- // set 1 second timeout
- connection.setTimeout(1000);
- // try reading a message from DBus
- DBusMsg request(connection.receive());
-
- // check if a message was received
- if (request.empty())
- {
- continue;
- }
-
- // reset the timer when a message is received
- if (! forever)
- resetTimer();
-
- // create a reply to the message
- DBusMsg reply;
-
- y2milestone("Received request from %s: interface: %s, method: %s", request.sender().c_str(),
- request.interface().c_str(), request.method().c_str());
-
- // check this is a method call for the right object, interface & method
- if (request.type() == DBUS_MESSAGE_TYPE_METHOD_CALL && request.interface() == "org.opensuse.yast.modules.Methods" && request.path() == "/Modules")
- {
- std::string method(request.method());
+ // name of the method
+ const char *name = symbol->name();
+ // type
+ constTypePtr type = symbol->type();
- YCPValue arg0;
+ if (type->isFunction())
+ {
+ constFunctionTypePtr fptr = constFunctionTypePtr(type);
- bool check_ok = true;
+ constTypePtr rettype = fptr->returnType();
- if (check_ok)
- {
-/*
- YCPValue arg = request.getYCPValue(1);
- YCPValue opt = request.getYCPValue(2);
-*/
- std::string caller(request.sender());
-/*
-#ifdef HAVE_POLKIT
- std::string arg_str, opt_str;
-
- if (!arg.isNull())
- {
- arg_str = arg->toString();
- }
+ DBusSignature sig;
- if (!opt.isNull())
- {
- opt_str = opt->toString();
- }
+ // add return type
+ std::string rett(Y2Dtype(rettype));
- // PolicyKit check
- if (!isActionAllowed(caller, pth->toString(), method, arg_str, opt_str))
- {
- // access denied
- reply.createError(request, "System policy does not allow you to do the action", DBUS_ERROR_ACCESS_DENIED);
- }
- else
-#endif
-*/ {
- y2debug("Request from: %s", caller.c_str());
- // remember the client
- if (clients.find(caller) == clients.end())
+ if (!rett.empty())
{
- DBusCaller c(caller, connection);
- // insert the dbus name and PID
- Clients::value_type new_client(caller, c);
- y2milestone("Added new client %s (pid %d)", caller.c_str(), c.getPid());
- clients.insert(new_client);
+ sig.retval = DBusArgument("ret", rett);
}
- YCPValue ret;
-
- constTypePtr t = searchFuncType(method);
+ // add parameter types
+ int params = fptr->parameterCount();
+ int parindex = 0;
+ DBusSignature::Params p;
- if (t)
+ bool params_ok = true;
+ while(parindex < params)
{
- constFunctionTypePtr fptr = constFunctionTypePtr(t);
- int reqarg = fptr->parameterCount();
+ std::string partype(Y2Dtype(fptr->parameterType(parindex)));
- if (request.arguments() == reqarg)
+ if (!partype.empty())
{
- // create function call
- Y2Function *y2func = ns->createFunctionCall(method.c_str(), t);
-
- if (y2func)
- {
- int index = 0;
-
- while(index < reqarg)
- {
- YCPValue arg = request.getYCPValue(index);
- y2func->appendParameter(arg);
- index ++;
- }
-
- if (y2func->finishParameters())
- {
- // call the function
- ret = y2func->evaluateCall();
- }
- else
- {
- y2error("Wrong parameters to function %s", method.c_str());
- }
- }
+ DBusArgument param("param", partype);
+ p.push_back(param);
}
else
{
- y2error("Function %s got %d parameters instead of %d", method.c_str(), request.arguments(), fptr->parameterCount());
+ y2warning("Function %s is not exported due to an unsupported parameter type", name);
+ params_ok = false;
+ break;
}
+ parindex++;
}
- reply.createReply(request);
-
- if (!ret.isNull())
+ if (params_ok)
{
- y2milestone("Result: %s", ret->toString().c_str());
- reply.addYCPValue(ret);
+ sig.params = p;
+ // register the function: register_function(object, interface, method, signature, handler)
+ register_method(ns->name(), interface_prefix, name, sig, e);
}
- else
- reply.addYCPValue(YCPVoid());
}
}
- }
- // handle Introspection request from "org.freedesktop.DBus.Introspectable" "Introspect"
- else if (request.isMethodCall(DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
- {
- y2milestone("Requesting path: %s", request.path().c_str());
- // define all exported methods here
- std::string introdata = createIntrospectionData();
-
- const char *introspect = (request.path() != "/Modules") ?
-// introcpection data for the root node
-DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
-"<node>"
-" <interface name='org.freedesktop.DBus.Introspectable'>"
-" <method name='Introspect'>"
-" <arg name='xml_data' type='s' direction='out'/>"
-" </method>"
-" </interface>"
-" <node name='Modules'/>"
-"</node>" :
-introdata.c_str();
-
- // create a reply to the request
- reply.createReply(request);
- reply.addString(introspect);
- }
- else if (request.type() == DBUS_MESSAGE_TYPE_METHOD_CALL)
- {
- y2warning("Ignoring unknown interface or method call: interface: %s, method: %s",
- request.interface().c_str(), request.method().c_str());
- // report error
- reply.createError(request, "Unknown object, interface or method", DBUS_ERROR_UNKNOWN_METHOD);
- }
- else if (request.type() == DBUS_MESSAGE_TYPE_ERROR)
- {
- DBusError error;
- dbus_error_init(&error);
-
- dbus_set_error_from_message(&error, request.getMessage());
-
- if (dbus_error_is_set(&error))
- {
- y2error("Received an error: %s: %s", error.name, error.message);
- }
-
- dbus_error_free(&error);
- }
- else if (request.type() == DBUS_MESSAGE_TYPE_SIGNAL)
- {
- y2error("Received a signal: interface: %s method: %s", request.interface().c_str(), request.method().c_str());
- }
-
- // was a reply set?
- if (!reply.empty())
- {
- // send the reply
- if (!connection.send(reply))
- {
- y2error("Cannot send the result");
- }
- else
- {
- y2milestone("Flushing connection...");
- connection.flush();
- y2milestone("...done");
- }
+ index++;
}
-
- y2milestone("Message processed");
}
-
- y2milestone("Finishing the DBus service");
}
-std::string Y2Dtype(constTypePtr type)
+std::string DBusModulesServer::Y2Dtype(constTypePtr type) const
{
YCPValueType vt = type->valueType();
std::string ret;
@@ -411,7 +152,7 @@
case(YT_STRING) : ret = DBUS_TYPE_STRING_AS_STRING; break;
case(YT_PATH) : ret = DBUS_TYPE_STRING_AS_STRING; break;
case(YT_SYMBOL) : ret = DBUS_TYPE_STRING_AS_STRING; break;
- case(YT_LIST) : ret = DBUS_TYPE_ARRAY_AS_STRING; break;
+// case(YT_LIST) : ret = DBUS_TYPE_ARRAY_AS_STRING; break;
default : y2warning("Value type %d is not supported", vt); break;
/*
@@ -435,32 +176,7 @@
return ret;
}
-#ifdef HAVE_POLKIT
-bool DBusModulesServer::isActionAllowed(const std::string &caller, const std::string &path, const std::string &method,
- const std::string &arg, const std::string &opt)
-{
- // create actionId
- static const char *polkit_prefix = "org.opensuse.yast.scr";
- std::string action_id(PolKit::createActionId(polkit_prefix, path, method, arg, opt));
-
- bool ret = false;
-
- // check the policy here
- if (policykit.isDBusUserAuthorized(action_id, caller, connection.getConnection()))
- {
- y2security("User is authorized to do action %s", action_id.c_str());
- ret = true;
- }
- else
- {
- y2security("User is NOT authorized to do action %s", action_id.c_str());
- }
-
- return ret;
-}
-#endif
-
-constTypePtr DBusModulesServer::searchFuncType(const std::string &fname)
+constTypePtr DBusModulesServer::searchFuncType(const std::string &fname) const
{
if (ns)
{
@@ -493,89 +209,70 @@
return NULL;
}
-std::string DBusModulesServer::createIntrospectionData()
+bool DBusModulesServer::connect()
{
- std::string ret(
-DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
-"<node>"
-" <interface name='org.freedesktop.DBus.Introspectable'>"
-" <method name='Introspect'>"
-" <arg name='xml_data' type='s' direction='out'/>"
-" </method>"
-" </interface>"
+ registerFunctions("org.opensuse.yast.modules");
+ return DBusServerBase::connect(SYSTEM, "org.opensuse.yast.modules");
+}
-" <interface name='org.opensuse.yast.modules.Methods'>");
+DBusMsg DBusModulesServer::handler(const DBusMsg &request)
+{
+ YCPValue ret;
+ DBusMsg reply;
- if (ns)
+ std::string method = request.method();
+
+ constTypePtr t = searchFuncType(method);
+
+ if (t)
{
- unsigned symbols = ns->symbolCount();
- unsigned index = 0;
+ constFunctionTypePtr fptr = constFunctionTypePtr(t);
+ int reqarg = fptr->parameterCount();
- while(index < symbols)
+ if (request.arguments() == reqarg)
{
- SymbolEntryPtr symbol = ns->symbolEntry(index);
+ // create function call
+ Y2Function *y2func = ns->createFunctionCall(method.c_str(), t);
- if (symbol)
+ if (y2func)
{
- const char *name = symbol->name();
- constTypePtr type = symbol->type();
+ int index = 0;
- if (type->isFunction())
+ while(index < reqarg)
{
- constFunctionTypePtr fptr = constFunctionTypePtr(type);
-
- constTypePtr rettype = fptr->returnType();
-
- std::string method(" <method name='" + std::string(name) + "'>");
-
- // add return type
- std::string rett(Y2Dtype(rettype));
-
- if (!rett.empty())
- {
- method += " <arg name='ret' type='" + rett + "' direction='out'/>";
- }
-
- // add parameter types
- int params = fptr->parameterCount();
- int parindex = 0;
-
- bool params_ok = true;
- while(parindex < params)
- {
- std::string partype(Y2Dtype(fptr->parameterType(parindex)));
-
- if (!partype.empty())
- {
- method += " <arg name='param' type='" + partype + "' direction='in'/>";
- }
- else
- {
- y2warning("Function %s is not exported due to an unsupported parameter type", name);
- params_ok = false;
- break;
- }
-
- parindex++;
- }
+ YCPValue arg = request.getYCPValue(index);
+ y2func->appendParameter(arg);
+ index ++;
+ }
- if (params_ok)
- {
- method += " </method>";
- ret += method;
- }
+ if (y2func->finishParameters())
+ {
+ // call the function
+ ret = y2func->evaluateCall();
+ }
+ else
+ {
+ y2error("Wrong parameters to function %s", method.c_str());
}
}
-
- index++;
+ }
+ else
+ {
+ y2error("Function %s got %d parameters instead of %d", method.c_str(), request.arguments(), fptr->parameterCount());
}
}
+ else
+ {
+ y2internal("Function %s was not found although it was registered", method.c_str());
+ }
- ret +=
-" </interface>"
-"</node>";
-
- return ret;
-}
+ reply.createReply(request);
+ if (!ret.isNull())
+ {
+ y2milestone("Result: %s", ret->toString().c_str());
+ reply.addYCPValue(ret);
+ }
+ return reply;
+}
Modified: branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/dbus/namespa…
==============================================================================
--- branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.h (original)
+++ branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.h Fri Aug 29 15:40:09 2008
@@ -3,75 +3,57 @@
DBusModulesServer.h
*/
-#ifndef DBUSSERVER_H
-#define DBUSSERVER_H
+#ifndef DBUSMODUELSSERVER_H
+#define DBUSMODULESSERVER_H
#include "config.h"
-#include <dbus/dbus.h>
-
-#include "DBusConn.h"
-#include "DBusCaller.h"
-
-#ifdef HAVE_POLKIT
-#include "PolKit.h"
-#endif
-
-extern "C"
-{
-#include <unistd.h>
-#include <signal.h>
-}
-
-#include <map>
+#include <DBusServerBase.h>
+#include <DBusMsg.h>
#include <ycp/TypePtr.h>
+#include <functional>
+
class Y2Namespace;
-class DBusModulesServer
+class DBusModulesServer : public DBusServerBase
{
public:
DBusModulesServer(const std::string &name_space);
- ~DBusModulesServer();
+ virtual ~DBusModulesServer();
+
+ virtual bool connect();
- bool connect();
- /**
- * Runs the server
- * @param forever for debugging, disables exiting after timeout
- */
- void run(bool forever = false);
private:
- DBusConn connection;
+ // the wrapped Yast namespace
+ Y2Namespace *ns;
-#ifdef HAVE_POLKIT
- PolKit policykit;
- bool isActionAllowed(const std::string &caller, const std::string &path,
- const std::string &method, const std::string &arg, const std::string &opt);
-#endif
+ constTypePtr searchFuncType(const std::string &fname) const;
+ std::string Y2Dtype(constTypePtr type) const;
- // SCR access
- Y2Namespace *ns;
+ // register the functions from the namespace to DBus service
+ void registerFunctions(const std::string &interface_prefix);
+
+ DBusMsg handler(const DBusMsg &request);
+
+ class Callback : public std::function<DBusMsg (const DBusMsg &request)>
+ {
+ DBusModulesServer *ms;
+
+ public:
- // create introspection data for the namespace
- std::string createIntrospectionData();
-
- constTypePtr searchFuncType(const std::string &fname);
-
- // disable copying
- DBusModulesServer(const DBusModulesServer&);
- DBusModulesServer& operator=(const DBusModulesServer&);
-
- void resetTimer();
- void registerSignalHandler();
- bool canFinish();
+ Callback(DBusModulesServer *s) : ms(s) {}
+ ~Callback() {}
- typedef std::map<std::string, DBusCaller> Clients;
+ DBusMsg operator()(const DBusMsg &request)
+ { return ms ? ms->handler(request) : DBusMsg(); }
+ };
- Clients clients;
+ Callback e;
};
Added: branches/tmp/lslezak/core/liby2dbus/src/DBusArgument.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2dbus/sr…
==============================================================================
--- branches/tmp/lslezak/core/liby2dbus/src/DBusArgument.cc (added)
+++ branches/tmp/lslezak/core/liby2dbus/src/DBusArgument.cc Fri Aug 29 15:40:09 2008
@@ -0,0 +1,30 @@
+
+/*
+ class DBusArgument
+*/
+
+#include "DBusArgument.h"
+
+DBusArgument::DBusArgument(const std::string &arg_name, const std::string &arg_signature) : name(arg_name), signature(arg_signature)
+{
+}
+
+DBusArgument::~DBusArgument()
+{
+}
+
+bool DBusArgument::empty() const
+{
+ return signature.empty();
+}
+
+std::string DBusArgument::asXML(bool direction_in) const
+{
+ if (empty())
+ {
+ return std::string();
+ }
+
+ return std::string("<arg name='" + name + "' type='" + signature + "' direction='" + (direction_in ? "in" : "out") + "'/>");
+}
+
Added: branches/tmp/lslezak/core/liby2dbus/src/DBusArgument.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2dbus/sr…
==============================================================================
--- branches/tmp/lslezak/core/liby2dbus/src/DBusArgument.h (added)
+++ branches/tmp/lslezak/core/liby2dbus/src/DBusArgument.h Fri Aug 29 15:40:09 2008
@@ -0,0 +1,28 @@
+
+/*
+ class DBusArgument
+*/
+
+#ifndef DBUSARGUMENT_H
+#define DBUSARGUMENT_H
+
+#include <string>
+
+class DBusArgument
+{
+
+ public:
+
+ DBusArgument(const std::string &arg_name = std::string(), const std::string &arg_signature = std::string());
+ ~DBusArgument();
+
+ bool empty() const;
+
+ // default direction is "in" (input parameter)
+ std::string asXML(bool direction_in = true) const;
+
+ std::string name;
+ std::string signature;
+};
+
+#endif
Modified: branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2dbus/sr…
==============================================================================
--- branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.cc (original)
+++ branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.cc Fri Aug 29 15:40:09 2008
@@ -442,7 +442,7 @@
}
-YCPValue DBusMsg::getYCPValueRaw(DBusMessageIter *it, const std::string &ycp_type)
+YCPValue DBusMsg::getYCPValueRaw(DBusMessageIter *it, const std::string &ycp_type) const
{
YCPValue ret;
@@ -658,7 +658,7 @@
return ret;
}
-YCPValue DBusMsg::getYCPValue(DBusMessageIter *it)
+YCPValue DBusMsg::getYCPValue(DBusMessageIter *it) const
{
int type = dbus_message_iter_get_arg_type(it);
y2debug("Found DBus type: %d (%c)", type, (char)type);
@@ -739,7 +739,7 @@
return (received_nil) ? YCPVoid() : ret;
}
-YCPValue DBusMsg::getYCPValue(int index)
+YCPValue DBusMsg::getYCPValue(int index) const
{
YCPValue ret = YCPNull();
Modified: branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2dbus/sr…
==============================================================================
--- branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.h (original)
+++ branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.h Fri Aug 29 15:40:09 2008
@@ -43,7 +43,7 @@
bool addDouble(double val);
bool addYCPValue(const YCPValue &val);
- YCPValue getYCPValue(int index);
+ YCPValue getYCPValue(int index) const;
bool isMethodCall(const std::string &interface, const std::string &method) const;
int arguments() const;
@@ -70,8 +70,8 @@
int typeInt(const YCPValue &val) const;
const char * typeStr(const YCPValue &val) const;
- YCPValue getYCPValue(DBusMessageIter *it);
- YCPValue getYCPValueRaw(DBusMessageIter *it, const std::string &ycp_type = std::string());
+ YCPValue getYCPValue(DBusMessageIter *it) const;
+ YCPValue getYCPValueRaw(DBusMessageIter *it, const std::string &ycp_type = std::string()) const;
};
#endif
Added: branches/tmp/lslezak/core/liby2dbus/src/DBusServerBase.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2dbus/sr…
==============================================================================
--- branches/tmp/lslezak/core/liby2dbus/src/DBusServerBase.cc (added)
+++ branches/tmp/lslezak/core/liby2dbus/src/DBusServerBase.cc Fri Aug 29 15:40:09 2008
@@ -0,0 +1,475 @@
+
+/*
+
+ DBus server
+
+ */
+
+#include <dbus/dbus.h>
+
+#include "DBusServerBase.h"
+#include "DBusMsg.h"
+
+#include <ycp/y2log.h>
+
+extern "C"
+{
+// nanosleep()
+#include <time.h>
+// stat()
+#include <sys/stat.h>
+#include <unistd.h>
+#include <signal.h>
+}
+
+// ostringstream
+#include <sstream>
+
+// std::pair
+#include <utility>
+
+static bool finish = false;
+
+DBusServerBase::DBusServerBase()
+{
+ dbus_threads_init_default();
+}
+
+DBusServerBase::~DBusServerBase()
+{
+}
+
+
+bool DBusServerBase::connect(DBusType bustype, const std::string &sname)
+{
+ DBusBusType bt = (bustype == SYSTEM) ? DBUS_BUS_SYSTEM : DBUS_BUS_SESSION;
+
+ service_name = sname;
+
+ // connect to DBus, request a service name
+ return connection.connect(bt, service_name.c_str());
+}
+
+// set 30 second timer
+void DBusServerBase::resetTimer()
+{
+ ::alarm(30);
+}
+
+// NOTE: this is a signal handler, do only really necessary tasks here!
+// be aware of non-reentrant functions!
+void sig_timer(int signal, siginfo_t *info, void *data)
+{
+ if (signal == SIGALRM)
+ {
+ // set the finish flag for the main loop
+ finish = true;
+ }
+}
+
+void DBusServerBase::registerSignalHandler()
+{
+ struct sigaction new_action, old_action;
+
+ // use sa_sigaction parameter
+ new_action.sa_flags = SA_SIGINFO;
+ new_action.sa_sigaction = &sig_timer;
+ ::sigemptyset(&new_action.sa_mask);
+
+ if (::sigaction(SIGALRM, &new_action, &old_action))
+ {
+ y2error("Cannot register SIGALRM handler!");
+ }
+}
+
+bool DBusServerBase::canFinish()
+{
+ // check if clients are still running,
+ // remove finished clients
+ for(Clients::iterator it = clients.begin();
+ it != clients.end();)
+ {
+ DBusCaller caller = it->second;
+
+ if (!caller.isRunning())
+ {
+ Clients::iterator remove_it(it);
+
+ // move the current iterator
+ it++;
+
+ y2milestone("Removing client %s (pid %d) from list", (remove_it->first).c_str(), caller.getPid());
+
+ clients.erase(remove_it);
+ }
+ else
+ {
+ // the process is still running
+ // no need to check the other clients
+ // we have to still run for at least this client
+ y2debug("Client %s PID %d is still running", (it->first).c_str(), caller.getPid());
+ break;
+ }
+ }
+
+ // if there is no client the server can be finished
+ return clients.size() == 0;
+}
+
+/**
+ * Server that exposes a method call and waits for it to be called
+ */
+void DBusServerBase::run(bool forever)
+{
+ y2milestone("Listening for incoming DBus messages...");
+
+ if (forever)
+ y2milestone("Timer disabled");
+ else
+ registerSignalHandler();
+
+ // mainloop
+ while (true)
+ {
+ // the time is over
+ if (finish)
+ {
+ y2milestone("Timout signal received");
+
+ if (canFinish())
+ {
+ break;
+ }
+ else
+ {
+ // reset the flag
+ finish = false;
+
+ // set a new timer
+ resetTimer();
+ }
+ }
+
+ // set 1 second timeout
+ connection.setTimeout(1000);
+ // try reading a message from DBus
+ DBusMsg request(connection.receive());
+
+ // check if a message was received
+ if (request.empty())
+ {
+ continue;
+ }
+
+ // reset the timer when a message is received
+ if (! forever)
+ resetTimer();
+
+ // create a reply to the message
+ DBusMsg reply;
+
+ y2milestone("Received request from %s: interface: %s, method: %s", request.sender().c_str(),
+ request.interface().c_str(), request.method().c_str());
+
+ // handle Introspection request from "org.freedesktop.DBus.Introspectable" "Introspect"
+ if (request.isMethodCall(DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
+ {
+ y2milestone("Requesting path: %s", request.path().c_str());
+ std::string introspect;
+
+ // root node?
+ if (request.path() == "/")
+ {
+ introspect =
+ // introcpection data for the root node
+ DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
+ "<node>"
+ " <interface name='org.freedesktop.DBus.Introspectable'>"
+ " <method name='Introspect'>"
+ " <arg name='xml_data' type='s' direction='out'/>"
+ " </method>"
+ " </interface>";
+
+ for(Objects::const_iterator i = registered_objects.begin();
+ i != registered_objects.end();
+ ++i)
+ {
+ introspect += " <node name='" + i->first + "'/>";
+ }
+
+ // close the node section
+ introspect += "</node>";
+ }
+ else
+ {
+ introspect =
+ // introcpection data for the root node
+ DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
+ "<node>"
+ " <interface name='org.freedesktop.DBus.Introspectable'>"
+ " <method name='Introspect'>"
+ " <arg name='xml_data' type='s' direction='out'/>"
+ " </method>"
+ " </interface>";
+
+ std::string objname = request.path();
+
+ // remove the slash at the beginning
+ if (objname.size() > 0 && objname[0] == '/')
+ {
+ objname.erase(objname.begin());
+ }
+
+ // return properties of the registered object only
+ Objects::const_iterator i = registered_objects.find(objname);
+
+ if (i == registered_objects.end())
+ {
+ y2warning("Requested object %s is not registered", objname.c_str());
+ }
+ else
+ {
+ ObjectData od = i->second;
+
+ // iterate over the interfaces
+ for(ObjectData::const_iterator ii = od.begin();
+ ii != od.end();
+ ++ii)
+ {
+ introspect += " <interface name='" + ii->first + "'>";
+
+ InterfaceData id = ii->second;
+
+ // iterate over all methods
+ for(InterfaceData::const_iterator iii = id.begin();
+ iii != id.end();
+ ++iii)
+ {
+ // iterate over the methods in the interface
+ introspect += " <method name='" + iii->first + "'>";
+
+ // iterate over all parameters
+ DBusSignature sig = iii->second.second;
+
+ // add somthing like "<arg name='xml_data' type='s' direction='out'/>"
+ introspect += sig.asXML();
+
+ introspect += " </method>";
+ }
+
+ introspect += " </interface>";
+ }
+
+ }
+ }
+
+ // create a reply to the request
+ reply.createReply(request);
+ reply.addString(introspect.c_str());
+ }
+ else if (request.type() == DBUS_MESSAGE_TYPE_METHOD_CALL)
+ {
+ // TODO check the policy
+
+ // find the registered object
+ std::string objname = request.path();
+
+ // remove the slash at the beginning
+ if (objname.size() > 0 && objname[0] == '/')
+ {
+ objname.erase(objname.begin());
+ }
+
+ // search the object
+ Objects::const_iterator i = registered_objects.find(objname);
+
+ bool found = false;
+
+ if (i != registered_objects.end())
+ {
+ ObjectData::const_iterator ii = i->second.find(request.interface());
+
+ if (ii != i->second.end())
+ {
+ InterfaceData::const_iterator iii = ii->second.find(request.method());
+
+ if (iii != ii->second.end())
+ {
+ MethodData md = iii->second;
+ methodHandler mh = md.first;
+
+ y2milestone("Evaluating method: object %s interface: %s, method: %s",
+ request.path().c_str(), request.interface().c_str(), request.method().c_str());
+
+ // call the registered callback
+ found = true;
+ reply = mh(request);
+ }
+ else
+ {
+ y2warning("Object %s does not provide method %s in interface %s",
+ objname.c_str(), request.path().c_str(), request.interface().c_str());
+ }
+ }
+ else
+ {
+ y2warning("Object %s does not provide interface %s",
+ objname.c_str(), request.interface().c_str());
+ }
+ }
+ else
+ {
+ y2warning("Object %s is not registered", objname.c_str());
+ }
+
+ if (!found)
+ {
+ // report error
+ reply.createError(request, "Unknown object, interface or method", DBUS_ERROR_UNKNOWN_METHOD);
+ }
+ }
+ else if (request.type() == DBUS_MESSAGE_TYPE_ERROR)
+ {
+ DBusError error;
+ dbus_error_init(&error);
+
+ dbus_set_error_from_message(&error, request.getMessage());
+
+ if (dbus_error_is_set(&error))
+ {
+ y2error("Received an error: %s: %s", error.name, error.message);
+ }
+
+ dbus_error_free(&error);
+ }
+ else if (request.type() == DBUS_MESSAGE_TYPE_SIGNAL)
+ {
+ // singals are not supported
+ y2error("Received a signal: interface: %s method: %s", request.interface().c_str(), request.method().c_str());
+ }
+
+ // was a reply set?
+ if (!reply.empty())
+ {
+ // send the reply
+ if (!connection.send(reply))
+ {
+ y2error("Cannot send the result");
+ }
+ else
+ {
+ y2milestone("Flushing connection...");
+ connection.flush();
+ y2milestone("...done");
+ }
+ }
+
+ y2milestone("Message processed");
+ }
+
+ y2milestone("Finishing the DBus service");
+}
+
+void DBusServerBase::register_method(const Object &obj, const Interface &intf, const Method &m, const DBusSignature &sig, methodHandler h)
+{
+ y2milestone("Registering DBus path: object %s interface %s method %s...", obj.c_str(), intf.c_str(), m.c_str());
+ Objects::iterator i = registered_objects.find(obj);
+
+ // create a new data item
+ MethodData md = std::make_pair(h, sig);
+
+ if (i == registered_objects.end())
+ {
+ // create a new object
+ InterfaceData id;
+ id[m] = md;
+
+ ObjectData od;
+ od[intf] = id;
+
+ registered_objects[obj] = od;
+ }
+ else
+ {
+ ObjectData od = i->second;
+
+ // search the interface
+ ObjectData::iterator ii = od.find(intf);
+
+ if (ii == od.end())
+ {
+ // the interface is not registered
+ // create a new object
+ InterfaceData id;
+ id[m] = md;
+
+ od[intf] = id;
+
+ registered_objects[obj] = od;
+ }
+ else
+ {
+ InterfaceData id = ii->second;
+
+ // search the method
+ InterfaceData::iterator iii = id.find(m);
+
+ if (iii == id.end())
+ {
+ // the method is not registered
+ // create a new object
+ id[m] = md;
+
+ od[intf] = id;
+
+ registered_objects[obj] = od;
+ }
+ else
+ {
+ y2warning("Object %s has already registered method %s in interface %s, updating...", obj.c_str(), m.c_str(), intf.c_str());
+
+ // update the registered data
+ id[m] = md;
+
+ od[intf] = id;
+
+ registered_objects[obj] = od;
+ }
+ }
+ }
+}
+
+
+/*
+#ifdef HAVE_POLKIT
+bool DBusServerBase::isActionAllowed(const std::string &caller, const std::string &path, const std::string &method,
+ const std::string &arg, const std::string &opt)
+{
+ // create actionId
+ static const char *polkit_prefix = "org.opensuse.yast.scr";
+ std::string action_id(PolKit::createActionId(polkit_prefix, path, method, arg, opt));
+
+ bool ret = false;
+
+ // check the policy here
+ if (policykit.isDBusUserAuthorized(action_id, caller, connection.getConnection()))
+ {
+ y2security("User is authorized to do action %s", action_id.c_str());
+ ret = true;
+ }
+ else
+ {
+ y2security("User is NOT authorized to do action %s", action_id.c_str());
+ }
+
+ return ret;
+}
+#endif
+*/
+
+
+std::string DBusServerBase::createActionId(const DBusMsg &msg)
+{
+ //TODO FIXME
+ return std::string();
+}
Added: branches/tmp/lslezak/core/liby2dbus/src/DBusServerBase.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2dbus/sr…
==============================================================================
--- branches/tmp/lslezak/core/liby2dbus/src/DBusServerBase.h (added)
+++ branches/tmp/lslezak/core/liby2dbus/src/DBusServerBase.h Fri Aug 29 15:40:09 2008
@@ -0,0 +1,93 @@
+
+/*
+ DBusServerBase.h
+*/
+
+#ifndef DBUSSERVERBASE_H
+#define DBUSSERVERBASE_H
+
+#include "config.h"
+
+extern "C"
+{
+#include <unistd.h>
+#include <signal.h>
+}
+
+#include "DBusConn.h"
+#include "DBusCaller.h"
+#include "DBusSignature.h"
+
+#ifdef HAVE_POLKIT
+#include "PolKit.h"
+#endif
+
+#include <functional>
+
+#include <map>
+
+class DBusServerBase
+{
+ public:
+
+ DBusServerBase();
+ virtual ~DBusServerBase();
+
+ virtual bool connect() = 0;
+
+ /**
+ * Runs the server
+ * @param forever for debugging, disables exiting after timeout
+ */
+ void run(bool forever = false);
+
+
+ protected:
+ enum DBusType{ SESSION, SYSTEM };
+
+ bool connect(DBusType bustype, const std::string &sname);
+
+ typedef std::string Object;
+ typedef std::string Interface;
+ typedef std::string Method;
+
+ typedef std::function<DBusMsg(const DBusMsg &)> methodHandler;
+
+ void register_method(const Object &obj, const Interface &i, const Method &m, const DBusSignature &sig, methodHandler h);
+
+ // create PolicyKit action ID for the received message
+ virtual std::string createActionId(const DBusMsg &msg);
+
+ std::string service_name;
+
+
+ private:
+
+ // disable copying
+ DBusServerBase(const DBusServerBase&);
+ DBusServerBase& operator=(const DBusServerBase&);
+
+ void resetTimer();
+ void registerSignalHandler();
+ bool canFinish();
+
+ typedef std::pair<methodHandler, DBusSignature> MethodData;
+ typedef std::map<Method, MethodData> InterfaceData;
+ typedef std::map<Interface, InterfaceData> ObjectData;
+ typedef std::map<Object, ObjectData> Objects;
+
+ Objects registered_objects;
+
+ typedef std::map<std::string, DBusCaller> Clients;
+ Clients clients;
+
+ DBusConn connection;
+
+#ifdef HAVE_POLKIT
+ PolKit policykit;
+#endif
+
+};
+
+#endif
+
Added: branches/tmp/lslezak/core/liby2dbus/src/DBusSignature.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2dbus/sr…
==============================================================================
--- branches/tmp/lslezak/core/liby2dbus/src/DBusSignature.cc (added)
+++ branches/tmp/lslezak/core/liby2dbus/src/DBusSignature.cc Fri Aug 29 15:40:09 2008
@@ -0,0 +1,32 @@
+
+/*
+ DBusSignature
+ */
+
+#include "DBusSignature.h"
+
+DBusSignature::DBusSignature(const DBusArgument &ret, const Params &pars): params(pars), retval(ret)
+{
+}
+
+DBusSignature::~DBusSignature()
+{
+}
+
+std::string DBusSignature::asXML() const
+{
+ std::string ret;
+
+ // add return value (false = direction is out)
+ ret += retval.asXML(false);
+
+ // add parameters
+ for(Params::const_iterator i = params.begin();
+ i != params.end();
+ ++i)
+ {
+ ret += i->asXML();
+ }
+
+ return ret;
+}
Added: branches/tmp/lslezak/core/liby2dbus/src/DBusSignature.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2dbus/sr…
==============================================================================
--- branches/tmp/lslezak/core/liby2dbus/src/DBusSignature.h (added)
+++ branches/tmp/lslezak/core/liby2dbus/src/DBusSignature.h Fri Aug 29 15:40:09 2008
@@ -0,0 +1,31 @@
+
+/*
+ DBusSignature
+ */
+
+#ifndef DBUSSIGNATURE_H
+#define DBUSSIGNATURE_H
+
+#include <string>
+
+#include "DBusArgument.h"
+#include <list>
+
+class DBusSignature
+{
+ public:
+ typedef std::list<DBusArgument> Params;
+
+ // create void(void) method by default
+ DBusSignature(const DBusArgument &ret = DBusArgument(), const Params &pars = Params());
+ ~DBusSignature();
+
+ std::string asXML() const;
+
+ Params params;
+
+ DBusArgument retval;
+};
+
+#endif
+
Modified: branches/tmp/lslezak/core/liby2dbus/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2dbus/sr…
==============================================================================
--- branches/tmp/lslezak/core/liby2dbus/src/Makefile.am (original)
+++ branches/tmp/lslezak/core/liby2dbus/src/Makefile.am Fri Aug 29 15:40:09 2008
@@ -7,7 +7,9 @@
plugin_LTLIBRARIES = liby2dbus.la
-liby2dbus_la_SOURCES = DBusMsg.cc DBusMsg.h DBusConn.cc DBusConn.h DBusCaller.cc DBusCaller.h
+liby2dbus_la_SOURCES = DBusMsg.cc DBusMsg.h DBusConn.cc DBusConn.h DBusCaller.cc DBusCaller.h \
+ DBusServerBase.cc DBusServerBase.h DBusSignature.cc DBusSignature.h \
+ DBusArgument.cc DBusArgument.h
if HAVE_POLKIT
liby2dbus_la_SOURCES += PolKit.cc PolKit.h
endif
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r50485 - /trunk/storage/storage/src/modules/Storage.ycp
by aschnell@svn.opensuse.org 29 Aug '08
by aschnell@svn.opensuse.org 29 Aug '08
29 Aug '08
Author: aschnell
Date: Fri Aug 29 15:28:46 2008
New Revision: 50485
URL: http://svn.opensuse.org/viewcvs/yast?rev=50485&view=rev
Log:
- internal refactoring
Modified:
trunk/storage/storage/src/modules/Storage.ycp
Modified: trunk/storage/storage/src/modules/Storage.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/modules/Stor…
==============================================================================
--- trunk/storage/storage/src/modules/Storage.ycp (original)
+++ trunk/storage/storage/src/modules/Storage.ycp Fri Aug 29 15:28:46 2008
@@ -4459,76 +4459,49 @@
return( ret );
}
-global define list<string> AddPackageList()
- ``{
+
+global list<string> AddPackageList()
+{
list<string> pl = hw_packages;
- boolean mount_lvm = false;
- boolean need_evms = false;
+
map<string,map> tg = GetTargetMap();
- map<string,map> tt = filter( string k, map e, tg,
- ``(e["type"]:`CT_UNKNOWN==`CT_LVM ));
- boolean have_lvm = size(tt)>0;
- if( have_lvm )
- {
- list<map> part = [];
- foreach( string k, map e, tt,
- ``{
- part = (list<map>)merge( part, e["partitions"]:[]);
- });
- mount_lvm = size(filter( map p, part, ``(size(p["mount"]:"")>0)))>0;
- }
- tt = filter( string k, map e, tg, ``(k=="/dev/evms"||search(k, "/dev/evms/")==0));
- if( size(filter( string k, map e, tg, ``(e["is_container"]:false &&
- search(e["name"]:"","lvm/")!=0 &&
- search(e["name"]:"","lvm2/")!=0)))>0)
- {
- y2milestone( "non lvm evms container" );
- need_evms = true;
- }
- if( !need_evms )
- {
- list<map> part = [];
- foreach( string k, map e, tt,
- ``{
- part = (list<map>)merge( part, e["partitions"]:[]);
- });
- need_evms = size(filter( map p, part, ``(size(p["mount"]:"")>0)))>0;
- }
- y2milestone( "AddPackageList have_lvm %1 mount_lvm %2 need_evms %3",
- have_lvm, mount_lvm, need_evms );
- if( have_lvm && (mount_lvm||!need_evms))
- {
- pl = add( pl, "lvm2" );
- }
- if( need_evms )
- {
- pl = add( pl, "evms" );
- pl = add( pl, "yast2-storage-evms" );
- }
+
+ boolean need_lvm = false;
boolean need_quota = false;
boolean need_crypt = false;
- foreach( string k, map e, tg,
- ``{
+
+ foreach( string k, map e, tg, {
+ if (e["type"]:`CT_UNKNOWN == `CT_LVM)
+ need_lvm = true;
if( size(filter( map p, e["partitions"]:[],
``(FileSystems::HasQuota(p))))>0 )
need_quota = true;
if( size(filter( map p, e["partitions"]:[],
``(p["enc_type"]:`none != `none)))>0 )
need_crypt = true;
- });
+ });
+
+ y2milestone("AddPackageList need lvm:%1 quota:%2 crypt:%3", need_lvm, need_quota, need_crypt);
+
+ if (need_lvm)
+ {
+ pl = add(pl, "lvm2");
+ }
if( need_quota )
- {
+ {
pl = add( pl, "quota" );
- }
+ }
if( need_crypt )
- {
+ {
pl = add( pl, "cryptsetup" );
pl = add( pl, "pam_mount" );
- }
- y2milestone( "AddPackageList ret %1", pl );
- return( pl );
}
+ y2milestone("AddPackageList ret %1", pl);
+ return pl;
+}
+
+
global define list GetForeignPrimary()
``{
list ret = [];
@@ -5646,10 +5619,12 @@
}
}
-global define void FinishInstall()
- ``{
- y2milestone( "FinishInstall initial:%1", Stage::initial() );
+global void FinishInstall()
+{
+ y2milestone("FinishInstall initial:%1", Stage::initial());
+
map<string,map> tg = GetTargetMap();
+
if( Stage::initial() )
{
HandleModulesOnBoot( tg );
@@ -5707,13 +5682,14 @@
}
*/
}
+
boolean need_crypt = false;
boolean need_md = false;
boolean need_lvm = false;
boolean need_dmraid = false;
boolean need_dmmultipath = false;
- foreach( string k, map e, tg,
- ``{
+
+ foreach( string k, map e, tg, {
if( size(filter( map p, e["partitions"]:[],
``(p["enc_type"]:`none != `none)))>0 )
need_crypt = true;
@@ -5725,17 +5701,20 @@
need_dmraid = true;
if( e["type"]:`CT_UNKNOWN==`CT_DMMULTIPATH )
need_dmmultipath = true;
- });
+ });
+
y2milestone( "FinishInstall need crypto:%1 md:%2 lvm:%3 dmraid:%4 dmmultipath:%5",
need_crypt, need_md, need_lvm, need_dmraid, need_dmmultipath );
+
if( need_crypt )
CallInsserv( true, "crypto" );
CallInsserv( need_md, "md" );
CallInsserv( need_lvm, "lvm" );
CallInsserv( need_dmraid, "dmraid" );
// activation of multipath is task of yast2-multipath
- y2milestone( "FinishInstall done" );
- }
+
+ y2milestone("FinishInstall done");
+}
global define map GetEntryForMountpoint( string mp )
``{
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r50484 - in /branches/tmp/visnov/progress: installation/ packager/
by visnov@svn.opensuse.org 29 Aug '08
by visnov@svn.opensuse.org 29 Aug '08
29 Aug '08
Author: visnov
Date: Fri Aug 29 15:19:13 2008
New Revision: 50484
URL: http://svn.opensuse.org/viewcvs/yast?rev=50484&view=rev
Log:
- split SlideShow module to 3:
* Slides - handling of the slide files
* SlideShow - generic functions to handle the widgets of the
installation progress
* PackageSlideShow - package installation specific stuff
- added quite some comments
- sw_single adapted
- some more code adapted for the split
Added:
branches/tmp/visnov/progress/packager/PackageInstallation.ycp
branches/tmp/visnov/progress/packager/PackageSlideShow.ycp
branches/tmp/visnov/progress/packager/Packages.ycp
branches/tmp/visnov/progress/packager/SlideShowCallbacks.ycp
branches/tmp/visnov/progress/packager/Slides.ycp
branches/tmp/visnov/progress/packager/sw_single.ycp
Modified:
branches/tmp/visnov/progress/installation/inst_prepareprogress.ycp
branches/tmp/visnov/progress/packager/SlideShow.ycp
branches/tmp/visnov/progress/packager/inst_rpmcopy.ycp
Modified: branches/tmp/visnov/progress/installation/inst_prepareprogress.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/visnov/progress/installat…
==============================================================================
--- branches/tmp/visnov/progress/installation/inst_prepareprogress.ycp (original)
+++ branches/tmp/visnov/progress/installation/inst_prepareprogress.ycp Fri Aug 29 15:19:13 2008
@@ -18,13 +18,14 @@
import "SlideShow";
import "ImageInstallation";
import "StorageClients";
+ import "PackageSlideShow";
y2milestone("BEGIN of inst_prepareprogress.ycp");
Packages::SlideShowSetUp (Language::language);
- SlideShow::OpenSlideShowDialog();
- SlideShow::InitPkgData(true); // FIXME: this is odd!
+ SlideShow::OpenDialog();
+ PackageSlideShow::InitPkgData(true); // FIXME: this is odd!
ImageInstallation::FillUpImagesDetails();
@@ -46,7 +47,7 @@
"description": _("Installing Packages..."),
// here, we do a hack, because until images are deployed, we cannot determine how many
// packages will be really installed additionally
- "value" : (SlideShow::total_size_to_install - ImageInstallation::TotalSize()) / 1024 , // kilobytes
+ "value" : (PackageSlideShow::total_size_to_install - ImageInstallation::TotalSize()) / 1024 , // kilobytes
"units" : `kb,
],
];
Added: branches/tmp/visnov/progress/packager/PackageInstallation.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/visnov/progress/packager/…
==============================================================================
--- branches/tmp/visnov/progress/packager/PackageInstallation.ycp (added)
+++ branches/tmp/visnov/progress/packager/PackageInstallation.ycp Fri Aug 29 15:19:13 2008
@@ -0,0 +1,237 @@
+/**
+ * Module: PackageInstallation.ycp
+ *
+ * Authors: Gabriele Strattner <gs(a)suse.de>
+ *
+ * $Id: PackageInstallation.ycp 39643 2007-07-24 14:30:33Z lslezak $
+ *
+ */
+
+{
+ module "PackageInstallation";
+ textdomain "packager";
+
+ import "Mode";
+ import "Installation";
+ import "Directory";
+ import "Packages";
+ import "SlideShow";
+ import "PackageSlideShow";
+
+ import "Label";
+
+
+
+ global define any FakePackager( list<list> packages, string inst_source,
+ boolean deleting );
+
+
+ /**
+ * Show a dialog with either the list of failed packages (string a) or
+ * the complete log (string b).
+ */
+ define void ShowFailedPackages (string a, string b)
+ {
+ term rbuttons = `RadioButtonGroup (
+ `VBox (
+ `Left(`RadioButton(`id(`a), `opt(`notify),
+ // button label
+ _("&Show Failed Packages List"), true)),
+ `Left(`RadioButton(`id(`b), `opt(`notify),
+ // button label
+ _("&Show Full Log"), false))
+ )
+ );
+
+ UI::OpenDialog (
+ `opt(`decorated),
+ `VBox(
+ `HSpacing(40),
+ // dialog headline
+ `Left(`Heading(_("Installation of Some Packages Failed"))),
+ rbuttons,
+ `RichText(`id(`text),
+ `opt(`plainText),
+ a),
+ `PushButton (`id(`ok), `opt(`default, `key_F10),
+ Label::OKButton ())
+ )
+ );
+
+ while (true)
+ {
+ symbol ret = (symbol) UI::UserInput ();
+
+ if (ret == `a || ret == `b)
+ {
+ UI::ChangeWidget (`id(`text), `Value, (boolean) UI::QueryWidget (`id(`a), `Value) ? a : b);
+ continue;
+ }
+
+ if (ret == `ok)
+ break;
+ }
+
+ UI::CloseDialog ();
+ }
+
+
+ /**
+ * commitPackages marked for deletion or installation
+ * Return: [ int successful, list failed, list remaining, list srcremaining ]
+ *
+ **/
+ global define list CommitPackages (integer media_number,
+ integer packages_installed)
+ {
+ y2milestone("CommitPackages called: media nr. %1, packages %2", media_number, packages_installed);
+
+ if ( Mode::test () )
+ {
+ FakePackager( [],
+ "suse",
+ false ); // not deleting packages
+ return [];
+ }
+ // install packages from this media
+
+ y2milestone ("CommitPackages (%1,%2): Pkg::TargetGetDU() %3",
+ media_number, packages_installed, Pkg::TargetGetDU());
+
+ list <integer> sources = Pkg::SourceGetCurrent (false);
+ integer source_id = sources[0]:0;
+
+ PackageSlideShow::InitPkgData(false);
+
+ // structure: [ ["source_name", id] ]
+ list< list > src_list = Pkg::PkgMediaNames();
+
+ // get ID of the first repository
+ integer first_source = src_list[0,1]:1;
+
+ y2milestone("ID of the first repository: %1", first_source);
+
+ if (media_number == 0)
+ {
+ PackageSlideShow::SetCurrentCdNo (first_source, 1);
+ }
+ else
+ {
+ PackageSlideShow::SetCurrentCdNo (first_source, media_number);
+ }
+ PackageSlideShow::UpdateAllCdProgress (false);
+ SlideShow::StartTimer();
+
+ boolean do_commit = true;
+ if (media_number != 0)
+ {
+ list<map<string,any> > pkgs = Pkg::ResolvableProperties ("", `package, "");
+ pkgs = filter (map<string,any> p, pkgs, {
+ return p["status"]:nil == `selected;
+ });
+ do_commit = size (pkgs) > 0;
+ }
+
+ list commit_result = [];
+ if (do_commit)
+ {
+ // returns [ int successful, list failed, list remaining, list srcremaining ]
+ y2milestone ("Calling PkgCommit (%1)", media_number);
+ commit_result = Pkg::PkgCommit (media_number);
+
+ SlideShow::StopTimer();
+
+ if (commit_result == nil)
+ {
+ y2error ("Bad media number %1", media_number);
+ return [];
+ }
+ }
+ else
+ {
+ y2milestone ("No package from media %1 left for installation", media_number);
+ }
+
+ // see if installation of some packages failed
+ list<string> errpacks = (list<string>) (commit_result[1]:[]);
+ if (size (errpacks) > 0)
+ {
+ string full_log = (string) SCR::Read (.target.string, Installation::destdir +
+ Directory::logdir + "/y2logRPM");
+ ShowFailedPackages (mergestring (errpacks, "\n"), full_log);
+ list<string> old_failed_packs = [];
+ if ((integer)SCR::Read (.target.size,
+ "/var/lib/YaST2/failed_packages") > 0)
+ {
+ old_failed_packs = (list<string>)
+ SCR::Read (.target.ycp, "/var/lib/YaST2/failed_packages");
+ }
+ SCR::Write (.target.ycp, "/var/lib/YaST2/failed_packages",
+ merge (old_failed_packs, errpacks));
+ }
+
+ return commit_result;
+ };
+
+
+ //
+ // Fake progress bars for Mode::test ()
+ //
+ // NOTE: This is currently completely broken.
+ // -- sh 2003-12-15
+ //
+ global define any FakePackager( list<list> packages, string inst_source,
+ boolean deleting )
+ {
+ integer disk_usage = 20;
+ integer disk_capacity = 10000;
+ any ret = nil;
+ integer number = 0;
+
+ y2debug( "FakePackager - handling %1 packages", size( packages ) );
+
+ foreach( list pac, packages, {
+ //y2debug( "Fake installing %1 from %2", select(pac,0), inst_source );
+
+ string pkg_name = pac[0]:"";
+
+ integer pkg_size = 42*1024;
+ integer bytes_installed = 0;
+
+ if ( pkg_size < 0 )
+ {
+ // pkginfo doesn't know anything about the kernel RPM, so its
+ // size can't be obtained, e.g. pkg_size is -1. To make up for
+ // this, let's assume a negative starting size to keep things
+ // going for a while (this is test_mode only, anyway).
+ bytes_installed = -857 * 1024;
+ }
+
+ while ( bytes_installed < pkg_size && ret != `cancel && ret != `diskfull )
+ {
+ integer percent = ( 100 * bytes_installed ) / pkg_size;
+ // if ( deleting )
+ // {
+ // // Handle deleting packages
+ // }
+ // else
+ // {
+ // // Handle installing packages
+ // }
+ sleep ( 300 ); // millisec
+ bytes_installed = bytes_installed + 300 * 1024;
+ }
+ disk_usage = disk_usage+1;
+ number = number+1;
+
+ } );
+
+ if ( ret == `cancel || ret == `abort ) ret = `cancel;
+ else if ( ret == `diskfull ) ret = `diskfull;
+ else ret = `ok;
+
+ y2debug( "FakePackager returning with %1", ret );
+ return ret;
+ }
+
+}
Added: branches/tmp/visnov/progress/packager/PackageSlideShow.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/visnov/progress/packager/…
==============================================================================
--- branches/tmp/visnov/progress/packager/PackageSlideShow.ycp (added)
+++ branches/tmp/visnov/progress/packager/PackageSlideShow.ycp Fri Aug 29 15:19:13 2008
@@ -0,0 +1,1113 @@
+/**
+ * Module: PackageSlideShow.ycp
+ *
+ * Purpose: Module to access slides from installation repository
+ *
+ * Author: Stefan Hundhammer <sh(a)suse.de>
+ * Stanislav Visnovsky <visnov(a)suse.cz>
+ *
+ */
+{
+ module "PackageSlideShow";
+
+ textdomain "packager";
+
+ import "Slides";
+ import "SlideShow";
+ import "String";
+
+ global list<list<integer> > total_sizes_per_cd_per_src = []; // total sizes per inst-src: [ [42, 43, 44], [12, 13, 14] ]
+ global list<list<integer> > remaining_sizes_per_cd_per_src = []; // remaining sizes
+ global list<list<integer> > remaining_times_per_cd_per_src = []; // remaining times
+ global list<string> inst_src_names = []; // a list of strings identifying each repository
+ global list<list<integer> > total_pkg_count_per_cd_per_src = []; // number of pkgs per inst-src: [ [7, 5, 3], [2, 3, 4] ]
+ global list<list<integer> > remaining_pkg_count_per_cd_per_src = []; // remaining number of pkgs
+ global map<integer,integer> srcid_to_current_src_no = $[];
+ // the string is follwed by a media number, e.g. "Medium 1"
+ global string media_type = _("Medium");
+ global integer total_size_installed = 0;
+ global integer total_size_to_install = 0;
+ global integer min_time_per_cd = 10; // const - minimum time displayed per CD if there is something to install
+ global integer max_time_per_cd = 7200; // const - seconds to cut off predicted time (it's bogus anyway)
+ global integer size_column = 1; // const - column number for remaining size per CD
+ global integer pkg_count_column = 2; // const - column number for remaining number of packages per CD
+ global integer time_column = 3; // const - column number for remaining time per CD
+ global integer current_src_no = -1; // 1..n
+ global integer current_cd_no = -1; // 1..n
+ global integer next_src_no = -1;
+ global integer next_cd_no = -1;
+ global boolean last_cd = false;
+ global integer total_cd_count = 0;
+ global boolean unit_is_seconds = false; // begin with package sizes
+ global integer bytes_per_second = 1;
+ global boolean init_pkg_data_complete = false;
+
+ boolean debug = false; // more debugging info
+ string provide_name = ""; // currently downlaoded package name
+ string provide_size = ""; // currently downlaoded package size
+
+
+/*****************************************************************************/
+/*************** Formatting functions and helpers ***************************/
+/*****************************************************************************/
+
+ /**
+ * Get version info for a package (without build no.)
+ *
+ * @param pkg_name name of the package without path and ".rpm" extension
+ * @return version string
+ **/
+ global string StripReleaseNo( string pkg_name )
+ {
+ integer build_no_pos = findlastof (pkg_name, "-" ); // find trailing build no.
+
+ if ( build_no_pos != nil && build_no_pos > 0 )
+ {
+ // cut off trailing build no.
+ pkg_name = substring( pkg_name , 0, build_no_pos );
+ }
+
+ return pkg_name;
+ }
+
+ /**
+ * Get package file name from path
+ *
+ * @param pkg_name location of the package
+ * @return string package file name
+ **/
+ global string StripPath(string pkg_name)
+ {
+ if (pkg_name == nil)
+ {
+ return nil;
+ }
+
+ integer file_pos = findlastof(pkg_name, "/");
+
+ if (file_pos != nil && file_pos > 0 )
+ {
+ // return just the file name
+ pkg_name = substring(pkg_name, file_pos + 1);
+ }
+
+ return pkg_name;
+ }
+
+
+ /**
+ * set media type "CD" or "DVD"
+ */
+ global void SetMediaType (string new_media_type)
+ {
+ media_type = new_media_type;
+ }
+
+ /**
+ * Sum up all list items
+ **/
+ integer ListSum( list<integer> sizes )
+ {
+ integer sum = 0;
+
+ foreach( integer item, sizes, ``{
+ if ( item != -1 )
+ sum = sum + item;
+ });
+
+ return sum;
+ }
+
+
+ /**
+ * Sum up all positive list items, but cut off individual items at a maximum value.
+ * Negative return values indicate overflow of any individual item at "max_cutoff".
+ * In this case, the real sum is the absolute value of the return value.
+ **/
+ integer ListSumCutOff( list<integer> sizes, integer max_cutoff )
+ {
+ boolean overflow = false;
+ integer sum = 0;
+
+ foreach( integer item, sizes, ``{
+ if ( item > 0 )
+ {
+ if ( item > max_cutoff )
+ {
+ overflow = true;
+ sum = sum + max_cutoff;
+ }
+ else
+ sum = sum + item;
+ }
+ });
+
+ if ( overflow )
+ sum = -sum;
+
+ return sum;
+ }
+
+
+ integer TotalRemainingSize()
+ {
+ return ListSum( flatten( remaining_sizes_per_cd_per_src ) );
+ }
+
+
+ integer TotalRemainingTime()
+ {
+ return ListSumCutOff( flatten( remaining_times_per_cd_per_src ),
+ max_time_per_cd );
+ }
+
+
+ integer TotalRemainingPkgCount()
+ {
+ return ListSum( flatten( remaining_pkg_count_per_cd_per_src ) );
+ }
+
+
+ integer TotalInstalledSize()
+ {
+ return total_size_to_install - TotalRemainingSize();
+ }
+
+
+ /**
+ * Format an integer number as (at least) two digits; use leading zeroes if
+ * necessary.
+ * @return number as two-digit string
+ **/
+ string FormatTwoDigits( integer x )
+ {
+ return x < 10 && x >= 0 ?
+ sformat( "0%1", x ) :
+ sformat( "%1", x );
+ }
+
+
+ /**
+ * Format an integer seconds value with min:sec or hours:min:sec
+ **/
+ string FormatTime( integer seconds )
+ {
+ if ( seconds < 0 )
+ return "";
+
+ if ( seconds < 3600 ) // Less than one hour
+ {
+ return sformat( "%1:%2", FormatTwoDigits( seconds / 60 ), FormatTwoDigits( seconds % 60 ) );
+ }
+ else // More than one hour - we don't hope this will ever happen, but who knows?
+ {
+ integer hours = seconds / 3600;
+ seconds = seconds % 3600;
+ return sformat( "%1:%2:%3", hours, FormatTwoDigits( seconds / 60 ), FormatTwoDigits( seconds % 60 ) );
+ }
+ }
+
+
+ /**
+ * Format an integer seconds value with min:sec or hours:min:sec
+ *
+ * Negative values are interpreted as overflow - ">" is prepended and the
+ * absolute value is used.
+ **/
+ string FormatTimeShowOverflow( integer seconds )
+ {
+ string text = "";
+
+ if ( seconds < 0 ) // Overflow (indicated by negative value)
+ {
+ // When data throughput goes downhill (stalled network connection etc.),
+ // cut off the predicted time at a reasonable maximum.
+ // "%1" is a predefined maximum time.
+
+ text = sformat( _(">%1"), FormatTime( -seconds ) );
+ }
+ else
+ {
+ text = FormatTime( seconds );
+ }
+
+ return text;
+ }
+
+
+ /**
+ * Format number of remaining bytes to be installed as string.
+ * @param remaining bytes remaining, -1 for 'done'
+ * @return string human readable remaining time or byte / kB/ MB size
+ **/
+ string FormatRemainingSize( integer remaining )
+ {
+ if ( remaining < 0 )
+ {
+ // Nothing more to install from this CD (very concise - little space!!)
+ return _("Done.");
+ }
+ if ( remaining == 0 )
+ {
+ return "";
+ }
+
+ return String::FormatSize( remaining );
+ }
+
+
+ /**
+ * Format number of remaining packages to be installed as string.
+ * @param remaining bytes remaining, -1 for 'done'
+ * @return string human readable remaining time or byte / kB/ MB size
+ **/
+ string FormatRemainingCount( integer remaining )
+ {
+ if ( remaining < 0 )
+ {
+ // Nothing more to install from this CD (very concise - little space!!)
+ return _("Done.");
+ }
+ if ( remaining == 0 )
+ {
+ return "";
+ }
+
+ return sformat( "%1", remaining );
+ }
+
+
+ string FormatNextMedia()
+ {
+ string text = "";
+
+ if ( next_src_no >= 0 && next_cd_no >= 0 )
+ {
+ string next_media_name = sformat( "%1 %2 %3",
+ inst_src_names[ next_src_no ]:"",
+ media_type, next_cd_no+1 );
+
+ if ( unit_is_seconds )
+ {
+ // Status line informing about the next CD that will be used
+ // %1: Media type ("CD" / "DVD", ???)
+ // %2: Media name ("SuSE Linux Professional CD 2" )
+ // %3: Time remaining until this media will be needed
+ text = sformat( _("Next %1: %2 -- %3"), media_type, next_media_name,
+ FormatTime( remaining_times_per_cd_per_src[ current_src_no-1, current_cd_no-1 ]: 1) );
+ }
+ else
+ {
+ // Status line informing about the next CD that will be used
+ // %1: Media type ("CD" / "DVD", ???)
+ // %2: Media name ("SuSE Linux Professional CD 2" )
+ text = sformat( _("Next %1: %2"), media_type, next_media_name );
+ }
+ }
+
+ return text;
+ }
+
+/*****************************************************************************/
+/*********************** Computing Helpers **********************************/
+/*****************************************************************************/
+
+
+ /**
+ * Perform sanity check for correct initialzation etc.
+ * @param silent don't complain in log file
+ * @return true if OK, false if any error
+ **/
+ boolean SanityCheck( boolean silent )
+ {
+ return true; // FIXME!
+ if ( ! init_pkg_data_complete )
+ {
+ if ( ! silent )
+ {
+ y2error( "SlideShow::SanityCheck(): Slide show not correctly initialized: " +
+ "SlideShow::InitPkgData() never called!" );
+ }
+ return false;
+ }
+
+ if ( current_src_no < 1 || current_cd_no < 1 )
+ {
+ // nothing to install but something is going to be deleted, so it's OK
+ if (Pkg::IsAnyResolvable(`package, `to_remove))
+ {
+ return true;
+ }
+ else if (!silent)
+ {
+ y2error(-1, "SlideShow::SanityCheck(): Illegal values for current_src (%1) or current_cd (%2)",
+ current_src_no, current_cd_no );
+ y2milestone( "total sizes: %1", total_sizes_per_cd_per_src );
+ }
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Update internal bookkeeping: subtract size of one package from the
+ * global list of remaining sizes per CD
+ **/
+ void SubtractPackageSize( integer pkg_size )
+ {
+ integer remaining = remaining_sizes_per_cd_per_src [ current_src_no-1, current_cd_no-1 ]: 1;
+ remaining = remaining - pkg_size;
+ total_size_installed = total_size_installed + pkg_size;
+
+ if ( remaining <= 0 )
+ {
+ // -1 is the indicator for "done with this CD" - not to be
+ // confused with 0 for "nothing to install from this CD".
+ remaining = -1;
+ }
+
+ remaining_sizes_per_cd_per_src [ current_src_no-1, current_cd_no-1 ] = remaining;
+ remaining_pkg_count_per_cd_per_src [ current_src_no-1, current_cd_no-1 ] =
+ remaining_pkg_count_per_cd_per_src [ current_src_no-1, current_cd_no-1 ]:0 -1;
+
+ if ( unit_is_seconds )
+ {
+ integer seconds = 0;
+
+ if ( remaining > 0 && bytes_per_second > 0 )
+ seconds = remaining / bytes_per_second;
+
+ remaining_times_per_cd_per_src [ current_src_no-1, current_cd_no-1 ] = seconds;
+ }
+
+ if ( debug )
+ y2milestone( "SubtractPackageSize( %1 ) -> %2", pkg_size, remaining_sizes_per_cd_per_src);
+ }
+
+
+ /**
+ * Initialize internal pacakge data, such as remaining package sizes and
+ * times. This may not be called before the pkginfo server is up and
+ * running, so this cannot be reliably done from the constructor in all
+ * cases.
+ * @param force true to force reinitialization
+ **/
+ global void InitPkgData(boolean force)
+ {
+ if ( init_pkg_data_complete && ! force)
+ return;
+
+ // Reinititalize some globals (in case this is a second run)
+ total_size_installed = 0;
+ //total_time_elapsed = 0;
+ //start_time = -1;
+ current_src_no = -1; // 1..n
+ current_cd_no = -1; // 1..n
+ next_src_no = -1;
+ next_cd_no = -1;
+ last_cd = false;
+ unit_is_seconds = false; // begin with package sizes
+ bytes_per_second = 1;
+
+ list< list > src_list = Pkg::PkgMediaNames();
+ inst_src_names = maplist( list src, src_list, ``(src[0]:"CD") );
+
+ y2milestone ("Media names: %1", inst_src_names);
+
+ integer index = 0;
+
+ srcid_to_current_src_no = listmap( list src, src_list, {
+ index = index + 1;
+ return $[src[1]:-1 : index];
+ });
+
+ y2milestone ("Repository mapping information: %1", srcid_to_current_src_no );
+
+ total_sizes_per_cd_per_src = Pkg::PkgMediaSizes();
+ total_pkg_count_per_cd_per_src = Pkg::PkgMediaCount();
+
+
+ total_size_to_install = ListSum( flatten( total_sizes_per_cd_per_src ) );
+ y2milestone("total_size_to_install: %1", total_size_to_install);
+ remaining_sizes_per_cd_per_src = (list<list <integer> >) eval (total_sizes_per_cd_per_src);
+ remaining_pkg_count_per_cd_per_src = (list<list <integer> >) eval (total_pkg_count_per_cd_per_src);
+ total_cd_count = size( flatten( total_sizes_per_cd_per_src ) );
+ init_pkg_data_complete = true;
+
+ y2milestone( "SlideShow::InitPkgData() done; total_sizes_per_cd_per_src: %1", total_sizes_per_cd_per_src );
+ y2milestone( "SlideShow::InitPkgData(): pkg: %1", total_pkg_count_per_cd_per_src );
+
+ // RebuildDialog(true);
+ }
+
+ /**
+ * Try to figure out what media will be needed next
+ * and set next_src_no and next_cd_no accordingly.
+ **/
+ void FindNextMedia()
+ {
+ // Normally we would have to use current_cd_no+1,
+ // but since this uses 1..n and we need 0..n-1
+ // for array subscripts anyway, use it as it is.
+ next_cd_no = current_cd_no;
+ next_src_no = current_src_no-1;
+ last_cd = false;
+
+ while ( next_src_no < size( remaining_sizes_per_cd_per_src ) )
+ {
+ list<integer> remaining_sizes = remaining_sizes_per_cd_per_src[ next_src_no ]: [];
+
+ while ( next_cd_no < size( remaining_sizes ) )
+ {
+ if ( remaining_sizes[ next_cd_no ]:0 > 0 )
+ {
+ if ( debug )
+ y2milestone( "Next media: src: %1 CD: %2", next_src_no, next_cd_no );
+ return;
+ }
+ else
+ {
+ next_cd_no = next_cd_no + 1;
+ }
+ }
+
+ next_src_no = next_src_no + 1;
+ }
+
+ if ( debug )
+ y2milestone( "No next media - all done" );
+
+ next_src_no = -1;
+ next_cd_no = -1;
+ last_cd = true;
+ }
+
+
+ /**
+ * Set the current repository and CD number. Must be called for each CD change.
+ * src_no: 1...n
+ * cd_no: 1...n
+ **/
+ global void SetCurrentCdNo( integer src_no, integer cd_no )
+ {
+ if (cd_no == 0)
+ {
+ y2milestone("medium number 0, using medium number 1");
+ cd_no = 1;
+ }
+
+ y2milestone("SetCurrentCdNo() - src: %1 , CD: %2", src_no, cd_no);
+ current_src_no = srcid_to_current_src_no[src_no]:-1;
+ current_cd_no = cd_no;
+
+ SlideShow::CheckForSlides();
+ FindNextMedia();
+
+ if ( Slides::HaveSlides() && Slides::HaveSlideSupport() )
+ {
+ if ( ! SlideShow::HaveSlideWidget() )
+ {
+ SlideShow::RebuildDialog();
+
+ if ( SlideShow::user_switched_to_details )
+ SlideShow::SwitchToDetailsView();
+ }
+
+ if ( ! SlideShow::user_switched_to_details ) // Don't override explicit user request!
+ {
+ SlideShow::SwitchToSlideView();
+ }
+ }
+ else
+ {
+ if ( ! SlideShow::ShowingDetails() )
+ SlideShow::RebuildDialog();
+ }
+ }
+
+
+
+ /**
+ * Recalculate remaining times per CD based on package sizes remaining
+ * and data rate so far. Recalculation is only done each 'recalc_interval'
+ * seconds unless 'force_recalc' is set to 'true'.
+ *
+ * @param force_recalc force recalculation even if timeout not reached yet
+ * @return true if recalculated, false if not
+ **/
+ boolean RecalcRemainingTimes( boolean force_recalc )
+ {
+ if ( ! force_recalc
+ && time() < SlideShow::next_recalc_time )
+ {
+ // Nothing to do (yet) - simply return
+ return false;
+ }
+
+
+ // Actually do recalculation
+
+ integer elapsed = SlideShow::total_time_elapsed;
+
+ if ( SlideShow::start_time >= 0 )
+ {
+ elapsed = elapsed + time() - SlideShow::start_time;
+ }
+
+ if ( elapsed == 0 )
+ {
+ // Called too early - no calculation possible yet.
+ // This happens regularly during initialization, so an error
+ // message wouldn't be a good idea here.
+
+ return false;
+ }
+
+ // This is the real thing.
+
+ integer real_bytes_per_second = total_size_installed / elapsed;
+
+ // But this turns out to be way to optimistic - RPM gets slower and
+ // slower while installing. So let's add some safety margin to make
+ // sure initial estimates are on the pessimistic side - the
+ // installation being faster than initially estimated will be a
+ // pleasant surprise to the user. Most users don't like it the other
+ // way round.
+ //
+ // The "pessimistic factor" progressively decreases as the installation
+ // proceeds. It begins with about 1.7, i.e. the data transfer rate is
+ // halved to what it looks like initially. It decreases to 1.0 towards
+ // the end.
+
+ float pessimistic_factor = 1.0;
+
+ if ( total_size_to_install > 0 )
+ pessimistic_factor = 1.7 - tofloat( total_size_installed ) / tofloat( total_size_to_install );
+ bytes_per_second = tointeger( tofloat( real_bytes_per_second ) / pessimistic_factor + 0.5 );
+
+ if ( bytes_per_second < 1 )
+ bytes_per_second = 1;
+
+ remaining_times_per_cd_per_src = [];
+
+ // Recalculate remaining times for the individual CDs
+
+ foreach ( list<integer> remaining_sizes_list, remaining_sizes_per_cd_per_src,
+ ``{
+ list<integer> remaining_times_list = [];
+ integer remaining_time = -1;
+
+ foreach ( integer remaining_size, remaining_sizes_list,
+ ``{
+ remaining_time = remaining_size;
+
+ if ( remaining_size > 0 )
+ {
+ remaining_time = remaining_size / bytes_per_second;
+
+ if ( remaining_time < min_time_per_cd )
+ {
+ // It takes at least this long for the CD drive to spin up and
+ // for RPM to do _anything_. Times below this values are
+ // ridiculously unrealistic.
+ remaining_time = min_time_per_cd;
+ }
+ else if ( remaining_time > max_time_per_cd ) // clip off at 2 hours
+ {
+ // When data throughput goes downhill (stalled network connection etc.),
+ // cut off the predicted time at a reasonable maximum.
+ remaining_time = max_time_per_cd;
+ }
+ }
+ remaining_times_list = add( remaining_times_list, remaining_time );
+ });
+
+ remaining_times_per_cd_per_src = add( remaining_times_per_cd_per_src, remaining_times_list );
+ });
+
+
+ // Recalculate slide interval
+
+ if ( Slides::HaveSlides() )
+ {
+ integer slides_remaining = size( Slides::slides ) - SlideShow::current_slide_no - 1;
+
+ if ( slides_remaining > 0 )
+ {
+ // The remaining time for the rest of the slides depends on the
+ // remaining time for the current CD only: This is where the
+ // slide images and texts reside. Normally, only CD1 has slides
+ // at all, i.e. the slide show must be finished when CD1 is
+ // done.
+ //
+ // In addition to that, take elapsed time for current slide
+ // into account so all slides get about the same time.
+
+ integer time_remaining = remaining_times_per_cd_per_src[current_src_no-1, current_cd_no-1]:1 + time() - SlideShow::slide_start_time;
+ SlideShow::slide_interval = time_remaining / slides_remaining;
+ y2debug( "New slide interval: %1 - slides remaining: %2 - remaining time: %3",
+ SlideShow::slide_interval, slides_remaining, time_remaining );
+
+ if ( SlideShow::slide_interval < SlideShow::slide_min_interval )
+ {
+ SlideShow::slide_interval = SlideShow::slide_min_interval;
+ y2debug( "Resetting slide interval to min slide interval: %1", SlideShow::slide_interval );
+ }
+
+ if ( SlideShow::slide_interval > SlideShow::slide_max_interval )
+ {
+ SlideShow::slide_interval = SlideShow::slide_max_interval;
+ y2debug( "Resetting slide interval to max slide interval: %1", SlideShow::slide_interval );
+ }
+ }
+ }
+
+ SlideShow::next_recalc_time = time() + SlideShow::recalc_interval;
+
+ return true;
+ }
+
+ /**
+ * Switch unit to seconds if necessary and recalc everything accordingly.
+ * @return true if just switched from sizes to seconds, false otherwise
+ **/
+ boolean SwitchToSecondsIfNecessary()
+ {
+ if ( unit_is_seconds
+ || time() < SlideShow::start_time + SlideShow::initial_recalc_delay )
+ {
+ return false; // no need to switch
+ }
+
+ RecalcRemainingTimes( true ); // force recalculation
+ unit_is_seconds = true;
+
+ return true; // just switched
+ }
+
+
+
+/*****************************************************************************/
+/****************** Callbacks and progress bars *****************************/
+/*****************************************************************************/
+
+
+
+ /**
+ * Update progress widgets for the current CD: Label and ProgressBar.
+ * Use global statistics variables for that.
+ **/
+ global void UpdateCurrentCdProgress(boolean silent_check)
+ {
+ if ( ! SanityCheck( silent_check ) ) return;
+ if ( ! UI::WidgetExists(`cdStatisticsTable) ) return;
+
+
+ //
+ // Update table entries for current CD
+ //
+
+ integer remaining = remaining_sizes_per_cd_per_src [ current_src_no-1, current_cd_no-1 ]:0;
+ UI::ChangeWidget(`id(`cdStatisticsTable ),
+ `Item( sformat( "cd(%1,%2)", current_src_no-1, current_cd_no-1), size_column ),
+ FormatRemainingSize( remaining ) );
+
+ UI::ChangeWidget(`id(`cdStatisticsTable ),
+ `Item( sformat( "cd(%1,%2)", current_src_no-1, current_cd_no-1), pkg_count_column ),
+ FormatRemainingCount( remaining_pkg_count_per_cd_per_src [ current_src_no-1, current_cd_no-1 ]:0 ) );
+
+ if ( unit_is_seconds )
+ {
+ // Convert 'remaining' from size (bytes) to time (seconds)
+
+ remaining = remaining / bytes_per_second;
+
+ if ( remaining <= 0 )
+ remaining = 0;
+
+ if ( remaining > max_time_per_cd ) // clip off at 2 hours
+ {
+ // When data throughput goes downhill (stalled network connection etc.),
+ // cut off the predicted time at a reasonable maximum.
+ remaining = -max_time_per_cd;
+ }
+
+ UI::ChangeWidget(`id(`cdStatisticsTable ),
+ `Item( sformat( "cd(%1,%2)", current_src_no-1, current_cd_no-1), time_column ),
+ FormatTimeShowOverflow( remaining ) );
+ }
+
+
+ //
+ // Update "total" table entries
+ //
+
+ UI::ChangeWidget(`id( `cdStatisticsTable ),
+ `Item( "total", size_column ),
+ FormatRemainingSize( TotalRemainingSize() ) );
+
+ UI::ChangeWidget(`id( `cdStatisticsTable ),
+ `Item( "total", pkg_count_column ),
+ FormatRemainingCount( TotalRemainingPkgCount() ) );
+
+ if ( unit_is_seconds )
+ {
+ UI::ChangeWidget(`id( `cdStatisticsTable ), `Item( "total", time_column ),
+ FormatTimeShowOverflow( TotalRemainingTime() ) );
+
+ }
+ }
+
+ /**
+ * Update progress widgets
+ **/
+ void UpdateTotalProgress(boolean silent_check)
+ {
+ SlideShow::StageProgress( ( TotalInstalledSize() >> 10 ) * 100 / ( total_size_to_install >> 10 ), nil /*, SlideShow::GetProgressLabel()*/ );
+
+ UpdateCurrentCdProgress(silent_check);
+
+ if ( UI::WidgetExists(`nextMedia ) )
+ {
+ string nextMedia = FormatNextMedia();
+
+ if ( nextMedia != "" || last_cd )
+ {
+ UI::ChangeWidget(`nextMedia, `Value, nextMedia );
+ UI::RecalcLayout();
+ last_cd = false;
+ }
+ }
+ }
+
+
+ /**
+ * Returns a table widget item list for CD statistics
+ **/
+ list<term> CdStatisticsTableItems()
+ {
+ list<term> itemList = [];
+
+ //
+ // Add "Total" item - at the top so it is visible by default even if there are many items
+ //
+
+ {
+ // List column header for total remaining MB and time to install
+ string caption = _("Total");
+ integer remaining = TotalRemainingSize();
+ string rem_size = FormatRemainingSize( remaining );
+ string rem_count = FormatRemainingCount( TotalRemainingPkgCount() );
+ string rem_time = "";
+
+ if ( unit_is_seconds && bytes_per_second > 0 )
+ {
+ rem_time = FormatTimeShowOverflow( TotalRemainingTime() );
+ }
+
+ itemList = add( itemList, SlideShow::TableItem( "total", caption, " " + rem_size, " " + rem_count, " " + rem_time ) );
+ }
+
+
+ //
+ // Now go through all repositories
+ //
+
+ integer src_no = 0;
+
+ foreach ( list<integer> inst_src, remaining_sizes_per_cd_per_src, ``{
+ y2milestone( "src #%1: %2", src_no, inst_src );
+
+ if (ListSum(inst_src) > 0) // Ignore repositories from where there is nothing is to install
+ {
+ // Add heading for this repository
+ itemList = add( itemList, SlideShow::TableItem( sformat( "src(%1)", src_no ),
+ inst_src_names[ src_no ]:"", "", "", "" ) );
+
+ integer cd_no = 0;
+
+ foreach ( integer remaining, inst_src, ``{
+ if ( remaining > 0
+ || ( src_no+1 == current_src_no && cd_no+1 == current_cd_no ) ) // suppress current CD
+ {
+ string caption = sformat( "%1 %2", media_type, cd_no+1 ); // "CD 1" - column #0
+ string rem_size = FormatRemainingSize( remaining ); // column #1
+ string rem_count = FormatRemainingCount( remaining_pkg_count_per_cd_per_src[ src_no, cd_no ]:0 );
+ string rem_time = "";
+
+ if ( unit_is_seconds && bytes_per_second > 0 )
+ {
+ remaining = remaining / bytes_per_second;
+ rem_time = FormatTime( remaining ); // column #2
+
+ if ( remaining > max_time_per_cd ) // clip off at 2 hours
+ {
+ // When data throughput goes downhill (stalled network connection etc.),
+ // cut off the predicted time at a reasonable maximum.
+ // "%1" is a predefined maximum time.
+ rem_time = FormatTimeShowOverflow( -max_time_per_cd );
+ }
+ }
+
+ itemList = add( itemList,
+ SlideShow::TableItem( sformat("cd(%1,%2)", src_no, cd_no ), // ID
+ caption, " " + rem_size, " " + rem_count, " " + rem_time ) );
+ }
+
+ cd_no = cd_no + 1;
+ });
+ }
+
+ src_no = src_no + 1;
+ });
+
+ if ( debug )
+ {
+ y2milestone( "Remaining: %1", remaining_sizes_per_cd_per_src );
+ y2milestone( "CD table item list:\n%1", itemList );
+ }
+
+ return itemList;
+ }
+
+
+
+ /**
+ * Progress display update
+ * This is called via the packager's progress callbacks.
+ *
+ * @param pkg_percent package percentage
+ **/
+ global void UpdateCurrentPackageProgress(integer pkg_percent)
+ {
+ SlideShow::SubProgress( pkg_percent, nil );
+ }
+
+ // update the download rate
+ global void UpdateCurrentPackageRateProgress(integer pkg_percent, integer bps_avg, integer bps_current)
+ {
+ if( ! SlideShow::ShowingDetails() ) return;
+
+ string new_text = nil; // no update of the label
+ if (bps_current > 0)
+ {
+ // do not show the average download rate if the space is limited
+ if (SlideShow::textmode && SlideShow::display_width < 100)
+ {
+ bps_avg = -1;
+ }
+ new_text = String::FormatRateMessage(provide_name + " - %1", bps_avg, bps_current);
+ new_text = sformat(_("Downloading %1 (download size %2)"), new_text, provide_size);
+ }
+
+ SlideShow::SubProgress( pkg_percent, new_text );
+ }
+
+
+ /**
+ * Update progress widgets for all CDs.
+ * Uses global statistics variables.
+ **/
+ global void UpdateAllCdProgress(boolean silent_check)
+ {
+ if ( ! SanityCheck( silent_check ) ) return;
+
+ if ( unit_is_seconds )
+ RecalcRemainingTimes( true ); // force
+
+ SlideShow::UpdateTable( CdStatisticsTableItems() );
+ }
+
+
+ /**
+ * Return a CD's progress bar ID
+ * @param src_no number of the repository (from 0 on)
+ * @param cd_no number of the CD within that repository (from 0 on)
+ **/
+ string CdProgressId( integer src_no, integer cd_no )
+ {
+ return sformat( "Src %1 CD %2", src_no, cd_no );
+ }
+
+
+ /**
+ * package start display update
+ * - this is called at the end of a new package
+ *
+ * @param pkg_name package name
+ * @param deleting Flag: deleting (true) or installing (false) package?
+ **/
+ global void SlideDisplayDone ( string pkg_name,
+ integer pkg_size,
+ boolean deleting )
+ {
+ if ( ! deleting )
+ {
+ SubtractPackageSize( pkg_size );
+
+ if (SwitchToSecondsIfNecessary()
+ || RecalcRemainingTimes( false ) ) // no forced recalculation
+ {
+ y2debug( "Updating progress for all CDs" );
+ UpdateAllCdProgress(false);
+ }
+ else
+ {
+ UpdateCurrentCdProgress(false);
+ }
+
+ UpdateTotalProgress(false);
+
+ } // ! deleting
+
+ }
+
+
+
+ /**
+ * package start display update
+ * - this is called at the beginning of a new package
+ *
+ * @param pkg_name package name
+ * @param pkg_summary package summary (short description)
+ * @param deleting Flag: deleting (true) or installing (false) package?
+ **/
+ global void SlideDisplayStart( string pkg_name,
+ string pkg_summary,
+ integer pkg_size,
+ boolean deleting )
+ {
+ if ( ! SanityCheck( false ) ) return;
+
+ // remove path
+ pkg_name = StripPath(pkg_name);
+
+ // remove release and .rpm suffix
+ // pkg_name = StripReleaseNo( pkg_name ); // bug #154872
+
+ if ( deleting )
+ {
+ pkg_size = -1;
+
+ // This is a kind of misuse of insider knowledge: If there are packages to delete, this
+ // deletion comes first, and only then packages are installed. This, however, greatly
+ // distorts the estimated times based on data throughput so far: While packages are
+ // deleted, throughput is zero, and estimated times rise to infinity (they are cut off
+ // at max_time_per_cd to hide this). So we make sure the time spent deleting packages is
+ // not counted for estimating remaining times - reset the timer.
+ //
+ // Note: This will begin to fail when some day packages are deleted in the middle of the
+ // installaton process.
+
+ SlideShow::ResetTimer();
+ }
+
+ if ( pkg_summary == nil )
+ pkg_summary = "";
+
+ string msg = "";
+
+ if ( deleting )
+ {
+ // Heading for the progress bar for the current package
+ // while it is deleted. "%1" is the package name.
+ msg = sformat( _("Deleting %1"), pkg_name );
+ }
+ else
+ {
+ // package installation - summary text
+ // %1 is RPM name, %2 is installed (unpacked) size (e.g. 6.20MB)
+ msg = sformat( _("%1 (installed size %2)"), pkg_name, String::FormatSize( pkg_size ) );
+ }
+
+
+ //
+ // Update package progress bar
+ //
+ SlideShow::SubProgress( 0, msg );
+
+ // Update global progress bar
+ string rem_string = "";
+ integer tot_rem_t = TotalRemainingTime();
+
+ rem_string = ( unit_is_seconds && bytes_per_second > 0 && tot_rem_t > 0) ?
+ sformat("%1 / %2", FormatRemainingSize(TotalRemainingSize()), FormatTimeShowOverflow(tot_rem_t))
+ : FormatRemainingSize(TotalRemainingSize());
+ SlideShow::SetGlobalProgressLabel( SlideShow::CurrentStageDescription() + sformat(_(" (Remaining: %1)"), rem_string));
+
+ //
+ // Update (user visible) installation log
+ //
+ SlideShow::AppendMessageToInstLog( sformat( _("Installing %1"), msg) );
+
+ //
+ // Update the current slide if applicable
+ //
+ if ( SlideShow::ShowingSlide() )
+ {
+ SlideShow::ChangeSlideIfNecessary();
+ }
+ }
+
+
+ global void SlideGenericProvideStart (string pkg_name, integer sz,
+ string pattern, boolean remote)
+ {
+ if ( ! SanityCheck( false ) ) return;
+ if ( ! SlideShow::ShowingDetails() ) return;
+
+ string provide_msg = "";
+
+ if (remote)
+ {
+ provide_name = pkg_name;
+ provide_size = String::FormatSize(sz);
+
+ provide_msg = sformat(_("Downloading %1 (download size %2)"), provide_name, provide_size);
+ }
+ else
+ {
+ provide_msg = pkg_name;
+ }
+
+ SlideShow::SubProgress( 0, provide_msg );
+
+ //
+ // Update (user visible) installation log
+ // for remote download only
+ //
+
+ if( ! remote ) return;
+
+ y2milestone( "Package '%1' is remote", pkg_name );
+
+ // message in the installatino log, %1 is package name,
+ // %2 is package size
+ SlideShow::AppendMessageToInstLog( sformat (pattern, pkg_name, String::FormatSize (sz)) );
+ }
+
+ global void SlideDeltaApplyStart (string pkg_name) {
+ if ( ! SanityCheck( false ) ) return;
+ if ( ! SlideShow::ShowingDetails() ) return;
+
+ SlideShow::SubProgress( 0, pkg_name );
+
+ SlideShow::AppendMessageToInstLog( sformat (_("Applying delta RPM: %1"), pkg_name) );
+ }
+
+
+ /**
+ * Package providal start
+ */
+ global void SlideProvideStart (string pkg_name, integer sz, boolean remote)
+ {
+ // message in the installatino log, %1 is package name,
+ // %2 is package size
+ SlideGenericProvideStart (pkg_name, sz, _("Downloading %1 (download size %2)"),
+ remote);
+ }
+
+
+
+}
Added: branches/tmp/visnov/progress/packager/Packages.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/visnov/progress/packager/…
==============================================================================
--- branches/tmp/visnov/progress/packager/Packages.ycp (added)
+++ branches/tmp/visnov/progress/packager/Packages.ycp Fri Aug 29 15:19:13 2008
@@ -0,0 +1,1635 @@
+/**
+ * File: Packages.ycp
+ * Package: Package selections
+ * Authors: Anas Nashif <nashif(a)suse.de>
+ *
+ * $Id: Packages.ycp 50074 2008-08-14 12:40:21Z locilka $
+ */
+
+{
+
+module "Packages";
+
+textdomain "packager";
+
+import "AddOnProduct";
+import "WorkflowManager";
+import "Arch";
+import "Directory";
+import "InstURL";
+import "Kernel";
+import "Mode";
+import "Stage";
+import "Linuxrc";
+import "Language";
+import "ProductFeatures";
+import "ProductControl";
+import "Report";
+import "Slides";
+import "SlideShow";
+import "SpaceCalculation";
+import "String";
+import "Popup";
+import "Label";
+import "Wizard";
+import "PackageCallbacks";
+import "Product";
+import "DefaultDesktop";
+import "SourceDialogs";
+import "FileUtils";
+import "PackageCallbacks";
+import "Installation";
+import "URL";
+
+include "packager/load_release_notes.ycp";
+
+/**
+ * Force full proposal routine next run
+ */
+boolean full_repropose = false;
+
+/**
+ * repository has been initialized?
+ */
+boolean init_called = false;
+
+/**
+ * repository initialization is WIP
+ */
+boolean init_in_progress = false;
+
+/**
+ * Error which occurred during repository initialization
+ */
+string init_error = nil;
+
+// cache for the proposed summary
+map cached_proposal = nil;
+// the selection used for the cached proposal
+list<string> cached_proposal_packages = [];
+list<map> cached_proposal_patterns = [];
+list<map> cached_proposal_products = [];
+list<map> cached_proposal_patches = [];
+list<map> cached_proposal_selections = [];
+list<string> cached_proposal_languages = [];
+
+ global boolean install_sources = false; // Installing source packages ?
+ global integer timestamp = 0; // last time of getting the target map
+
+ global string metadir = "/yast-install";
+ global boolean metadir_used = false; // true if meta data and inst-sys is in ramdisk
+
+ global list<integer> theSources = []; // id codes of repositories in priority order
+ global list<string> theSourceDirectories = []; // product directories on repositories
+ global map<integer,integer> theSourceOrder = $[]; // installation order
+
+ string servicepack_metadata = "/servicepack.tar.gz";
+
+ // to remember if warning should occurre if switching base selection
+ global boolean base_selection_modified = false;
+
+ global boolean base_selection_changed = false;
+
+ // Local variables
+
+
+ string choosen_base_selection = "";
+
+ // count of errors during packages solver
+ global integer solve_errors = 0;
+
+ /**
+ * Packages to be selected when proposing the list
+ */
+ list<string> additional_packages = [];
+
+ boolean system_packages_selected = false;
+
+// DefaultDesktop::PrefferedWindowManager
+// global string window_manager = nil;
+
+ global boolean using_patterns = false;
+
+ global string add_on_products_list = nil;
+
+ global string add_on_products_type = nil;
+
+// summary functions
+
+/**
+ * List selected resolvables of specified kind
+ * @param what symbol specifying the kind of resolvables to select
+ * @param format string format string to print summaries in
+ * @return a list of selected resolvables
+ */
+global list<string> ListSelected (symbol what, string format) {
+ if (format == "" || format == nil)
+ format = "%1";
+ list<map<string,any> > selected = Pkg::ResolvableProperties ("", what, "");
+
+ // ignore hidden patterns
+ if (what == `pattern)
+ {
+ selected = filter (map<string,any> r, selected, {
+ return r["user_visible"]:nil == true;
+ });
+
+ // order patterns according to "order" flag
+ selected = sort(map<string,any> x, map<string,any> y, selected,
+ {
+ integer xo = tointeger(x["order"]:"");
+ integer yo = tointeger(y["order"]:"");
+
+ if (xo == nil || yo == nil)
+ {
+ // order is not an integer, compare as strings
+ return x["order"]:"" < y["order"]:"";
+ }
+ else
+ {
+ return xo < yo;
+ }
+ }
+ );
+ }
+
+ selected = filter (map<string,any> r, selected, {
+ return r["status"]:nil == `selected;
+ });
+
+ list<string> ret = maplist (map<string,any> r, selected, {
+ string disp = r["summary"]:r["name"]:"";
+ return sformat (format, disp);
+ });
+ return ret;
+}
+
+/**
+ * Count the total size of packages to be installed
+ * @return string formatted size of packages to be installed
+ */
+global string CountSizeToBeInstalled () {
+ integer sz = 0;
+ list<list<integer> > media_sizes = Pkg::PkgMediaSizes();
+
+ foreach (list<integer> inst_sizes, media_sizes,
+ {
+ foreach (integer inst_size, inst_sizes,
+ {
+ sz = sz + inst_size;
+ }
+ );
+ }
+ );
+
+ y2milestone ("Total size of packages to install %1 (%2kB)", sz, sz / 1024 );
+ return String::FormatSizeWithPrecision (sz, 1, true);
+}
+
+map<integer,integer> SrcMapping()
+{
+ map<integer,integer> srcid_to_current_src_no = $[];
+ integer index = 0;
+
+ list< list > src_list = Pkg::PkgMediaNames();
+ y2debug("source names: %1", src_list);
+
+ srcid_to_current_src_no = listmap( list src, src_list, {
+ index = index + 1;
+ return $[src[1]:-1 : index];
+ });
+
+ y2milestone ("Repository mapping information: %1", srcid_to_current_src_no );
+ return srcid_to_current_src_no;
+}
+
+/**
+ * Count the total size of packages to be installed
+ * @return integer size of packages to be installed (in bytes)
+ */
+global integer CountSizeToBeDownloaded() {
+ integer ret = 0;
+
+ // get list of remote repositories
+ // consider only http(s) and ftp protocols as remote
+
+ // all enabled sources
+ list<integer> repos = Pkg::SourceGetCurrent(true);
+ list<integer> remote_repos = [];
+
+ foreach(integer repo, repos,
+ {
+ string url = Pkg::SourceGeneralData(repo)["url"]:"";
+ string scheme = tolower(URL::Parse(url)["scheme"]:"");
+
+ if (scheme == "http" || scheme == "https" || scheme == "ftp")
+ {
+ y2milestone("Found remote repository %1: %2", repo, url);
+ remote_repos = add(remote_repos, repo);
+ }
+ }
+ );
+
+ // shortcut, no remote repository found
+ if (size(remote_repos) == 0)
+ {
+ y2milestone("No remote repository found");
+ return 0;
+ }
+
+ map<integer,integer> repo_mapping = SrcMapping();
+
+ list<list<integer> > media_sizes = Pkg::PkgMediaPackageSizes();
+ y2debug("Media sizes: %1", media_sizes);
+
+ foreach(integer repoid, remote_repos,
+ {
+ list<integer> repo_media_sizes = media_sizes[(repo_mapping[repoid]:-1) - 1]:[];
+
+ foreach(integer media_size, repo_media_sizes,
+ {
+ ret = ret + media_size;
+ }
+ );
+ }
+ );
+
+ y2milestone("Total size of packages to download: %1 (%2kB)", ret, ret / 1024);
+ return ret;
+}
+
+/**
+ * Return information about suboptimal distribution if relevant
+ * @return string the information string or empty string
+ */
+global string InfoAboutSubOptimalDistribution () {
+ // warn about suboptimal distribution
+ // this depends on the kernel
+ string dp = (string) SCR::Read(.content.DISTPRODUCT);
+ if (dp==nil)
+ dp = "";
+
+ if (ProductFeatures::GetBooleanFeature ("software",
+ "inform_about_suboptimal_distribution") &&
+ Arch::i386 () && issubstring(dp, "DVD"))
+ {
+ string tmp = (string) SCR::Read(.proc.cpuinfo.value."0"."flags");
+ list flags = (size (tmp) > 0) ? splitstring (tmp, " ") : [];
+
+ // this depends on the cpu (lm = long mode)
+ if (contains (flags, "lm"))
+ {
+ // warning text
+ return _("Your computer is a 64-bit x86-64 system. However, you are trying to install a 32-bit distribution.");
+ }
+ }
+ return "";
+}
+
+string SummaryHelp(list<symbol> flags)
+{
+ string ret = "";
+
+ if (contains(flags, `pattern))
+ {
+ // help text for software proposal
+ ret = ret + _("<P>The pattern list states which functionality will be available after installing the system.</P>");
+ }
+
+ if (contains(flags, `size))
+ {
+ ret = ret +
+ // (see bnc#178357 why these numbers)
+ // translators: help text for software proposal
+ _("<P>The propsal contains total size of files which will be installed to the system. However, the system will contain some other files (temporary and working files) so the used space will be slighltly larger than the proposed value. Therefore it is a good idea to have at least 25% (or 300MB) free space before starting the installation.</P>") +
+ // help text for software proposal
+ _("<P>The total size to download is size of packages which will be downloaded from remote (network) repositories. This value is important when the connection is slow or when there is a data limit for downloading.</P>");
+
+ }
+
+ // add a header if the result is not empty
+ if (ret != "")
+ {
+ // help text for software proposal - header
+ ret = _("<P><B>Software Proposal</B></P>") + ret;
+ }
+
+ return ret;
+}
+
+/**
+ * Return the summary output lines
+ * @param flags a list of flags, allowed are `product, `pattern, `selection,
+ * `size, `desktop
+ * @return a list of the output lines
+ */
+global list<string> SummaryOutput (list<symbol> flags) {
+ list<string> output = [ InfoAboutSubOptimalDistribution () ];
+ if (contains (flags, `product))
+ // installation proposal - SW summary, %1 is name of the installed product
+ // (e.g. openSUSE 10.3, SUSE Linux Enterprise ...)
+ output = (list<string>)merge (output, ListSelected (`product, _("Product: %1")));
+ if (contains (flags, `desktop))
+ // installation proposal - SW summary, %1 is name of the selected desktop or system type (e.g. KDE)
+ output = (list<string>)add (output, sformat(_("System Type: %1"), DefaultDesktop::Description ()));
+ if (contains (flags, `pattern))
+ {
+ list<string> patterns = ListSelected (`pattern, "+ %1");
+
+ if (size(patterns) > 0)
+ {
+ output = (list<string>) add (output, _("Patterns:<br>") + mergestring (patterns, "<br>"));
+ }
+ }
+ if (contains (flags, `selection))
+ {
+ list<string> selections = ListSelected (`selection, "+ %1");
+
+ if (size(selections) > 0)
+ {
+ output = (list<string>) add (output, _("Selections:<br>") + mergestring (selections, "<br>"));
+ }
+ }
+ if (contains (flags, `size))
+ {
+ output = (list<string>)add (output,
+ // installation proposal - SW summary, %1 is size of the selected packages (in MB or GB)
+ sformat (_("Size of Packages to Install: %1"),
+ CountSizeToBeInstalled ()));
+
+ // add download size
+ integer download_size = CountSizeToBeDownloaded();
+ if (download_size > 0)
+ {
+ output = (list<string>)add (output,
+ // installation proposal - SW summary, %1 is download size of the selected packages
+ // which will be installed from an ftp or http repository (in MB or GB)
+ sformat (_("Downloading from Remote Repositories: %1"),
+ String::FormatSizeWithPrecision(download_size, 1, true))
+ );
+ }
+ }
+
+ output = filter (string o, output, {
+ return o != "" && o != nil;
+ });
+
+ return output;
+}
+
+/**
+ * Check if selected software fits on the partitions
+ * @param init boolean true if partition sizes have changed
+ * @return boolean true if selected software fits, false otherwise
+ */
+global boolean CheckDiskSize (boolean init) {
+ if (init)
+ {
+ y2milestone ("Resetting space calculation");
+ SpaceCalculation::GetPartitionInfo();
+ }
+ return SpaceCalculation::CheckDiskSize();
+}
+
+/**
+ * Print the installatino proposal summary
+ * @param flags a list of symbols, see above
+ * @param boolean use_cache if true, use previous proposal if possible
+ * @returnu a map proposal summary
+ */
+global map Summary (list<symbol> flags, boolean use_cache) {
+ if (init_error != nil)
+ {
+ return $[
+ "warning" : init_error,
+ "warning_level" : `blocker,
+ ];
+ }
+ map ret = $[];
+
+ if (! CheckDiskSize (! use_cache))
+ {
+ ret = $[
+ "warning" : ProductFeatures::GetFeature ("software","selection_type") == `fixed
+ // summary warning
+ ? _("Not enough disk space.")
+ // summary warning
+ : _("Not enough disk space. Remove some packages in the single selection."),
+ "warning_level" : Mode::update() ? `warning : `blocker,
+ ];
+ }
+ else
+ {
+ // check available free space (less than 25% and less than 750MB) (see bnc#178357)
+ list<map> free_space = SpaceCalculation::CheckDiskFreeSpace(25, 750*1024);
+
+ if (size(free_space) > 0)
+ {
+ string warning = "";
+
+ foreach(map df, free_space,
+ {
+ string partition = df["dir"]:"";
+
+ // add a backslash if it's missing
+ if (partition == "" || substring(partition, 0, 1) != "/")
+ {
+ partition = "/" + partition;
+ }
+
+ integer free_pct = df["free_percent"]:0;
+ integer free_kB = df["free_size"]:0;
+
+ string w = sformat(_("Only %1 (%2%%) free space available on partition %3.<BR>"), String::FormatSize(free_kB*1024), free_pct, partition);
+
+ warning = warning + w;
+ }
+ );
+
+ if (warning != "")
+ {
+ ret["warning"] = warning;
+ ret["warning_level"] = `warning;
+ }
+ }
+ }
+
+ ret["raw_proposal"] = SummaryOutput (flags);
+ ret["help"] = SummaryHelp(flags);
+ return ret;
+}
+
+
+
+
+
+
+// proposal control functions
+
+global void ForceFullRepropose () {
+ full_repropose = true;
+}
+
+global boolean SelectProduct ();
+
+/**
+ * Reset package selection, but keep objects of specified type
+ * @param keep a list of symbols specifying type of objects to be kept
+ */
+global void Reset (list<symbol> keep) {
+ list<map<string,any> > restore = [];
+ foreach (symbol type, keep, {
+ list<map<string,any> > selected = Pkg::ResolvableProperties ("", type, "");
+ foreach (map<string,any> s, selected, {
+ restore = add (restore, $[
+ "type" : type,
+ "name" : s["name"]:""
+ ]);
+ });
+ });
+ Pkg::PkgReset();
+ foreach (map<string,any> res, restore, {
+ Pkg::ResolvableInstall (res["name"]:"", (symbol)(res["type"]:nil));
+ });
+
+ system_packages_selected = false;
+}
+
+/**
+ * Initialize add-on products provided by the repository
+ */
+global void InitializeAddOnProducts() {
+ Packages::SelectProduct ();
+ PackageCallbacks::SetMediaCallbacks();
+
+ // Set the base workflow before adding more AddOnProducts using the add_on_products file
+ // Do not force "base workflow" if there is already any base one stored
+ // bugzilla #269625
+ WorkflowManager::SetBaseWorkflow (false);
+
+ if (Packages::add_on_products_list != nil) {
+ y2milestone ("Found list of add-on products to preselect: %1", Packages::add_on_products_list);
+ AddOnProduct::SetPreselectedAddOnProductsType (Packages::add_on_products_type);
+ AddOnProduct::AddPreselectedAddOnProducts (Packages::add_on_products_list);
+ Packages::add_on_products_list = nil; // do not select them any more
+ }
+}
+
+
+ /*-----------------------------------------------------------------------
+ * LOCALE FUNCTIONS
+ *-----------------------------------------------------------------------*/
+
+ /**
+ * Add a package to list to be selected before proposal
+ * Can be called only before the installation proposal, later doesn't
+ * have any effect
+ * @param package string package to be selected
+ */
+ global void addAdditionalPackage(string package)
+ {
+ additional_packages = add (additional_packages, package);
+ }
+
+ /**
+ * Compute architecture packages
+ * @return list(string)
+ */
+ define list<string> architecturePackages ()
+ {
+ list<string> packages = [];
+
+ // remove unneeded / add needed packages for ppc
+ if (Arch::ppc ())
+ {
+ if (Arch::board_mac ())
+ {
+ packages = add (packages, "mouseemu");
+ }
+
+ if (Arch::board_mac_new ()
+ || Arch::board_mac_old ())
+ {
+ string pmac_board = "";
+ list<map> pmac_compatible = (list<map>) SCR::Read(.probe.cpu);
+ foreach (map pmac_compatible_tmp, pmac_compatible, {
+ pmac_board = pmac_compatible_tmp["system"]:"";
+ });
+
+ // install pbbuttonsd on PowerBooks and iMacs
+ if (issubstring (pmac_board, "PowerBook")
+ || issubstring (pmac_board, "PowerMac2,1")
+ || issubstring (pmac_board, "PowerMac2,2")
+ || issubstring (pmac_board, "PowerMac4,1")
+ || issubstring (pmac_board, "iMac,1"))
+ {
+ packages = add (packages, "pbbuttonsd");
+ packages = add (packages, "powerprefs");
+ }
+ }
+
+ if (Arch::ppc64 () && (Arch::board_chrp () || Arch::board_iseries ()))
+ {
+ packages = add (packages, "iprutils");
+ }
+ }
+
+ if (Arch::ia64 ())
+ {
+ // install fpswa if the firmware has an older version
+ if (SCR::Execute(.target.bash, "/sbin/fpswa_check_version") != 0)
+ {
+ packages = add (packages, "fpswa");
+ }
+ }
+
+ if (Arch::is_xenU())
+ {
+ // xen-tools are required for registration of a Xen VM
+ packages = add (packages, "xen-tools");
+ }
+
+ // add numactl on x86_64 with SMP
+ if (Arch::has_smp () && Arch::x86_64 ())
+ {
+ packages = add (packages, "numactl");
+ packages = add (packages, "irqbalance");
+ }
+
+ return packages;
+ }
+
+
+ /**
+ * graphicPackages ()
+ * Compute graphic (x11) packages
+ * @return list(string) list of rpm packages needed
+ */
+ define list<string> graphicPackages ()
+ {
+ list<string> packages = [];
+
+ // don't setup graphics if running via serial console
+ if (!Linuxrc::serial_console ())
+ {
+ packages = [ "xorg-x11", "xorg-x11-server", "xorg-x11-server-glx",
+ "libusb", "sax2", "sax2-gui", "sax2-ident", "sax2-tools",
+ "sax2-libsax", "sax2-libsax-perl"];
+ }
+
+ y2milestone ("X11 Packages to install: %1", packages);
+ return packages;
+ }
+
+
+ /**
+ * Compute special packages
+ * @return list(string)
+ */
+ define list<string> modePackages ()
+ {
+ list<string> packages = [];
+
+ if (Linuxrc::vnc ())
+ {
+ packages = add (packages, "tightvnc");
+ packages = add (packages, "yast2-qt");
+ packages = add (packages, "xorg-x11");
+ packages = add (packages, "icewm");
+ packages = add (packages, "sax2-tools");
+ }
+
+ if (Linuxrc::display_ip ())
+ {
+ packages = add (packages, "yast2-qt");
+ packages = add (packages, "xorg-x11");
+ packages = add (packages, "fvwm2");
+ packages = add (packages, "sax2-tools");
+ }
+
+ if (Linuxrc::braille ())
+ {
+ packages = add (packages, "sbl");
+ }
+ y2milestone ("Installation mode packages: %1", packages);
+ return packages;
+ }
+
+
+ /**
+ * Compute special java packages
+ * @return list(string)
+ */
+ define list<string> javaPackages ()
+ {
+ if (!Arch::alpha ())
+ return [];
+
+ list<string> packages = [];
+
+ list cpus = (list) SCR::Read (.probe.cpu);
+ string model = cpus[0, "model"]:"EV4";
+ string cputype = substring (model, 2, 1);
+
+ if ((cputype == "6") || (cputype == "7") || (cputype == "8"))
+ {
+ packages = ["cpml_ev6"];
+ }
+ else
+ {
+ packages = ["cpml_ev5"];
+ }
+ return packages;
+ }
+
+
+ /**
+ * Compute board (vendor) dependant packages
+ * @return list(string)
+ */
+ define list<string> boardPackages ()
+ {
+ list<string> packages = [];
+
+ list <map <string, any> > probe = (list <map <string, any> >)SCR::Read (.probe.system);
+ packages = (list<string>)probe[0,"requires"]:[];
+ y2milestone ("Board/Vendor specific packages: %1", packages);
+
+ return packages;
+ }
+
+
+ /**
+ * Compute packages required to access the repository
+ * @return list(string) list of the required packages
+ */
+ list<string> sourceAccessPackages()
+ {
+ // TODO: rather check all registered repositories...
+ list<string> ret = [];
+
+ string instmode = Linuxrc::InstallInf("InstMode");
+ y2milestone("Installation mode: %1", instmode);
+
+ if (instmode == "smb" || instmode == "cifs")
+ {
+ // /sbin/mount.cifs is required to mount a SMB/CIFS share
+ ret = ["cifs-mount"];
+ }
+ else if (instmode == "nfs")
+ {
+ // portmap is required to mount an NFS export
+ ret = ["portmap"];
+ }
+
+ y2milestone("Packages for accessing the repository: %1", ret);
+
+ return ret;
+ }
+
+ /*
+ * Additional kernel packages from control file
+ * @return list<string> Additional Kernel packages
+ */
+ define list<string> ComputeAdditionalKernelPackages ()
+ {
+ string final_kernel = Kernel::GetFinalKernel ();
+ integer pos = findfirstof(final_kernel, "-");
+ string extension = substring(final_kernel, pos, size(final_kernel));
+ list<string> akp = [];
+ if (extension!="")
+ {
+ list<string> kernel_packages = (list<string>)
+ ProductFeatures::GetFeature ("software", "kernel_packages");
+ if (size(kernel_packages) > 0 && kernel_packages != nil)
+ {
+ akp = maplist(string p , kernel_packages, {
+ return (p + "-" + extension);
+ });
+ }
+ }
+ return akp;
+ }
+
+ /*-----------------------------------------------------------------------
+ * GLOBAL FUNCTIONS
+ *-----------------------------------------------------------------------*/
+
+
+global list<string> ComputeSystemPatternList () {
+ list<string> pattern_list = [];
+ // also add the 'laptop' selection if PCMCIA detected
+ if (Arch::is_laptop () || Arch::has_pcmcia ())
+ {
+ foreach (string pat_name, ["laptop", "Laptop"], {
+ list<map<string, any> > pat_list = Pkg::ResolvableProperties (pat_name, `pattern, "");
+ if (size (pat_list) > 0)
+ pattern_list = add (pattern_list, pat_name);
+ });
+ }
+ y2milestone ("System patterns: %1", pattern_list);
+ return pattern_list;
+}
+
+
+ /**
+ * Build and return list of packages which depends on the
+ * the current target system and the preselected packages
+ * (architecture, X11....)
+ * @return list<string> packages
+ */
+ global define list<string> ComputeSystemPackageList ()
+ {
+ list<string> install_list = architecturePackages ();
+
+ install_list = (list<string>) union (install_list, modePackages ());
+
+ // add storage packages if yast2-storage installed
+ list<string> storage_packages = (list<string>)WFM::call("wrapper_storage", ["AddPackageList"]);
+ if (storage_packages == nil)
+ {
+ y2warning("storage_packages is nil, module Storage:: is probably missing");
+ }
+ else
+ {
+ install_list = (list<string>) union (install_list, storage_packages);
+ }
+
+ install_list = (list<string>) union (install_list, additional_packages);
+
+ // Kernel is added in autoinstPackages () if autoinst is enabled
+ if (!Mode::update () || !Mode::autoinst ())
+ {
+ list <string> kernel_pkgs = Kernel::ComputePackages ();
+ list <string> kernel_pkgs_additional = ComputeAdditionalKernelPackages();
+ install_list = (list <string>) union (install_list, kernel_pkgs);
+ if (size(kernel_pkgs_additional) > 0 && kernel_pkgs_additional != nil)
+ {
+ install_list = (list <string>) union (install_list, kernel_pkgs_additional);
+ }
+ }
+
+ if (Pkg::IsSelected("xorg-x11") && Linuxrc::vnc ())
+ {
+ install_list = (list<string>) union (install_list, graphicPackages ());
+ }
+ else
+ {
+ y2milestone ("Not selecting graphic packages");
+ }
+
+ if (Pkg::IsSelected("java"))
+ {
+ install_list = (list<string>) union (install_list, javaPackages ());
+ }
+ else
+ {
+ y2milestone ("Not selecting java packages");
+ }
+
+ install_list = (list<string>) union (install_list, boardPackages ());
+
+ // add packages required to access the repository in the 2nd stage and at run-time
+ install_list = (list<string>) union (install_list, sourceAccessPackages());
+
+ // and the most flexible enhancement for other products
+ // NOTE: not really flexible, because it requires the client
+ // in the instsys, instead use <kernel-packages> in the control file.
+ if (ProductFeatures::GetFeature ("software", "packages_transmogrify") != "")
+ {
+ list<string> tmp_list = (list<string>)
+ WFM::CallFunction (ProductFeatures::GetStringFeature ("software", "packages_transmogrify"),
+ [ install_list ]);
+
+ // Make sure we did not get a nil from calling the client, i.e.
+ // if the client does not exist at all..
+ if (tmp_list != nil)
+ {
+ install_list = tmp_list;
+ }
+ }
+
+ list<string> packages = (list<string>)
+ ProductFeatures::GetFeature ("software", "packages");
+ if (size(packages) > 0 && packages != nil )
+ {
+ y2milestone("Adding packages from control file: %1", packages);
+ install_list = (list<string>) union (install_list, packages);
+ }
+
+ install_list = toset (install_list);
+ y2milestone ("auto-adding packages: %1", install_list);
+ return install_list;
+ }
+
+/**
+ * Check whether content file in the specified repository is the same
+ * as the one in the ramdisk
+ * @param source integer the repository ID to check
+ * @return boolean true if content files match
+ */
+global boolean CheckContentFile (integer source) {
+ y2milestone ("Checking content file");
+ string instmode = Linuxrc::InstallInf("InstMode");
+ if (! (instmode == nil || instmode == "cd" || instmode == "dvd"))
+ {
+ y2milestone ("Installing via network, not checking the content file");
+ return true;
+ }
+ string media_content = Pkg::SourceProvideFile (source, 1, "/content");
+ string media = (string)SCR::Read (.target.string, media_content);
+ string ramdisk = (string)SCR::Read (.target.string, "/content");
+ boolean ret = (media == ramdisk);
+ y2milestone ("Content files are the same: %1", ret);
+ return ret;
+}
+
+/**
+ * Import GPG keys found in the inst-sys
+ */
+void ImportGPGKeys () {
+ map out = (map) SCR::Execute (.target.bash_output, "/bin/ls -d /*.gpg");
+ foreach (string file, splitstring (out["stdout"]:"", "\n"), {
+ if (file != "")
+ Pkg::ImportGPGKey (file, true);
+ });
+}
+
+string UpdateSourceURL (string url) {
+ string ret = "";
+ while (ret == "")
+ {
+
+ string msg = sformat( _("Unable to create repository
+from URL '%1'."), InstURL::HidePassword(url) ) + "\n\n" + _("Details:")
+ + "\n" + Pkg::LastError() + "\n\n" + _("Try again?");
+
+ if (Popup::YesNo (msg))
+ {
+ ret = SourceDialogs::EditPopup (url);
+ }
+ else
+ {
+ // error in proposal, %1 is URL
+ init_error = sformat (_("No repository found at '%1'."),
+ InstURL::HidePassword (url));
+ return "";
+ }
+ }
+ return ret;
+}
+
+list<string> LocaleVersions (string lang) {
+ list<string> ret = [ lang ];
+ list<string> components = splitstring (lang, ".");
+ if (components[0]:"" != lang && components[0]:"" != "")
+ {
+ lang = components[0]:"";
+ ret = add (ret, lang);
+ }
+ components = splitstring (lang, "_");
+ if (components[0]:"" != lang && components[0]:"" != "")
+ {
+ lang = components[0]:"";
+ ret = add (ret, lang);
+ }
+ return ret;
+}
+
+string ContentFileProductLabel () {
+ string language = Language::language;
+ list<string> locales = LocaleVersions (Language::language);
+ string ret = "";
+ foreach (string loc, locales, {
+ if (ret == "")
+ {
+ string val = (string)SCR::Read (add (.content, "LABEL." + loc));
+ if (val != "" && val != nil)
+ {
+ ret = val;
+ return ret;
+ }
+ }
+ });
+ return (string)SCR::Read (.content.LABEL);
+}
+
+integer base_source_id = nil;
+
+boolean FindAndCopySlideDir (string our_slidedir, integer source, string search_for_dir,
+ string lang_long, string lang_short, string fallback_lang) {
+ // directory used as a source of texts
+ string providedir = nil;
+
+ // one of the localizations (long or short)
+ string used_loc_dir = "";
+
+ foreach (string try_this_lang, [lang_long, lang_short, fallback_lang], {
+ if (try_this_lang == nil || try_this_lang == "")
+ return;
+
+ string test_dir = sformat ("%1/txt/%2", search_for_dir, try_this_lang);
+ y2milestone ("Checking '%1'", test_dir);
+ providedir = Pkg::SourceProvideDirectory (source, 1, test_dir, true, true);
+
+ if (providedir != nil) {
+ y2milestone ("%1 lang found", try_this_lang);
+ used_loc_dir = try_this_lang;
+ // don't check for other langs
+ break;
+ }
+ });
+
+ // no wanted localization found
+ if (providedir == nil) {
+ y2milestone ("Neither %1 nor %2 localization found", lang_long, lang_short);
+ return false;
+ }
+
+ // where texts are stored later
+ string loc_slidedir = sformat ("%1/txt/%2/", our_slidedir, used_loc_dir);
+ WFM::Execute (.local.bash, sformat ("mkdir -p '%1'", String::Quote (loc_slidedir)));
+
+ // copy all files to our own cache
+ y2milestone ("Copying %1/* to %2", providedir, String::Quote (loc_slidedir));
+ WFM::Execute (.local.bash, sformat ("cp -r %1/* '%2'", providedir, String::Quote (loc_slidedir)));
+
+ // where images are stored
+ string imagesdir = sformat ("%1/pic", search_for_dir);
+
+ imagesdir = Pkg::SourceProvideDirectory (source, 1, imagesdir, true, true);
+
+ if (imagesdir != nil) {
+ // where images should be cached
+ string our_imagesdir = sformat ("%1/pic/", our_slidedir);
+ WFM::Execute (.local.bash, sformat ("mkdir -p '%1'", String::Quote (our_imagesdir)));
+
+ y2milestone ("Copying %1/* to '%2'", imagesdir, String::Quote (our_imagesdir));
+ WFM::Execute (.local.bash, sformat ("cp -r %1/* '%2'", imagesdir, String::Quote (our_imagesdir)));
+ } else {
+ y2error ("No such dir: %1", imagesdir);
+ }
+
+ return true;
+}
+
+boolean FindAndCopySlideDirWithoutCallbacks(string our_slidedir, integer source, string search_for_dir,
+ string lang_long, string lang_short, string fallback_lang)
+{
+ // disable callbacks
+ PackageCallbacks::RegisterEmptyProgressCallbacks();
+
+ boolean ret = FindAndCopySlideDir (our_slidedir, source, search_for_dir, lang_long, lang_short, fallback_lang);
+
+ // restore callbacks
+ PackageCallbacks::RestorePreviousProgressCallbacks();
+
+ return ret;
+}
+
+global void SlideShowSetUp (string wanted_language) {
+ integer source = base_source_id;
+
+ string lang_long = "";
+ string lang_short = "";
+
+ // de_DE.UTF-8 -> de_DE
+ // es_ES -> es_ES
+ // blah -> ""
+ if (wanted_language != nil && wanted_language != "") {
+ y2milestone ("Selected language: %1", wanted_language);
+
+ if (regexpmatch (wanted_language, "^.+_.+$")) {
+ lang_long = wanted_language;
+ } else if (wanted_language != nil && wanted_language != "" && regexpmatch (wanted_language, "^.+_.+\..*$")) {
+ lang_long = regexpsub (wanted_language, "^(.+)_(.+)\..*", "\\1_\\2");
+ }
+
+ if (lang_long != nil && lang_long != "" && regexpmatch (lang_long, ".*_.*")) {
+ lang_short = regexpsub (lang_long, "(.*)_.*", "\\1");
+ } else if (wanted_language != nil && wanted_language != "") {
+ lang_short = wanted_language;
+ }
+
+ y2milestone ("Slide Show lang_long: %1, lang_short: %2", lang_long, lang_short);
+ } else {
+ y2error ("Wrong language definition: %1", wanted_language);
+ }
+
+ // setup slidedir
+ map productmap = Pkg::SourceProductData (source);
+ string datadir = productmap["datadir"]:"suse";
+
+ // target slideshow directory
+ string our_slidedir = sformat ("%1/slidedir/", (string) WFM::Read (.local.tmpdir, ""));
+ WFM::Execute (.local.bash, sformat ("mkdir -p '%1'", our_slidedir));
+
+ // media directory
+ // bugzilla #305097
+ //
+ // bugzilla #326327
+ // try to download only slides that are needed (by selected language)
+ // no images are cached
+ string search_for_dir = sformat ("/%1/setup/slide/", datadir);
+ FindAndCopySlideDirWithoutCallbacks(our_slidedir, source, search_for_dir, lang_long, lang_short, Slides::fallback_lang);
+
+ // fallback solution disabled
+/*
+ if (success != true) {
+ y2milestone ("Using fallback solution, language is not supported");
+ string fallback_slidedir = Pkg::SourceProvideDirectory (source, 1, search_for_dir, true, true);
+
+ if (fallback_slidedir == nil) {
+ y2milestone ("No slide directory '%1' found in repository '%2'.",
+ search_for_dir, source);
+ } else {
+ // copy all files to our own cache
+ y2milestone ("Copying %1/* to %2/", fallback_slidedir, String::Quote (our_slidedir));
+ WFM::Execute (.local.bash, sformat ("cp -r %1/* '%2/'", fallback_slidedir, String::Quote (our_slidedir)));
+ }
+ }
+*/
+
+ y2milestone ("Setting up the slide directory local copy: %1", our_slidedir);
+ Slides::SetSlideDir (our_slidedir);
+
+ if (load_release_notes (source))
+ {
+ // TRANSLATORS: beginning of the rich text with the release notes
+ SlideShow::relnotes = _("<p><b>These are the release notes made for the first initial release. They are
+part of the installation media. During the configuration steps, if a connection
+to the Internet is available, you can download updated release notes
+from the SUSE Linux Web server.</b></p>") + media_text;
+ }
+}
+
+integer IntegrateServicePack (boolean show_popup, string base_url) {
+ /* Check for Service Pack */
+ boolean servicepack_available = false;
+ if ((integer)WFM::Read(.local.size, servicepack_metadata) > 0)
+ {
+ y2milestone("Service Pack data available");
+ boolean popup_open = false;
+ if (show_popup)
+ {
+ UI::OpenDialog(`opt(`decorated ),
+ // popup - information label
+ `Label(_("Integrating booted media...")));
+ popup_open = true;
+ }
+ string spdir = metadir + "/Service-Pack/CD1";
+ WFM::Execute (.local.mkdir, spdir);
+ y2milestone ("Filling %1", spdir);
+ WFM::Execute(.local.bash, "tar -zxvf " +
+ servicepack_metadata + " -C " + spdir);
+ string sp_url = "dir:" + spdir;
+ // close the popup in order to be able to ask about the license
+ if (popup_open)
+ {
+ popup_open = false;
+ UI::CloseDialog ();
+ }
+ integer sp_source = Pkg::SourceCreate (sp_url, "");
+ if (sp_source == -1)
+ {
+ Report::Error (_("Failed to integrate the service pack repository."));
+ return nil;
+ }
+ if (! AddOnProduct::AcceptedLicenseAndInfoFile(sp_source))
+ {
+ y2milestone ("service pack license rejected");
+ Pkg::SourceDelete (sp_source);
+ return nil;
+ }
+ if (FileUtils::Exists (spdir + "/installation.xml"))
+ {
+ WorkflowManager::AddWorkflow (`addon, sp_source, "");
+ WorkflowManager::MergeWorkflows();
+ }
+ if (FileUtils::Exists (spdir + "/y2update.tgz"))
+ {
+ AddOnProduct::UpdateInstSys (spdir + "/y2update.tgz");
+ }
+ theSources = add (theSources, sp_source);
+ y2internal ("Service pack repository: %1, changing to URL: %2",
+ sp_source, base_url);
+ Pkg::SourceChangeUrl (sp_source, base_url);
+ }
+}
+
+boolean Initialize_BaseInit (boolean show_popup, string & base_url, string & log_url) {
+ boolean popup_open = false;
+ if (show_popup)
+ {
+ UI::OpenDialog(`opt(`decorated ),
+ // popup - information label
+ `Label(_("Initializing repositories...")));
+ popup_open = true;
+ }
+
+ PackageCallbacks::InitPackageCallbacks ();
+
+ // Initialize package manager
+ init_error = nil;
+ y2milestone ("Packages::Initialize()");
+
+ if (Mode::test ())
+ {
+ // Fake values for testing purposes
+ base_url = "dir:///dist/next-i386";
+ }
+ else
+ {
+ base_url = InstURL::installInf2Url ("");
+ }
+
+ // hide password from URL if present
+ log_url = InstURL::HidePassword(base_url);
+ y2milestone ("Initialize Package Manager: %1", log_url);
+
+ // Set languages for packagemanager. Always set the UI language. Set
+ // language for additional packages only in Stage::initial ().
+ Pkg::SetTextLocale (Language::language);
+
+ if (popup_open)
+ {
+ UI::CloseDialog ();
+ popup_open = false;
+ }
+
+ return true;
+}
+
+global void Initialize_StageInitial (boolean show_popup, string base_url, string log_url) {
+ integer initial_source = nil;
+ ImportGPGKeys ();
+ while (initial_source == nil)
+ {
+ initial_source = Pkg::SourceCreateBase (base_url, "");
+ if (initial_source == -1 || initial_source == nil)
+ {
+ y2error ("No repository in '%1'", log_url);
+ base_url = UpdateSourceURL (base_url);
+ if (base_url != "")
+ {
+ initial_source = nil;
+ }
+ else
+ {
+ init_in_progress = false;
+ return;
+ }
+ }
+ if (! CheckContentFile (initial_source))
+ {
+ string label = ContentFileProductLabel ();
+ // bug #159754, release the mounted CD
+ Pkg::SourceReleaseAll();
+ Pkg::SourceDelete (initial_source);
+ initial_source = nil;
+ if (! Popup::ContinueCancel (
+ // message popup, %1 is product name
+ sformat (_("Insert %1 CD 1"), label)))
+ {
+ init_error = sformat (_("%1 CD 1 not found"), label);
+ init_in_progress = false;
+ return;
+ }
+ }
+ }
+
+ base_source_id = initial_source;
+ y2milestone ("Base source ID: %1", base_source_id);
+
+ // Set the product before setting up add-on products
+ // In the autoyast mode it could be that the proposal
+ // screen will not be displayed. So the product will
+ // not be set. Bug 178831
+ SelectProduct ();
+
+ theSources = [ initial_source ];
+ integer sp_source = IntegrateServicePack (show_popup, base_url);
+ if (sp_source != nil)
+ theSources = add (theSources, sp_source);
+
+ if (ProductFeatures::GetFeature ("software", "selection_type") == `fixed)
+ {
+ Pkg::SetSelection (ProductFeatures::GetStringFeature ("software", "base_selection"));
+ }
+
+ string tmp_add_on_products = nil;
+ add_on_products_list = nil;
+
+ // #303675: Support several AddOns on standard SLE medium
+ // at first, try to find XML configuration
+ // then as a fallback/backward compatibility the old plain configuration
+ foreach (list <string> one_aop, [["/add_on_products.xml", "xml"], ["/add_on_products", "plain"]], {
+ string file = one_aop[0]:"";
+ string type = one_aop[1]:"";
+
+ tmp_add_on_products = Pkg::SourceProvideOptionalFile (initial_source, 1, file);
+
+ if (tmp_add_on_products != nil) {
+ add_on_products_list = sformat ("%1/add_on_products", SCR::Read (.target.tmpdir));
+ WFM::Execute (.local.bash, sformat ("cp %1 %2", tmp_add_on_products, add_on_products_list));
+ add_on_products_type = type;
+ y2milestone ("Found add_on_products %1 type %2", tmp_add_on_products, type);
+ break;
+ }
+ });
+}
+
+global void Initialize_StageNonInitial (boolean show_popup, string base_url, string log_url) {
+ if (theSources == nil || size (theSources) <= 0)
+ {
+ y2error ("Pkg::SourceStartCache failed");
+ theSources = [];
+ }
+ else if ( Stage::cont () // rewrite URL if cd/dvd since ide-scsi might have changed it
+ && ((substring (base_url, 0, 2) == "cd")
+ || (substring (base_url, 0, 3) == "dvd")))
+ {
+ foreach (integer source, theSources, {
+ map data = Pkg::SourceGeneralData (source); // get repository data
+ string url = data["url"]:"";
+ if ((substring (url, 0, 2) == "cd") // repository comes from cd/dvd
+ || (substring (url, 0, 3) == "dvd"))
+ {
+ string new_url = InstURL::RewriteCDUrl(url);
+ y2milestone ("rewrite url: '%1'->'%2'", url, InstURL::HidePassword(new_url));
+ Pkg::SourceChangeUrl (source, new_url);
+ }
+ });
+ }
+}
+
+// lock some packages if needed
+void LockPackages()
+{
+ // currently there is no need to lock any package...
+}
+
+/**
+ * Initialize the repositories
+ * @param show_popup boolean true to display information about initialization
+ */
+global void Initialize(boolean show_popup) {
+ if (init_called || init_in_progress)
+ {
+ y2warning ("Packages::Initialize() already called");
+ return;
+ }
+
+ init_in_progress = true;
+
+ // usual mountpoint for the medium
+ string base_url = "";
+ // url with hidden password for logging purpose
+ string log_url = "";
+
+ Initialize_BaseInit (show_popup, base_url, log_url);
+
+ theSources = Stage::initial() ? [] : Pkg::SourceStartCache (true); // dummy in 1st stage
+
+ boolean again = true;
+
+ while (again)
+ {
+ if (Stage::initial ())
+ {
+ Initialize_StageInitial (show_popup, base_url, log_url);
+ }
+ else // cont or normal mode
+ {
+ Initialize_StageNonInitial (show_popup, base_url, log_url);
+ }
+
+ y2milestone ("theSources %1", theSources);
+ y2milestone ("theSourceDirectories %1", theSourceDirectories);
+
+ if (size (theSources) >= 0)
+ {
+ init_called = true;
+ again = false;
+ }
+ else
+ {
+ // an error message
+ string errortext = sformat (_("Error while initializing package descriptions.
+Check the log file %1 for more details."), Directory::logdir + "/y2log") +
+ "\n" + Pkg::LastError();
+
+ // FIXME somewhere get correct current_label and wanted_label
+ string result = PackageCallbacks::MediaChange ("NO_ERROR", errortext, base_url, "",
+ 0, "", 1, "", false, [], 0);
+ }
+ }
+
+ // FATE #302123
+ AddOnProduct::SetBaseProductURL (base_url);
+
+ LockPackages();
+
+ init_in_progress = false;
+}
+
+global void Init(boolean unused) {
+ Initialize (true);
+}
+
+/**
+ * Select the base product on the media for installation
+ * @return boolean true on success
+ */
+global boolean SelectProduct () {
+ Packages::Initialize (true);
+ list<map<string,any> > products = Pkg::ResolvableProperties ("", `product, "");
+
+ if (size (products) == 0)
+ {
+ y2milestone ("No product found on media");
+ return true;
+ }
+
+ list<map<string,any> >selected_products = filter (map<string,any> p, products, {
+ return p["status"]:nil == `selected;
+ });
+ // no product selected -> select them all
+ boolean ret = true;
+ if (size (selected_products) == 0)
+ {
+ y2milestone ("No product selected so far...");
+ foreach (map<string,any> p, products, {
+ y2milestone ("Selecting product %1", p["name"]:"");
+ ret = Pkg::ResolvableInstall (p["name"]:"", `product) && ret;
+ });
+ }
+
+ return ret;
+}
+
+/**
+ * Select system patterns
+ * @param reselect boolean true to select only those which are alrady selected
+ */
+void SelectSystemPatterns (boolean reselect) {
+ list<string> system_patterns = ComputeSystemPatternList ();
+ // autoinstallation has patterns specified in the profile
+ if (! Mode::autoinst ())
+ {
+ system_patterns = (list<string>)
+ merge (system_patterns, DefaultDesktop::PatternsToSelect ());
+ system_patterns = (list<string>)
+ toset (merge (system_patterns, Product::patterns));
+ }
+ if (! reselect)
+ {
+ list<string> to_deselect = DefaultDesktop::PatternsToDeselect ();
+ y2milestone ("Deselecting system patterns %1", to_deselect);
+ foreach (string p, to_deselect, {
+ Pkg::ResolvableRemove (p, `pattern);
+ });
+ y2milestone ("Selecting system patterns %1", system_patterns);
+ foreach (string p, system_patterns, {
+ Pkg::ResolvableInstall (p, `pattern);
+ });
+ }
+ else
+ {
+ y2milestone ("Re-selecting system patterns %1", system_patterns);
+ list<string>pats = filter (string p, system_patterns, {
+ list<map<string,any> > descrs = Pkg::ResolvableProperties (p, `pattern, "");
+ descrs = filter (map<string,any> descr, descrs, {
+ return descr["status"]:nil == `selected;
+ });
+ return size (descrs) > 0;
+ });
+ y2milestone ("Selected patterns to be reselected: %1", pats);
+ foreach (string p, pats, {
+ Pkg::ResolvableRemove (p, `pattern);
+ Pkg::ResolvableInstall (p, `pattern);
+ });
+ }
+}
+
+/**
+ * Select system packages
+ * @param reselect boolean true to select only those which are alrady selected
+ */
+void SelectSystemPackages (boolean reselect) {
+ list<string> system_packages = ComputeSystemPackageList();
+ if (! reselect)
+ {
+ y2milestone ("Selecting system packages %1", system_packages);
+ }
+ else
+ {
+ y2milestone ("Re-selecting new versions of system packages %1", system_packages);
+ // first deselect the package (and filter selected ones)
+ system_packages = filter (string p, system_packages, {
+ if (Pkg::IsProvided (p) || Pkg::IsSelected (p))
+ {
+ Pkg::PkgDelete (p);
+ return true;
+ }
+ return false;
+ });
+ y2milestone ("System packages to be reselected: %1", system_packages);
+ }
+ map <string, any> res = Pkg::DoProvide (system_packages);
+ if (size (res) > 0)
+ {
+ foreach (string s, any a, res, {
+ y2warning ("Pkg::DoProvide failed for %1: %2", s, a);
+ });
+ }
+}
+
+/**
+ * Make a proposal for package selection
+ * @param force reset
+ * @param re-initialize
+ * @return map for the API proposal
+ */
+global map Proposal (boolean force_reset, boolean reinit, boolean simple) {
+
+ // if the cache is valid and reset or reinitialization is not required
+ // then the cached proposal can be used
+ if (cached_proposal != nil && force_reset == false && reinit == false)
+ {
+ // selected packages
+ list<string> selected_packages = Pkg::GetPackages(`selected, false);
+
+ // selected patterns
+ list<map> selected_patterns = filter(map p, Pkg::ResolvableProperties("", `pattern, ""), {return p["status"]:`unknown == `selected;});
+
+ // selected products
+ list<map> selected_products = filter(map p, Pkg::ResolvableProperties("", `product, ""), {return p["status"]:`unknown == `selected;});
+
+ // selected patches
+ list<map> selected_patches = filter(map p, Pkg::ResolvableProperties("", `patch, ""), {return p["status"]:`unknown == `selected;});
+
+ // selected selections
+ list<map> selected_selections = filter(map s, Pkg::ResolvableProperties("", `selection, ""), {return s["status"]:`unknown == `selected;});
+
+ // selected languages
+ list<string> selected_languages = (list<string>)union([Pkg::GetPackageLocale()], Pkg::GetAdditionalLocales());
+
+
+ // if the package selection has not been changed the cache is up to date
+ if (selected_packages == cached_proposal_packages && selected_patterns == cached_proposal_patterns
+ && selected_products == cached_proposal_products && selected_patches == cached_proposal_patches
+ && selected_selections == cached_proposal_selections && selected_languages == cached_proposal_languages)
+ {
+ y2milestone("using cached software proposal");
+ return cached_proposal;
+ }
+ else
+ {
+ y2milestone("invalid cache: the software selection has been chaged");
+ }
+ }
+ else
+ {
+ y2milestone("the cached proposal is empty or reset is required");
+ }
+
+ UI::OpenDialog(`opt(`decorated ),
+ // popup label
+ `Label (_("Evaluating package selection...")));
+
+ y2milestone ("Packages::Proposal: force_reset %1, reinit %2, lang '%3'",
+ force_reset, reinit, Language::language);
+
+ if ( force_reset )
+ {
+ Kernel::ProbeKernel();
+ Packages::Reset ([`product]);
+ reinit = true;
+ LockPackages();
+ }
+
+ boolean initial_run = reinit || ! init_called;
+ Initialize (true);
+
+ if (init_error != nil)
+ {
+ UI::CloseDialog();
+ return Summary ([], false);
+ }
+
+ if (initial_run)
+ {
+ // autoyast can configure AdditionalLocales
+ // we don't want to overwrite this
+ if( ! Mode::autoinst ())
+ {
+ Pkg::SetAdditionalLocales ([Language::language]);
+ }
+ }
+
+ SelectProduct ();
+
+ if (ProductFeatures::GetFeature ("software", "selection_type") == `auto)
+ {
+ y2milestone ("Doing pattern-based software selection");
+
+ SelectSystemPackages (system_packages_selected && ! initial_run);
+ SelectSystemPatterns (system_packages_selected && ! initial_run);
+ system_packages_selected = true;
+ Pkg::PkgFreshen();
+ }
+ else if (ProductFeatures::GetFeature ("software","selection_type") == `fixed)
+ {
+ y2milestone ("Selection type: fixed");
+ }
+ else
+ {
+ y2error ("unknown value %1 for ProductFeatures::GetFeature (software, selection_type)",
+ (symbol)ProductFeatures::GetFeature ("software", "selection_type"));
+ }
+
+ if (! Pkg::PkgSolve (false))
+ {
+ solve_errors = Pkg::PkgSolveErrors ();
+ }
+
+ map ret = Summary (
+ [ `product, `pattern, `selection, `size, `desktop ],
+ false);
+ // TODO simple proposal
+
+ // cache the proposal
+ cached_proposal = ret;
+
+ // remember the status
+ cached_proposal_packages = Pkg::GetPackages(`selected, false);
+ cached_proposal_patterns = filter(map p, Pkg::ResolvableProperties("", `pattern, ""), {return p["status"]:`unknown == `selected;});
+ cached_proposal_products = filter(map p, Pkg::ResolvableProperties("", `product, ""), {return p["status"]:`unknown == `selected;});
+ cached_proposal_patches = filter(map p, Pkg::ResolvableProperties("", `patch, ""), {return p["status"]:`unknown == `selected;});
+ cached_proposal_selections = filter(map s, Pkg::ResolvableProperties("", `selection, ""), {return s["status"]:`unknown == `selected;});
+ cached_proposal_languages = (list<string>)union([Pkg::GetPackageLocale()], Pkg::GetAdditionalLocales());
+
+ UI::CloseDialog();
+
+ y2milestone ("Software proposal: %1", ret);
+
+ return ret;
+}
+
+/**
+ * Initialize the repositories with popup feedback
+ * Use Packages::Initialize (true) instead
+ */
+global void InitializeCatalogs() {
+ Packages::Initialize (true);
+}
+
+global boolean InitFailed () {
+ boolean ret = init_error != nil;
+ y2milestone ("Package manager initialization failed: %1", ret);
+ return ret;
+}
+
+/* EOF */
+}
Modified: branches/tmp/visnov/progress/packager/SlideShow.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/visnov/progress/packager/…
==============================================================================
--- branches/tmp/visnov/progress/packager/SlideShow.ycp (original)
+++ branches/tmp/visnov/progress/packager/SlideShow.ycp Fri Aug 29 15:19:13 2008
@@ -1,9 +1,10 @@
/**
* Module: SlideShow.ycp
*
- * Purpose: Slide show during package installation
+ * Purpose: Slide show during installation
*
* Author: Stefan Hundhammer <sh(a)suse.de>
+ * Stanislav Visnovsky <visnov(a)suse.cz>
*
* $Id: SlideShow.ycp 47606 2008-05-16 10:36:24Z lslezak $
*
@@ -22,50 +23,20 @@
import "FileUtils";
import "Mode";
import "Popup";
+ import "Slides";
- global list<list<integer> > total_sizes_per_cd_per_src = []; // total sizes per inst-src: [ [42, 43, 44], [12, 13, 14] ]
- global list<list<integer> > remaining_sizes_per_cd_per_src = []; // remaining sizes
- global list<list<integer> > remaining_times_per_cd_per_src = []; // remaining times
- global list<string> inst_src_names = []; // a list of strings identifying each repository
- global list<list<integer> > total_pkg_count_per_cd_per_src = []; // number of pkgs per inst-src: [ [7, 5, 3], [2, 3, 4] ]
- global list<list<integer> > remaining_pkg_count_per_cd_per_src = []; // remaining number of pkgs
- global map<integer,integer> srcid_to_current_src_no = $[];
- // the string is follwed by a media number, e.g. "Medium 1"
- global string media_type = _("Medium");
- global integer total_size_installed = 0;
- global integer total_size_to_install = 0;
global integer total_time_elapsed = 0;
global integer start_time = -1;
global integer initial_recalc_delay = 60; // const - seconds before initially calculating remaining times
global integer recalc_interval = 30; // const - seconds between "remaining time" recalculations
- global integer min_time_per_cd = 10; // const - minimum time displayed per CD if there is something to install
- global integer max_time_per_cd = 7200; // const - seconds to cut off predicted time (it's bogus anyway)
- global integer size_column = 1; // const - column number for remaining size per CD
- global integer pkg_count_column = 2; // const - column number for remaining number of packages per CD
- global integer time_column = 3; // const - column number for remaining time per CD
global integer next_recalc_time = time();
- global integer current_src_no = -1; // 1..n
- global integer current_cd_no = -1; // 1..n
- global integer next_src_no = -1;
- global integer next_cd_no = -1;
- global boolean last_cd = false;
- global integer total_cd_count = 0;
- global boolean unit_is_seconds = false; // begin with package sizes
- global integer bytes_per_second = 1;
global integer current_slide_no = 0;
global integer slide_start_time = 0;
global integer slide_min_interval = 30; // const - minimum seconds between slide changes
global integer slide_max_interval = 3*60; // const - maximum seconds between slide changes
- global string slide_base_path = Installation::sourcedir + "/suse/setup/slide";
-
- global string slide_txt_path = "";
- global string slide_pic_path = "";
- global string fallback_lang = "en";
global integer slide_interval = slide_min_interval;
- global list<string> slides = [];
global string language = Language::language;
- global boolean init_pkg_data_complete = false;
global boolean widgets_created = false;
global boolean user_switched_to_details = false;
global boolean opened_own_wizard = false;
@@ -79,22 +50,31 @@
string sub_progress_label = _("Installing...");
integer total_progress_value = 0;
integer sub_progress_value =0;
+ list<term> table_items = [];
boolean _show_table = false;
// properties of the current UI
- boolean textmode = UI::GetDisplayInfo()["TextMode"]:false;
- integer display_width = UI::GetDisplayInfo()["Width"]:0;
+ global boolean textmode = UI::GetDisplayInfo()["TextMode"]:false;
+ global integer display_width = UI::GetDisplayInfo()["Width"]:0;
global string relnotes = nil;
- void ChangeSlideIfNecessary(); // forward declaration
+ global void ChangeSlideIfNecessary(); // forward declaration
+ /**
+ * Set the flag that user requested abort of the installation
+ * @param abort new state of the abort requested flag (true = abort requested)
+ */
global void SetUserAbort(boolean abort)
{
user_abort = abort;
}
+ /**
+ * Get the status of the flag that user requested abort of the installation
+ * @return boolean state of the abort requested flag (true = abort requested)
+ */
global boolean GetUserAbort()
{
return user_abort;
@@ -142,7 +122,7 @@
* Check if currently the "Details" page is shown
* @return true if showing details, false otherwise
**/
- boolean ShowingDetails()
+ global boolean ShowingDetails()
{
return widgets_created && UI::WidgetExists(`detailsPage );
}
@@ -152,7 +132,7 @@
* Check if currently the "Slide Show" page is shown
* @return true if showing details, false otherwise
**/
- boolean ShowingSlide()
+ global boolean ShowingSlide()
{
return widgets_created && UI::WidgetExists(`slideShowPage );
}
@@ -161,12 +141,16 @@
* Check if currently the "Release Notes" page is shown
* @return true if showing details, false otherwise
**/
- boolean ShowingRelNotes()
+ global boolean ShowingRelNotes()
{
return widgets_created && UI::WidgetExists(`relNotesPage);
}
- // start a new subprogress
+ /**
+ * Restart the subprogress of the slideshow. This means the
+ * label will be set to \param text, value to 0.
+ * @param text new label for the subprogress
+ */
global void SubProgressStart(string text)
{
if ( UI::WidgetExists(`progressCurrentPackage ) )
@@ -178,7 +162,13 @@
sub_progress_label = text;
}
- // update the subprogress widget
+ /**
+ * Update status of subprogress of the slideshow. The new value will be set
+ * to \param value, if the \text is not nil, the label will be updated
+ * to this text as well. Otherwise label will not change.
+ * @param value new value for the subprogress
+ * @param text new label for the subprogress
+ */
global void SubProgress(integer value, string text)
{
if( UI::WidgetExists( `progressCurrentPackage ) )
@@ -193,7 +183,11 @@
sub_progress_label = text;
}
- // start a new global progress
+ /**
+ * Restart the global progress of the slideshow. This means the
+ * label will be set to \param text, value to 0.
+ * @param text new label for the global progress
+ */
global void GlobalProgressStart(string text)
{
total_progress_label = text;
@@ -207,7 +201,13 @@
total_progress_value = 0;
}
- // update the global progress widget
+ /**
+ * Update status of global progress of the slideshow. The new value will be set
+ * to \param value, if the \text is not nil, the label will be updated
+ * to this text as well. Otherwise label will not change.
+ * @param value new value for the global progress
+ * @param text new label for the global progress
+ */
void UpdateGlobalProgress(integer value, string new_text)
{
if( new_text != nil)
@@ -217,1103 +217,154 @@
if ( UI::WidgetExists(`progressTotal ) )
{
UI::ChangeWidget(`progressTotal, `Value, value);
- if( new_text != nil )
- UI::ChangeWidget(`progressTotal, `Label, new_text );
- }
- else
- y2milestone( "progressTotal widget missing" );
-
- // update slide
- if( ShowingSlide() )
- {
- ChangeSlideIfNecessary();
- }
- }
-
- map<string, map<string,any> > _stages = $[];
- map<string, any> _current_stage = nil;
-
- global void MoveToStage( string stage_name )
- {
- if( ! haskey( _stages, stage_name ) )
- {
- y2error( "Unknown progress stage \"%1\"", stage_name );
- return;
- }
-
- _current_stage = _stages[stage_name]:nil;
-
- y2milestone( "Moving to stage %1 (%2)", stage_name, _stages[stage_name, "start"]:0 );
- // translators: default global progress bar label
- UpdateGlobalProgress( _stages[stage_name, "start"]:0, _current_stage["description"]:_("Installing...") );
- }
-
- global void StageProgress( integer value, string text )
- {
- UpdateGlobalProgress( _current_stage["start"]:0 + (value * _current_stage["size"]:1 / 100), text );
- }
-
- /**
- * Append message to the installation log
- */
- global void AppendMessageToInstLog (string msg)
- {
- string log_line = "\n" + msg;
- inst_log = inst_log + log_line;
-
- if ( ShowingDetails() )
- {
- if ( UI::WidgetExists( `instLog ) )
- UI::ChangeWidget(`instLog, `LastLine, log_line );
- }
- }
-
- /**
- * Sum up all list items
- **/
- integer ListSum( list<integer> sizes )
- {
- integer sum = 0;
-
- foreach( integer item, sizes, ``{
- if ( item != -1 )
- sum = sum + item;
- });
-
- return sum;
- }
-
-
- /**
- * Sum up all positive list items, but cut off individual items at a maximum value.
- * Negative return values indicate overflow of any individual item at "max_cutoff".
- * In this case, the real sum is the absolute value of the return value.
- **/
- integer ListSumCutOff( list<integer> sizes, integer max_cutoff )
- {
- boolean overflow = false;
- integer sum = 0;
-
- foreach( integer item, sizes, ``{
- if ( item > 0 )
- {
- if ( item > max_cutoff )
- {
- overflow = true;
- sum = sum + max_cutoff;
- }
- else
- sum = sum + item;
- }
- });
-
- if ( overflow )
- sum = -sum;
-
- return sum;
- }
-
-
- integer TotalRemainingSize()
- {
- return ListSum( flatten( remaining_sizes_per_cd_per_src ) );
- }
-
-
- integer TotalRemainingTime()
- {
- return ListSumCutOff( flatten( remaining_times_per_cd_per_src ),
- max_time_per_cd );
- }
-
-
- integer TotalRemainingPkgCount()
- {
- return ListSum( flatten( remaining_pkg_count_per_cd_per_src ) );
- }
-
-
- integer TotalInstalledSize()
- {
- return total_size_to_install - TotalRemainingSize();
- }
-
-
- /**
- * Format an integer number as (at least) two digits; use leading zeroes if
- * necessary.
- * @return number as two-digit string
- **/
- string FormatTwoDigits( integer x )
- {
- return x < 10 && x >= 0 ?
- sformat( "0%1", x ) :
- sformat( "%1", x );
- }
-
-
- /**
- * Format an integer seconds value with min:sec or hours:min:sec
- **/
- string FormatTime( integer seconds )
- {
- if ( seconds < 0 )
- return "";
-
- if ( seconds < 3600 ) // Less than one hour
- {
- return sformat( "%1:%2", FormatTwoDigits( seconds / 60 ), FormatTwoDigits( seconds % 60 ) );
- }
- else // More than one hour - we don't hope this will ever happen, but who knows?
- {
- integer hours = seconds / 3600;
- seconds = seconds % 3600;
- return sformat( "%1:%2:%3", hours, FormatTwoDigits( seconds / 60 ), FormatTwoDigits( seconds % 60 ) );
- }
- }
-
-
- /**
- * Format an integer seconds value with min:sec or hours:min:sec
- *
- * Negative values are interpreted as overflow - ">" is prepended and the
- * absolute value is used.
- **/
- string FormatTimeShowOverflow( integer seconds )
- {
- string text = "";
-
- if ( seconds < 0 ) // Overflow (indicated by negative value)
- {
- // When data throughput goes downhill (stalled network connection etc.),
- // cut off the predicted time at a reasonable maximum.
- // "%1" is a predefined maximum time.
-
- text = sformat( _(">%1"), FormatTime( -seconds ) );
- }
- else
- {
- text = FormatTime( seconds );
- }
-
- return text;
- }
-
-
- /**
- * Format number of remaining bytes to be installed as string.
- * @param remaining bytes remaining, -1 for 'done'
- * @return string human readable remaining time or byte / kB/ MB size
- **/
- string FormatRemainingSize( integer remaining )
- {
- if ( remaining < 0 )
- {
- // Nothing more to install from this CD (very concise - little space!!)
- return _("Done.");
- }
- if ( remaining == 0 )
- {
- return "";
- }
-
- return String::FormatSize( remaining );
- }
-
-
- /**
- * Format number of remaining packages to be installed as string.
- * @param remaining bytes remaining, -1 for 'done'
- * @return string human readable remaining time or byte / kB/ MB size
- **/
- string FormatRemainingCount( integer remaining )
- {
- if ( remaining < 0 )
- {
- // Nothing more to install from this CD (very concise - little space!!)
- return _("Done.");
- }
- if ( remaining == 0 )
- {
- return "";
- }
-
- return sformat( "%1", remaining );
- }
-
-
- string FormatNextMedia()
- {
- string text = "";
-
- if ( next_src_no >= 0 && next_cd_no >= 0 )
- {
- string next_media_name = sformat( "%1 %2 %3",
- inst_src_names[ next_src_no ]:"",
- media_type, next_cd_no+1 );
-
- if ( unit_is_seconds )
- {
- // Status line informing about the next CD that will be used
- // %1: Media type ("CD" / "DVD", ???)
- // %2: Media name ("SuSE Linux Professional CD 2" )
- // %3: Time remaining until this media will be needed
- text = sformat( _("Next %1: %2 -- %3"), media_type, next_media_name,
- FormatTime( remaining_times_per_cd_per_src[ current_src_no-1, current_cd_no-1 ]: 1) );
- }
- else
- {
- // Status line informing about the next CD that will be used
- // %1: Media type ("CD" / "DVD", ???)
- // %2: Media name ("SuSE Linux Professional CD 2" )
- text = sformat( _("Next %1: %2"), media_type, next_media_name );
- }
- }
-
- return text;
- }
-
-
- /**
- * Get a list of available slides (images) for the slide show.
- * @return list slides
- **/
- list<string> GetSlideList( string lang )
- {
- list<string> slide_list = nil;
-
- string txt_path = sformat( "%1/txt/%2", slide_base_path, lang );
- if (FileUtils::Exists (txt_path)) {
- slide_list = (list<string>) SCR::Read (.target.dir, txt_path );
- }
-
- if ( slide_list == nil )
- {
- y2error( "Directory %1 does not exist", txt_path );
- if ( size( lang ) > 2 )
- {
- lang = substring( lang, 0, 2 );
- txt_path = sformat( "%1/txt/%2", slide_base_path, lang );
-
- if (FileUtils::Exists (txt_path)) {
- slide_list = (list<string>) SCR::Read (.target.dir, txt_path );
- }
- }
- }
-
- if ( slide_list == nil )
- {
- y2milestone( "Slideshow directory %1 does not exist", txt_path );
- }
- else
- {
- y2milestone ("Using slides from '%1' (%2 slides)", txt_path, size (slide_list));
-
- slide_list = sort( filter( string filename, slide_list, ``{
- // Check for valid extensions - ignore editor save files and other leftover stuff
- return regexpmatch( filename, ".*\.(rtf|RTF|html|HTML|htm|HTM)$" );
- } ) );
-
- y2debug( "GetSlideList(): Slides at %1: %2", txt_path, slide_list );
- }
-
- if ( slide_list != nil && size( slide_list ) > 0 ) // Slide texts found
- {
- slide_txt_path = txt_path;
- slide_pic_path = slide_base_path + "/pic";
-
- y2milestone ("Using TXT: %1, PIC: %2", slide_txt_path, slide_pic_path);
- }
- else // No slide texts found
- {
- y2debug( "No slides found at %1", txt_path );
-
- // function calls itself!
- if ( lang != fallback_lang )
- {
- y2debug( "Trying to load slides from fallback: %1", fallback_lang );
- slide_list = GetSlideList( fallback_lang );
- }
- }
-
- return slide_list;
- }
-
-
- /**
- * Check if showing slides is supported.
- *
- * Not to be confused with HaveSlides() which checks if there are slides available.
- **/
- boolean HaveSlideSupport()
- {
- map disp = UI::GetDisplayInfo();
-
- if (disp != nil // This shouldn't happen, but who knows?
- && disp["HasImageSupport"]:false
- && disp["DefaultWidth"]:-1 >= 800
- && disp["DefaultHeight"]:-1 >= 600
- && disp["Depth"]:-1 >= 8 )
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
-
- /**
- * Check if slides are available.
- *
- * Not to be confused with HaveSlideSupport() which checks
- * if slides could be displayed if there are any.
- **/
- boolean HaveSlides()
- {
- return size( slides ) > 0;
- }
-
-
- /**
- * Check if the dialog is currently set up so the user could switch to the slide page.
- **/
- boolean HaveSlideWidget()
- {
- return UI::WidgetExists(`dumbTab);
- }
-
-
- /**
- * Check if the slide show is available. This must be called before trying
- * to access any slides; some late initialization is done here.
- **/
- global void CheckForSlides()
- {
- slides = [];
-
- map tmp = (map) WFM::Read(.local.stat, slide_base_path);
- if (! tmp["isdir"]:false)
- {
- y2error( "Using default path instead of %1", slide_base_path );
- slide_base_path = "/var/adm/YaST/InstSrcManager/tmp/CurrentMedia/suse/setup/slide";
- }
-
- if ( debug && false )
- {
- y2milestone( "Debug mode - using faster time recalc values" );
- initial_recalc_delay = 7;
- recalc_interval = 5;
- slide_min_interval = 5;
- }
-
-
- if ( Stage::initial () || Stage::cont () )
- {
- if ( HaveSlideSupport() )
- {
- y2milestone( "Display OK for slide show" );
-
- y2milestone( "Trying slides from %1", slide_base_path );
-
- slides = GetSlideList( language );
- }
- else
- {
- y2warning( "Disabling slide show - insufficient display capabilities" );
- }
- }
- }
-
-
- /**
- * Set the slide show text.
- * @param text
- **/
- void SetSlideText( string text )
- {
- if ( UI::WidgetExists(`slideText ) )
- {
- //
- // Fix <img src> tags: Replace image path with current slide_pic_path
- //
-
- while (true)
- {
- string replaced = regexpsub( text, "(.*)&imagedir;(.*)",
- sformat("\\1%1\\2", slide_pic_path ) );
- if ( replaced == nil ) break;
- text = replaced;
- }
-
- UI::ChangeWidget(`slideText, `Value, text );
- }
- }
-
-
- /**
- * Load one slide from files complete with image and textual description.
- * @param text_file_name file name + path of the text file (rich text / HTML)
- * @return true if OK, false if error
- **/
- boolean LoadSlideFile( string text_file_name )
- {
- string text = (string) SCR::Read( .target.string, [text_file_name, ""] );
-
- if ( text == "" )
- {
- return false;
- }
- else
- {
- y2debug( "Loading slide show text from %1", text_file_name);
- SetSlideText( text );
- return true;
- }
- }
-
-
- /**
- * Get version info for a package (without build no.)
- *
- * @param pkg_name name of the package without path and ".rpm" extension
- * @return version string
- **/
- global string StripReleaseNo( string pkg_name )
- {
- integer build_no_pos = findlastof (pkg_name, "-" ); // find trailing build no.
-
- if ( build_no_pos != nil && build_no_pos > 0 )
- {
- // cut off trailing build no.
- pkg_name = substring( pkg_name , 0, build_no_pos );
- }
-
- return pkg_name;
- }
-
- /**
- * Get package file name from path
- *
- * @param pkg_name location of the package
- * @return string package file name
- **/
- global string StripPath(string pkg_name)
- {
- if (pkg_name == nil)
- {
- return nil;
- }
-
- integer file_pos = findlastof(pkg_name, "/");
-
- if (file_pos != nil && file_pos > 0 )
- {
- // return just the file name
- pkg_name = substring(pkg_name, file_pos + 1);
- }
-
- return pkg_name;
- }
-
-
- /**
- * set media type "CD" or "DVD"
- */
- global void SetMediaType (string new_media_type)
- {
- media_type = new_media_type;
- }
-
-
- /**
- * Set the slide show directory
- */
- global void SetSlideDir( string dir )
- {
- slide_base_path = dir;
-
- map tmp = (map) WFM::Read (.local.stat, slide_base_path);
-
- if ( ! tmp["isdir"]:false )
- {
- y2error( "Using default path instead of %1", tmp );
- slide_base_path = "/var/adm/YaST/InstSrcManager/tmp/CurrentMedia/suse/setup/slide";
- }
-
- y2milestone( "SetSlideDir: %1", slide_base_path );
- }
-
-
- /**
- * Perform sanity check for correct initialzation etc.
- * @param silent don't complain in log file
- * @return true if OK, false if any error
- **/
- boolean SanityCheck( boolean silent )
- {
- return true; // FIXME!
- if ( ! init_pkg_data_complete )
- {
- if ( ! silent )
- {
- y2error( "SlideShow::SanityCheck(): Slide show not correctly initialized: " +
- "SlideShow::InitPkgData() never called!" );
- }
- return false;
- }
-
- if ( current_src_no < 1 || current_cd_no < 1 )
- {
- // nothing to install but something is going to be deleted, so it's OK
- if (Pkg::IsAnyResolvable(`package, `to_remove))
- {
- return true;
- }
- else if (!silent)
- {
- y2error(-1, "SlideShow::SanityCheck(): Illegal values for current_src (%1) or current_cd (%2)",
- current_src_no, current_cd_no );
- y2milestone( "total sizes: %1", total_sizes_per_cd_per_src );
- }
- return false;
- }
-
- return true;
- }
-
- string provide_name = "";
- string provide_size = "";
-
- global void SlideGenericProvideStart (string pkg_name, integer sz,
- string pattern, boolean remote)
- {
- if ( ! SanityCheck( false ) ) return;
- if ( ! ShowingDetails() ) return;
-
- string provide_msg = "";
-
- if (remote)
- {
- provide_name = pkg_name;
- provide_size = String::FormatSize(sz);
-
- provide_msg = sformat(_("Downloading %1 (download size %2)"), provide_name, provide_size);
- }
- else
- {
- provide_msg = pkg_name;
- }
-
- SubProgress( 0, provide_msg );
-
- //
- // Update (user visible) installation log
- // for remote download only
- //
-
- if( ! remote ) return;
-
- y2milestone( "Package '%1' is remote", pkg_name );
-
- // message in the installatino log, %1 is package name,
- // %2 is package size
- AppendMessageToInstLog( sformat (pattern, pkg_name, String::FormatSize (sz)) );
- }
-
- global void SlideDeltaApplyStart (string pkg_name) {
- if ( ! SanityCheck( false ) ) return;
- if ( ! ShowingDetails() ) return;
-
- SubProgress( 0, pkg_name );
-
- AppendMessageToInstLog( sformat (_("Applying delta RPM: %1"), pkg_name) );
- }
-
-
- /**
- * Package providal start
- */
- global void SlideProvideStart (string pkg_name, integer sz, boolean remote)
- {
- // message in the installatino log, %1 is package name,
- // %2 is package size
- SlideGenericProvideStart (pkg_name, sz, _("Downloading %1 (download size %2)"),
- remote);
- }
-
-
- /**
- * Set the curent language. Must be called once during initialization.
- **/
- global void SetLanguage( string new_language )
- {
- language = new_language;
- }
-
- /**
- * Update internal bookkeeping: subtract size of one package from the
- * global list of remaining sizes per CD
- **/
- void SubtractPackageSize( integer pkg_size )
- {
- integer remaining = remaining_sizes_per_cd_per_src [ current_src_no-1, current_cd_no-1 ]: 1;
- remaining = remaining - pkg_size;
- total_size_installed = total_size_installed + pkg_size;
-
- if ( remaining <= 0 )
- {
- // -1 is the indicator for "done with this CD" - not to be
- // confused with 0 for "nothing to install from this CD".
- remaining = -1;
- }
-
- remaining_sizes_per_cd_per_src [ current_src_no-1, current_cd_no-1 ] = remaining;
- remaining_pkg_count_per_cd_per_src [ current_src_no-1, current_cd_no-1 ] =
- remaining_pkg_count_per_cd_per_src [ current_src_no-1, current_cd_no-1 ]:0 -1;
-
- if ( unit_is_seconds )
- {
- integer seconds = 0;
-
- if ( remaining > 0 && bytes_per_second > 0 )
- seconds = remaining / bytes_per_second;
-
- remaining_times_per_cd_per_src [ current_src_no-1, current_cd_no-1 ] = seconds;
- }
-
- if ( debug )
- y2milestone( "SubtractPackageSize( %1 ) -> %2", pkg_size, remaining_sizes_per_cd_per_src);
- }
-
-
- /**
- * Return a CD's progress bar ID
- * @param src_no number of the repository (from 0 on)
- * @param cd_no number of the CD within that repository (from 0 on)
- **/
- string CdProgressId( integer src_no, integer cd_no )
- {
- return sformat( "Src %1 CD %2", src_no, cd_no );
- }
-
-
- /**
- * Recalculate remaining times per CD based on package sizes remaining
- * and data rate so far. Recalculation is only done each 'recalc_interval'
- * seconds unless 'force_recalc' is set to 'true'.
- *
- * @param force_recalc force recalculation even if timeout not reached yet
- * @return true if recalculated, false if not
- **/
- boolean RecalcRemainingTimes( boolean force_recalc )
- {
- if ( ! force_recalc
- && time() < next_recalc_time )
- {
- // Nothing to do (yet) - simply return
- return false;
- }
-
-
- // Actually do recalculation
-
- integer elapsed = total_time_elapsed;
-
- if ( start_time >= 0 )
- {
- elapsed = elapsed + time() - start_time;
- }
-
- if ( elapsed == 0 )
- {
- // Called too early - no calculation possible yet.
- // This happens regularly during initialization, so an error
- // message wouldn't be a good idea here.
-
- return false;
- }
-
-
- // This is the real thing.
-
- integer real_bytes_per_second = total_size_installed / elapsed;
-
- // But this turns out to be way to optimistic - RPM gets slower and
- // slower while installing. So let's add some safety margin to make
- // sure initial estimates are on the pessimistic side - the
- // installation being faster than initially estimated will be a
- // pleasant surprise to the user. Most users don't like it the other
- // way round.
- //
- // The "pessimistic factor" progressively decreases as the installation
- // proceeds. It begins with about 1.7, i.e. the data transfer rate is
- // halved to what it looks like initially. It decreases to 1.0 towards
- // the end.
-
- float pessimistic_factor = 1.0;
-
- if ( total_size_to_install > 0 )
- pessimistic_factor = 1.7 - tofloat( total_size_installed ) / tofloat( total_size_to_install );
- bytes_per_second = tointeger( tofloat( real_bytes_per_second ) / pessimistic_factor + 0.5 );
-
- if ( bytes_per_second < 1 )
- bytes_per_second = 1;
-
- remaining_times_per_cd_per_src = [];
-
- // Recalculate remaining times for the individual CDs
-
- foreach ( list<integer> remaining_sizes_list, remaining_sizes_per_cd_per_src,
- ``{
- list<integer> remaining_times_list = [];
- integer remaining_time = -1;
-
- foreach ( integer remaining_size, remaining_sizes_list,
- ``{
- remaining_time = remaining_size;
-
- if ( remaining_size > 0 )
- {
- remaining_time = remaining_size / bytes_per_second;
-
- if ( remaining_time < min_time_per_cd )
- {
- // It takes at least this long for the CD drive to spin up and
- // for RPM to do _anything_. Times below this values are
- // ridiculously unrealistic.
- remaining_time = min_time_per_cd;
- }
- else if ( remaining_time > max_time_per_cd ) // clip off at 2 hours
- {
- // When data throughput goes downhill (stalled network connection etc.),
- // cut off the predicted time at a reasonable maximum.
- remaining_time = max_time_per_cd;
- }
- }
- remaining_times_list = add( remaining_times_list, remaining_time );
- });
-
- remaining_times_per_cd_per_src = add( remaining_times_per_cd_per_src, remaining_times_list );
- });
-
-
- // Recalculate slide interval
-
- if ( size( slides ) > 0 )
+ if( new_text != nil )
+ UI::ChangeWidget(`progressTotal, `Label, new_text );
+ }
+ else
+ y2milestone( "progressTotal widget missing" );
+
+ // update slide
+ if( ShowingSlide() )
{
- integer slides_remaining = size( slides ) - current_slide_no - 1;
-
- if ( slides_remaining > 0 )
- {
- // The remaining time for the rest of the slides depends on the
- // remaining time for the current CD only: This is where the
- // slide images and texts reside. Normally, only CD1 has slides
- // at all, i.e. the slide show must be finished when CD1 is
- // done.
- //
- // In addition to that, take elapsed time for current slide
- // into account so all slides get about the same time.
-
- integer time_remaining = remaining_times_per_cd_per_src[current_src_no-1, current_cd_no-1]:1 + time() - slide_start_time;
- slide_interval = time_remaining / slides_remaining;
- y2debug( "New slide interval: %1 - slides remaining: %2 - remaining time: %3",
- slide_interval, slides_remaining, time_remaining );
-
- if ( slide_interval < slide_min_interval )
- {
- slide_interval = slide_min_interval;
- y2debug( "Resetting slide interval to min slide interval: %1", slide_interval );
- }
-
- if ( slide_interval > slide_max_interval )
- {
- slide_interval = slide_max_interval;
- y2debug( "Resetting slide interval to max slide interval: %1", slide_interval );
- }
- }
+ ChangeSlideIfNecessary();
}
-
- next_recalc_time = time() + recalc_interval;
-
- return true;
}
+ map<string, map<string,any> > _stages = $[]; // list of the configured stages
+ map<string, any> _current_stage = nil; // current stage
/**
- * Create one single item for the CD statistics table
- **/
- term TableItem( string id, string col1, string col2, string col3, string col4 )
+ * Return the description for the current stage.
+ * @return string localized string description
+ */
+ global string CurrentStageDescription()
{
- return `item(`id( id ), col1, col2, col3, col4 );
+ return _current_stage["description"]:_("Installing...");
}
-
-
+
/**
- * Returns a table widget item list for CD statistics
- **/
- list<term> CdStatisticsTableItems()
+ * Move the global progress to the beginning of the given stage.
+ * @param stage_name id of the stage to move to
+ */
+ global void MoveToStage( string stage_name )
{
- list<term> itemList = [];
-
- //
- // Add "Total" item - at the top so it is visible by default even if there are many items
- //
-
+ if( ! haskey( _stages, stage_name ) )
{
- // List column header for total remaining MB and time to install
- string caption = _("Total");
- integer remaining = TotalRemainingSize();
- string rem_size = FormatRemainingSize( remaining );
- string rem_count = FormatRemainingCount( TotalRemainingPkgCount() );
- string rem_time = "";
-
- if ( unit_is_seconds && bytes_per_second > 0 )
- {
- rem_time = FormatTimeShowOverflow( TotalRemainingTime() );
- }
-
- itemList = add( itemList, TableItem( "total", caption, " " + rem_size, " " + rem_count, " " + rem_time ) );
+ y2error( "Unknown progress stage \"%1\"", stage_name );
+ return;
}
+
+ _current_stage = _stages[stage_name]:nil;
+
+ y2milestone( "Moving to stage %1 (%2)", stage_name, _stages[stage_name, "start"]:0 );
+ // translators: default global progress bar label
+ UpdateGlobalProgress( _stages[stage_name, "start"]:0, _current_stage["description"]:_("Installing...") );
+ }
+ /**
+ * Update the global progress according to the progress in the current stage.
+ * The new value will be set to the per cent of the current stage according to \param value,
+ * if the \text is not nil, the label will be updated
+ * to this text as well. Otherwise label will not change.
+ * @param value new value for the stage progress
+ * @param text new label for the global progress
+ */
+ global void StageProgress( integer value, string text )
+ {
+ UpdateGlobalProgress( _current_stage["start"]:0 + (value * _current_stage["size"]:1 / 100), text );
+ }
- //
- // Now go through all repositories
- //
-
- integer src_no = 0;
-
- foreach ( list<integer> inst_src, remaining_sizes_per_cd_per_src, ``{
- y2milestone( "src #%1: %2", src_no, inst_src );
-
- if (ListSum(inst_src) > 0) // Ignore repositories from where there is nothing is to install
- {
- // Add heading for this repository
- itemList = add( itemList, TableItem( sformat( "src(%1)", src_no ),
- inst_src_names[ src_no ]:"", "", "", "" ) );
-
- integer cd_no = 0;
-
- foreach ( integer remaining, inst_src, ``{
- if ( remaining > 0
- || ( src_no+1 == current_src_no && cd_no+1 == current_cd_no ) ) // suppress current CD
- {
- string caption = sformat( "%1 %2", media_type, cd_no+1 ); // "CD 1" - column #0
- string rem_size = FormatRemainingSize( remaining ); // column #1
- string rem_count = FormatRemainingCount( remaining_pkg_count_per_cd_per_src[ src_no, cd_no ]:0 );
- string rem_time = "";
-
- if ( unit_is_seconds && bytes_per_second > 0 )
- {
- remaining = remaining / bytes_per_second;
- rem_time = FormatTime( remaining ); // column #2
-
- if ( remaining > max_time_per_cd ) // clip off at 2 hours
- {
- // When data throughput goes downhill (stalled network connection etc.),
- // cut off the predicted time at a reasonable maximum.
- // "%1" is a predefined maximum time.
- rem_time = FormatTimeShowOverflow( -max_time_per_cd );
- }
- }
-
- itemList = add( itemList,
- TableItem( sformat("cd(%1,%2)", src_no, cd_no ), // ID
- caption, " " + rem_size, " " + rem_count, " " + rem_time ) );
- }
-
- cd_no = cd_no + 1;
- });
- }
-
- src_no = src_no + 1;
- });
-
- if ( debug )
+ /**
+ * Return the current global progress label.
+ * @return string current label
+ */
+ global void SetGlobalProgressLabel( string text )
+ {
+ total_progress_label = text;
+ if ( UI::WidgetExists(`progressTotal ) )
{
- y2milestone( "Remaining: %1", remaining_sizes_per_cd_per_src );
- y2milestone( "CD table item list:\n%1", itemList );
+ UI::ChangeWidget(`progressTotal, `Label, text);
}
-
- return itemList;
}
-
-
/**
- * Progress display update
- * This is called via the packager's progress callbacks.
- *
- * @param pkg_percent package percentage
- **/
- global void UpdateCurrentPackageProgress(integer pkg_percent)
+ * Append message to the installation log.
+ * @param msg message to be added, without trailing eoln
+ */
+ global void AppendMessageToInstLog (string msg)
{
- SubProgress( pkg_percent, nil );
- }
+ string log_line = "\n" + msg;
+ inst_log = inst_log + log_line;
- // update the download rate
- global void UpdateCurrentPackageRateProgress(integer pkg_percent, integer bps_avg, integer bps_current)
- {
- if( ! ShowingDetails() ) return;
-
- string new_text = nil; // no update of the label
- if (bps_current > 0)
+ if ( ShowingDetails() )
{
- // do not show the average download rate if the space is limited
- if (textmode && display_width < 100)
- {
- bps_avg = -1;
- }
- new_text = String::FormatRateMessage(provide_name + " - %1", bps_avg, bps_current);
- new_text = sformat(_("Downloading %1 (download size %2)"), new_text, provide_size);
+ if ( UI::WidgetExists( `instLog ) )
+ UI::ChangeWidget(`instLog, `LastLine, log_line );
}
-
- SubProgress( pkg_percent, new_text );
}
+
/**
- * Update progress widgets for all CDs.
- * Uses global statistics variables.
+ * Check if the dialog is currently set up so the user could switch to the slide page.
**/
- global void UpdateAllCdProgress(boolean silent_check)
+ global boolean HaveSlideWidget()
{
- if ( ! SanityCheck( silent_check ) ) return;
- if ( ! widgets_created ) return;
-
- if ( unit_is_seconds )
- RecalcRemainingTimes( true ); // force
-
- if ( UI::WidgetExists(`cdStatisticsTable) )
- UI::ChangeWidget(`cdStatisticsTable, `Items, CdStatisticsTableItems() );
+ return UI::WidgetExists(`dumbTab);
}
/**
- * Update progress widgets for the current CD: Label and ProgressBar.
- * Use global statistics variables for that.
+ * Check if the slide show is available. This must be called before trying
+ * to access any slides; some late initialization is done here.
**/
- global void UpdateCurrentCdProgress(boolean silent_check)
+ global void CheckForSlides()
{
- if ( ! SanityCheck( silent_check ) ) return;
- if ( ! UI::WidgetExists(`cdStatisticsTable) ) return;
-
-
- //
- // Update table entries for current CD
- //
-
- integer remaining = remaining_sizes_per_cd_per_src [ current_src_no-1, current_cd_no-1 ]:0;
- UI::ChangeWidget(`id(`cdStatisticsTable ),
- `Item( sformat( "cd(%1,%2)", current_src_no-1, current_cd_no-1), size_column ),
- FormatRemainingSize( remaining ) );
+ Slides::CheckBasePath();
- UI::ChangeWidget(`id(`cdStatisticsTable ),
- `Item( sformat( "cd(%1,%2)", current_src_no-1, current_cd_no-1), pkg_count_column ),
- FormatRemainingCount( remaining_pkg_count_per_cd_per_src [ current_src_no-1, current_cd_no-1 ]:0 ) );
-
- if ( unit_is_seconds )
+ if ( Stage::initial () || Stage::cont () )
{
- // Convert 'remaining' from size (bytes) to time (seconds)
-
- remaining = remaining / bytes_per_second;
-
- if ( remaining <= 0 )
- remaining = 0;
-
- if ( remaining > max_time_per_cd ) // clip off at 2 hours
+ if ( Slides::HaveSlideSupport() )
{
- // When data throughput goes downhill (stalled network connection etc.),
- // cut off the predicted time at a reasonable maximum.
- remaining = -max_time_per_cd;
+ y2milestone( "Display OK for slide show, loading" );
+ Slides::LoadSlides( language );
+ }
+ else
+ {
+ y2warning( "Disabling slide show - insufficient display capabilities" );
}
-
- UI::ChangeWidget(`id(`cdStatisticsTable ),
- `Item( sformat( "cd(%1,%2)", current_src_no-1, current_cd_no-1), time_column ),
- FormatTimeShowOverflow( remaining ) );
- }
-
-
- //
- // Update "total" table entries
- //
-
- UI::ChangeWidget(`id( `cdStatisticsTable ),
- `Item( "total", size_column ),
- FormatRemainingSize( TotalRemainingSize() ) );
-
- UI::ChangeWidget(`id( `cdStatisticsTable ),
- `Item( "total", pkg_count_column ),
- FormatRemainingCount( TotalRemainingPkgCount() ) );
-
- if ( unit_is_seconds )
- {
- UI::ChangeWidget(`id( `cdStatisticsTable ), `Item( "total", time_column ),
- FormatTimeShowOverflow( TotalRemainingTime() ) );
-
}
}
+
/**
- * If needed, compute new global progress label. Otherwise just return the current one.
- */
- string GetProgressLabel()
+ * Set the slide show text.
+ * @param text
+ **/
+ void SetSlideText( string text )
{
- // hack - this needs to be generic
- if( _current_stage["name"]:nil == "packages" )
+ if ( UI::WidgetExists(`slideText ) )
{
- string rem_string = "";
- integer tot_rem_t = TotalRemainingTime();
-
- rem_string = ( unit_is_seconds && bytes_per_second > 0 && tot_rem_t > 0) ?
- sformat("%1 / %2", FormatRemainingSize(TotalRemainingSize()), FormatTimeShowOverflow(tot_rem_t))
- : FormatRemainingSize(TotalRemainingSize());
-
- total_progress_label = _current_stage["description"]:_("Installing...") + sformat(_(" (Remaining: %1)"), rem_string);
+ UI::ChangeWidget(`slideText, `Value, text );
}
- return total_progress_label;
}
+
/**
- * Update progress widgets
+ * Set the curent language. Must be called once during initialization.
**/
- void UpdateTotalProgress(boolean silent_check)
+ global void SetLanguage( string new_language )
{
- StageProgress( ( TotalInstalledSize() >> 10 ) * 100 / ( total_size_to_install >> 10 ), GetProgressLabel() );
-
- UpdateCurrentCdProgress(silent_check);
-
- if ( UI::WidgetExists(`nextMedia ) )
- {
- string nextMedia = FormatNextMedia();
-
- if ( nextMedia != "" || last_cd )
- {
- UI::ChangeWidget(`nextMedia, `Value, nextMedia );
- UI::RecalcLayout();
- last_cd = false;
- }
- }
+ language = new_language;
}
/**
- * Switch unit to seconds if necessary and recalc everything accordingly.
- * @return true if just switched from sizes to seconds, false otherwise
+ * Create one single item for the CD statistics table
**/
- boolean SwitchToSecondsIfNecessary()
+ global term TableItem( string id, string col1, string col2, string col3, string col4 )
{
- if ( unit_is_seconds
- || time() < start_time + initial_recalc_delay )
- {
- return false; // no need to switch
- }
-
- RecalcRemainingTimes( true ); // force recalculation
- unit_is_seconds = true;
-
- return true; // just switched
+ return `item(`id( id ), col1, col2, col3, col4 );
}
@@ -1323,18 +374,17 @@
**/
void LoadSlide( integer slide_no )
{
- if ( slide_no > size( slides ) )
+ if ( slide_no > size( Slides::slides ) )
{
slide_no = 0;
}
current_slide_no = slide_no;
- string slide_name = slides[slide_no]:"";
+ string slide_name = Slides::slides[slide_no]:"";
slide_start_time = time();
- if ( LoadSlideFile( sformat ("%1/%2", slide_txt_path, slide_name ) ) ) return;
- SetSlideText ("");
+ SetSlideText( Slides::LoadSlideFile( slide_name ) );
}
@@ -1342,9 +392,9 @@
* Check if the current slide needs to be changed and do that if
* necessary.
**/
- void ChangeSlideIfNecessary()
+ global void ChangeSlideIfNecessary()
{
- if ( current_slide_no + 1 < size( slides )
+ if ( current_slide_no + 1 < size( Slides::slides )
&& time() > slide_start_time + slide_interval )
{
y2debug( "Loading slide #%1", current_slide_no + 2 );
@@ -1352,115 +402,6 @@
}
}
-
- /**
- * package start display update
- * - this is called at the beginning of a new package
- *
- * @param pkg_name package name
- * @param pkg_summary package summary (short description)
- * @param deleting Flag: deleting (true) or installing (false) package?
- **/
- global void SlideDisplayStart( string pkg_name,
- string pkg_summary,
- integer pkg_size,
- boolean deleting )
- {
- if ( ! SanityCheck( false ) ) return;
-
- // remove path
- pkg_name = StripPath(pkg_name);
-
- // remove release and .rpm suffix
- // pkg_name = StripReleaseNo( pkg_name ); // bug #154872
-
- if ( deleting )
- {
- pkg_size = -1;
-
- // This is a kind of misuse of insider knowledge: If there are packages to delete, this
- // deletion comes first, and only then packages are installed. This, however, greatly
- // distorts the estimated times based on data throughput so far: While packages are
- // deleted, throughput is zero, and estimated times rise to infinity (they are cut off
- // at max_time_per_cd to hide this). So we make sure the time spent deleting packages is
- // not counted for estimating remaining times - reset the timer.
- //
- // Note: This will begin to fail when some day packages are deleted in the middle of the
- // installaton process.
-
- ResetTimer();
- }
-
- if ( pkg_summary == nil )
- pkg_summary = "";
-
- string msg = "";
-
- if ( deleting )
- {
- // Heading for the progress bar for the current package
- // while it is deleted. "%1" is the package name.
- msg = sformat( _("Deleting %1"), pkg_name );
- }
- else
- {
- // package installation - summary text
- // %1 is RPM name, %2 is installed (unpacked) size (e.g. 6.20MB)
- msg = sformat( _("%1 (installed size %2)"), pkg_name, String::FormatSize( pkg_size ) );
- }
-
-
- //
- // Update package progress bar
- //
- SubProgress( 0, msg );
-
- //
- // Update (user visible) installation log
- //
- AppendMessageToInstLog( sformat( _("Installing %1"), msg) );
-
- //
- // Update the current slide if applicable
- //
- if ( ShowingSlide() )
- {
- ChangeSlideIfNecessary();
- }
- }
-
- /**
- * package start display update
- * - this is called at the end of a new package
- *
- * @param pkg_name package name
- * @param deleting Flag: deleting (true) or installing (false) package?
- **/
- global void SlideDisplayDone ( string pkg_name,
- integer pkg_size,
- boolean deleting )
- {
- if ( ! deleting )
- {
- SubtractPackageSize( pkg_size );
-
- if (SwitchToSecondsIfNecessary()
- || RecalcRemainingTimes( false ) ) // no forced recalculation
- {
- y2debug( "Updating progress for all CDs" );
- UpdateAllCdProgress(false);
- }
- else
- {
- UpdateCurrentCdProgress(false);
- }
-
- UpdateTotalProgress(false);
-
- } // ! deleting
-
- }
-
/**
* Add widgets for progress bar etc. around a slide show page
* @param page_id ID to use for this page (for checking with UI::WidgetExists() )
@@ -1476,15 +417,13 @@
`VWeight( 1, // lower layout priority
page_contents ),
// Progress bar for overall progress of software package installation
- `ProgressBar(`id(`progressTotal ), GetProgressLabel(), 100, total_progress_value)
+ `ProgressBar(`id(`progressTotal ), total_progress_label, 100, total_progress_value)
// intentionally omitting `Label(`nextMedia) -
// too much flicker upon update (UI::RecalcLayout() ) on NCurses
),
`HSpacing( 0.5 )
);
- y2milestone("total_size_to_install: %1", total_size_to_install);
-
y2debug( "widget term: \n%1", widgets );
return widgets;
}
@@ -1520,7 +459,7 @@
// Table headings for CD statistics during installation
`Right( _("Time") )
),
- CdStatisticsTableItems()
+ table_items
)
);
}
@@ -1546,6 +485,11 @@
return widgets;
}
+ /**
+ * Construct widgets for the "release notes" page
+ *
+ * @return A term describing the widgets
+ **/
term RelNotesPageWidgets() {
term widgets = AddProgressWidgets (`relNotesPage,
`RichText (relnotes)
@@ -1571,8 +515,10 @@
}
}
-
- void RebuildDetailsView(boolean silent_check)
+ /**
+ * Rebuild the details page.
+ */
+ void RebuildDetailsView()
{
if ( UI::WidgetExists(`tabContents ) )
{
@@ -1581,9 +527,6 @@
y2milestone( "Contents set to details" );
}
- // UpdateTotalProgress(silent_check);
- // UpdateAllCdProgress(silent_check);
-
if ( UI::WidgetExists( `instLog ) && inst_log != "" )
UI::ChangeWidget(`instLog, `Value, inst_log );
}
@@ -1591,14 +534,14 @@
/**
* Switch from the 'slide show' view to the 'details' view.
**/
- global void SwitchToDetailsView(boolean silent_check)
+ global void SwitchToDetailsView()
{
if ( ShowingDetails() )
{
y2milestone( "Already showing details" );
return;
}
- RebuildDetailsView( silent_check );
+ RebuildDetailsView();
}
/**
@@ -1618,6 +561,9 @@
}
+ /**
+ * Help text for the dialog
+ */
string HelpText()
{
// Help text while software packages are being installed (displayed only in rare cases)
@@ -1627,14 +573,15 @@
}
- void RebuildDialog(boolean silent_check)
+ /**
+ * Rebuild the dialog. Useful if slides become available post-creating the dialog.
+ */
+ global void RebuildDialog()
{
- if (!SanityCheck(silent_check)) return;
-
term contents = `Empty();
- if ( UI::HasSpecialWidget(`DumbTab) && HaveSlideSupport()
- && HaveSlides() )
+ if ( UI::HasSpecialWidget(`DumbTab) && Slides::HaveSlideSupport()
+ && Slides::HaveSlides() )
{
list tabs = [
// tab
@@ -1678,8 +625,8 @@
widgets_created = true;
- if ( ! HaveSlides() && ShowingSlide() )
- SwitchToDetailsView(false);
+ if ( ! Slides::HaveSlides() && ShowingSlide() )
+ SwitchToDetailsView();
}
@@ -1709,7 +656,7 @@
HelpText(),
false, false ); // has_back, has_next
- RebuildDialog(true);
+ RebuildDialog();
Wizard::SetTitleIcon("yast-sw_single");
// reset abort status
@@ -1724,157 +671,14 @@
{
current_slide_no = 0;
slide_start_time = 0;
- }
-
- /**
- * Initialize internal pacakge data, such as remaining package sizes and
- * times. This may not be called before the pkginfo server is up and
- * running, so this cannot be reliably done from the constructor in all
- * cases.
- * @param force true to force reinitialization
- **/
- global void InitPkgData(boolean force)
- {
- if ( init_pkg_data_complete && ! force)
- return;
-
- // Reinititalize some globals (in case this is a second run)
- total_size_installed = 0;
- total_time_elapsed = 0;
+ total_time_elapsed = 0;
start_time = -1;
next_recalc_time = -1;
- current_src_no = -1; // 1..n
- current_cd_no = -1; // 1..n
- next_src_no = -1;
- next_cd_no = -1;
- last_cd = false;
- unit_is_seconds = false; // begin with package sizes
- bytes_per_second = 1;
-
- list< list > src_list = Pkg::PkgMediaNames();
- inst_src_names = maplist( list src, src_list, ``(src[0]:"CD") );
-
- y2milestone ("Media names: %1", inst_src_names);
-
- integer index = 0;
-
- srcid_to_current_src_no = listmap( list src, src_list, {
- index = index + 1;
- return $[src[1]:-1 : index];
- });
-
- y2milestone ("Repository mapping information: %1", srcid_to_current_src_no );
-
- total_sizes_per_cd_per_src = Pkg::PkgMediaSizes();
- total_pkg_count_per_cd_per_src = Pkg::PkgMediaCount();
-
-
- total_size_to_install = ListSum( flatten( total_sizes_per_cd_per_src ) );
- y2milestone("total_size_to_install: %1", total_size_to_install);
- remaining_sizes_per_cd_per_src = (list<list <integer> >) eval (total_sizes_per_cd_per_src);
- remaining_pkg_count_per_cd_per_src = (list<list <integer> >) eval (total_pkg_count_per_cd_per_src);
- total_cd_count = size( flatten( total_sizes_per_cd_per_src ) );
- init_pkg_data_complete = true;
-
- y2milestone( "SlideShow::InitPkgData() done; total_sizes_per_cd_per_src: %1", total_sizes_per_cd_per_src );
- y2milestone( "SlideShow::InitPkgData(): pkg: %1", total_pkg_count_per_cd_per_src );
-
- // RebuildDialog(true);
- }
-
-
-
- /**
- * Try to figure out what media will be needed next
- * and set next_src_no and next_cd_no accordingly.
- **/
- void FindNextMedia()
- {
- // Normally we would have to use current_cd_no+1,
- // but since this uses 1..n and we need 0..n-1
- // for array subscripts anyway, use it as it is.
- next_cd_no = current_cd_no;
- next_src_no = current_src_no-1;
- last_cd = false;
-
- while ( next_src_no < size( remaining_sizes_per_cd_per_src ) )
- {
- list<integer> remaining_sizes = remaining_sizes_per_cd_per_src[ next_src_no ]: [];
-
- while ( next_cd_no < size( remaining_sizes ) )
- {
- if ( remaining_sizes[ next_cd_no ]:0 > 0 )
- {
- if ( debug )
- y2milestone( "Next media: src: %1 CD: %2", next_src_no, next_cd_no );
- return;
- }
- else
- {
- next_cd_no = next_cd_no + 1;
- }
- }
-
- next_src_no = next_src_no + 1;
- }
-
- if ( debug )
- y2milestone( "No next media - all done" );
-
- next_src_no = -1;
- next_cd_no = -1;
- last_cd = true;
}
+
/**
- * Set the current repository and CD number. Must be called for each CD change.
- * src_no: 1...n
- * cd_no: 1...n
- **/
- global void SetCurrentCdNo( integer src_no, integer cd_no )
- {
- if (cd_no == 0)
- {
- y2milestone("medium number 0, using medium number 1");
- cd_no = 1;
- }
-
- y2milestone("SetCurrentCdNo() - src: %1 , CD: %2", src_no, cd_no);
- current_src_no = srcid_to_current_src_no[src_no]:-1;
- current_cd_no = cd_no;
-
- CheckForSlides();
- FindNextMedia();
-
- if ( HaveSlides() && HaveSlideSupport() )
- {
- if ( ! HaveSlideWidget() )
- {
- RebuildDialog(false);
-
- if ( user_switched_to_details )
- SwitchToDetailsView(false);
- }
-
- if ( ! user_switched_to_details ) // Don't override explicit user request!
- {
- SwitchToSlideView();
- // LoadSlide(0); - do not restart slideshow for next CD
- }
- }
- else
- {
- if ( ! ShowingDetails() )
- RebuildDialog(false);
- //else
- // UpdateTotalProgress(false);
-
- // current_slide_no = 0; - do not restart slideshow for next CD
- }
- }
-
- /**
* Process (slide show) input (button press).
**/
global void HandleInput( any button )
@@ -1883,11 +687,11 @@
{
y2milestone( "User asks to switch to details" );
user_switched_to_details = true ;
- SwitchToDetailsView(false);
+ SwitchToDetailsView();
}
else if ( button == `showSlide && ! ShowingSlide() )
{
- if ( HaveSlides() )
+ if ( Slides::HaveSlides() )
{
user_switched_to_details = false;
SwitchToSlideView();
@@ -1913,9 +717,8 @@
/**
- * Check for user button presses and handle them. Generic handling.
- *
- * @return true if user wishes to abort
+ * Check for user button presses and handle them. Generic handling to be used in the
+ * progress handlers.
**/
global void GenericHandleInput()
{
@@ -1957,7 +760,7 @@
/**
* Open the slide show dialog.
**/
- global void OpenSlideShowDialog()
+ global void OpenDialog()
{
// call SlideShowCallbacks::InstallSlideShowCallbacks()
WFM::call("wrapper_slideshow_callbacks", ["InstallSlideShowCallbacks"]);
@@ -1967,19 +770,17 @@
OpenSlideShowBaseDialog();
- if ( HaveSlides() )
+ if ( Slides::HaveSlides() )
LoadSlide(0);
else
- SwitchToDetailsView(true);
-
- UpdateAllCdProgress(true);
+ SwitchToDetailsView();
}
/**
* Close the slide show dialog.
**/
- global void CloseSlideShowDialog()
+ global void CloseDialog()
{
if ( opened_own_wizard )
Wizard::CloseDialog();
@@ -1993,7 +794,7 @@
if ( ShowingDetails() && ! _show_table )
{
_show_table = true;
- RebuildDetailsView(true);
+ RebuildDetailsView();
}
_show_table = true;
}
@@ -2003,11 +804,20 @@
if ( ShowingDetails() && _show_table )
{
_show_table = false;
- RebuildDetailsView(true);
+ RebuildDetailsView();
}
_show_table = false;
}
-
+
+ global void UpdateTable( list<term> items )
+ {
+ table_items = items;
+ if( ShowingDetails() && _show_table )
+ {
+ UI::ChangeWidget( `id(`cdStatisticsTable), `Items, items );
+ }
+ }
+
/**
* Prepare the stages for the global progressbar. Will compute the total estimate of time and
* partition the global 100% to given stages based on their estimates. Can compute out of
Added: branches/tmp/visnov/progress/packager/SlideShowCallbacks.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/visnov/progress/packager/…
==============================================================================
--- branches/tmp/visnov/progress/packager/SlideShowCallbacks.ycp (added)
+++ branches/tmp/visnov/progress/packager/SlideShowCallbacks.ycp Fri Aug 29 15:19:13 2008
@@ -0,0 +1,621 @@
+/**
+ * Module: SlideShowCallbacks.ycp
+ *
+ * Authors: Gabriele Strattner <gs(a)suse.de>
+ * Klaus Kaempf <kkaempf(a)suse.de>
+ *
+ * Purpose: provides the Callbacks for SlideShow
+ *
+ * $Id: SlideShowCallbacks.ycp 48576 2008-06-27 09:16:09Z lslezak $
+ *
+ */
+
+{
+ module "SlideShowCallbacks";
+
+ textdomain "packager";
+
+ import "Installation";
+ import "Label";
+ import "Mode";
+ import "Stage";
+ import "PackageCallbacks";
+ import "Popup";
+ import "SlideShow";
+ import "PackageSlideShow";
+ import "Message";
+ import "Directory";
+ import "URL";
+
+ boolean _remote_provide = false;
+
+ string pkg_inprogress = "";
+
+ /**
+ * Check for user button presses and handle them.
+ *
+ * @return true if user wishes to abort
+ **/
+ void HandleInput()
+ {
+ // any button = SlideShow::debug ? UI::PollInput() : UI::TimeoutUserInput( 10 );
+ any button = UI::PollInput();
+
+ // in case of cancel ask user if he really wants to quit installation
+ if ( button == `abort || button == `cancel )
+ {
+ if ( Mode::normal () )
+ {
+ SlideShow::SetUserAbort(Popup::AnyQuestion( Popup::NoHeadline(),
+ // popup yes-no
+ _("Do you really want\nto quit the installation?"),
+ Label::YesButton(),
+ Label::NoButton(),
+ `focus_no ));
+ }
+ else if ( Stage::initial () )
+ {
+ SlideShow::SetUserAbort(Popup::ConfirmAbort( `unusable ));
+ }
+ else // Mode::update (), Stage::cont ()
+ {
+ SlideShow::SetUserAbort(Popup::ConfirmAbort( `incomplete ));
+ }
+
+ if (SlideShow::GetUserAbort())
+ {
+ SlideShow::AppendMessageToInstLog (_("Aborted"));
+ }
+ }
+ else
+ {
+ SlideShow::HandleInput( button );
+ }
+ }
+
+
+ /**
+ * at start of file providal
+ */
+ global void StartProvide( string name, integer archivesize, boolean remote )
+ {
+ pkg_inprogress = name;
+
+ if ( remote )
+ {
+ PackageSlideShow::SlideProvideStart (name , archivesize, remote);
+ _remote_provide = true;
+ }
+ }
+
+
+ /**
+ * during file providal
+ */
+ global boolean ProgressProvide(integer percent)
+ {
+ if (_remote_provide)
+ {
+ PackageSlideShow::UpdateCurrentPackageProgress( percent );
+ }
+ HandleInput();
+ return ! SlideShow::GetUserAbort();
+ }
+
+ global boolean ProgressDownload(integer percent, integer bps_avg, integer bps_current)
+ {
+ PackageSlideShow::UpdateCurrentPackageRateProgress(percent, bps_avg, bps_current);
+
+ HandleInput();
+ return ! SlideShow::GetUserAbort();
+ }
+
+
+ /**
+ * during file providal
+ */
+ global string DoneProvide( integer error, string reason, string name )
+ {
+ if ( _remote_provide )
+ {
+ PackageSlideShow::UpdateCurrentPackageProgress( 100 );
+ _remote_provide = false;
+ }
+ if (SlideShow::GetUserAbort())
+ {
+ return "CANCEL";
+ }
+ if (error != 0)
+ {
+ return PackageCallbacks::DoneProvide( error, reason, name );
+ }
+
+ return "";
+ }
+
+
+ global void ScriptStart(string patch_name, string patch_version, string patch_arch, string script_path)
+ {
+ string patch_full_name = PackageCallbacks::FormatPatchName(patch_name, patch_version, patch_arch);
+ y2milestone("ScriptStart: patch:%1, script:%2", patch_full_name, script_path);
+
+ // reset the progressbar
+ if (UI::WidgetExists(`progressCurrentPackage))
+ {
+ UI::ChangeWidget(`progressCurrentPackage, `Label, patch_full_name);
+ UI::ChangeWidget(`progressCurrentPackage, `Value, 0);
+ }
+
+ // message in the installation log widget, %1 is a patch name which contains the script
+ string log_line = sformat(_("Starting script %1"), patch_full_name);
+
+ SlideShow::AppendMessageToInstLog(log_line);
+ }
+
+ global boolean ScriptProgress (boolean ping, string output)
+ {
+ y2milestone("ScriptProgress: ping:%1, output: %2", ping, output);
+
+ if (output != nil && output != "")
+ {
+ string log_line = output;
+
+ // remove the trailing new line character
+ if (substring(output, size(output) - 1, 1) == "\n")
+ {
+ output = substring(output, 0, size(output) - 1);
+ }
+
+ // add the output to the log widget
+ SlideShow::AppendMessageToInstLog(output);
+ }
+
+ any input = UI::PollInput ();
+ y2milestone("input: %1", input);
+
+ if (input == `abort || input == `close)
+ return false;
+
+ return true;
+ }
+
+ global string ScriptProblem(string description)
+ {
+ y2milestone("ScriptProblem: %1", description);
+ Popup::Error(description);
+
+ // Abort
+ // TODO: support also Ignore and Retry
+ return "A";
+ }
+
+ global void ScriptFinish()
+ {
+ y2milestone("ScriptFinish");
+ }
+
+ global void Message(string patch_name, string patch_version, string patch_arch, string message)
+ {
+ string patch_full_name = PackageCallbacks::FormatPatchName(patch_name, patch_version, patch_arch);
+ y2milestone("Message (%1): %2", patch_full_name, message);
+
+ if (patch_full_name != "")
+ {
+ // label, %1 is patch name with version and architecture
+ patch_full_name = sformat(_("Patch %1\n\n"), patch_full_name);
+ }
+
+ Popup::LongMessage(patch_full_name + message);
+ }
+
+
+
+ //--------------------------------------------------------------------------
+ // slide show
+
+ term YesNoButtonBox()
+ {
+ term yes_button = `PushButton(`id(`yes), `opt(`key_F10), Label::YesButton());
+ term no_button = `PushButton(`id(`no_button), `opt(`default, `key_F9), Label::NoButton());
+
+ return `HBox(
+ `HStretch(),
+ `HWeight( 1, yes_button),
+ `HSpacing(2),
+ `HWeight( 1, no_button ),
+ `HStretch()
+ );
+ }
+
+ // never show the disk space warning popup during autoinstallation
+ boolean ask_again = Mode::autoinst() ? false : true;
+ // true == continue with the installtion
+ boolean user_input = true;
+
+ boolean YesNoAgainWarning(string message)
+ {
+ if (!ask_again)
+ {
+ return user_input;
+ }
+
+ term icon = `Empty();
+
+ // show the warning icon if possible
+ map ui_capabilities = UI::GetDisplayInfo();
+
+ if ( ui_capabilities[ "HasLocalImageSupport" ]:false )
+ {
+ icon = `Image( Directory::icondir + "32x32/apps/msg_warning.png", "" );
+ }
+
+ term content = `MarginBox(1.5, 0.5,
+ `VBox(
+ `HBox(
+ `VCenter(icon),
+ `HSpacing(1),
+ `VCenter(`Heading(Label::WarningMsg())),
+ `HStretch()
+ ),
+ `VSpacing(0.2),
+ `Left( `Label( message ) ),
+ `VSpacing(0.2),
+ `Left(`CheckBox(`id(`dont_ask), Message::DoNotShowMessageAgain())),
+ `VSpacing(0.5),
+ YesNoButtonBox()
+ )
+ );
+
+ UI::OpenDialog(`opt(`decorated), content);
+
+ any ret = UI::UserInput();
+
+ ask_again = !(boolean) UI::QueryWidget(`id(`dont_ask), `Value);
+
+ if (!ask_again)
+ {
+ // remember the user input
+ user_input = (ret == `yes);
+ }
+
+ UI::CloseDialog();
+
+ return ret == `yes;
+ }
+
+
+
+ /**
+ * Callback that will be called by the packager for each RPM as it is being installed or deleted.
+ * Note: The packager doesn't call this directly - the corresponding wrapper callbacks do
+ * and pass the "deleting" flag as appropriate.
+ **/
+ global void DisplayStartInstall(string pkg_name, string pkg_description, integer pkg_size, boolean deleting )
+ {
+ PackageSlideShow::SlideDisplayStart( pkg_name, pkg_description, pkg_size, deleting );
+ HandleInput();
+
+ // warn user about exhausted diskspace during installation (not if deleting packages)
+ if (!deleting && ask_again)
+ {
+ map<string, list<integer> > pkgdu = Pkg::PkgDU(pkg_inprogress);
+
+ y2debug("PkgDU(%1): %2", pkg_inprogress, pkgdu);
+
+ if (pkgdu != nil)
+ {
+ // check each mount point
+ foreach(string part, list<integer> data, pkgdu,
+ {
+ // skip read-only partitions, the package cannot be installed anyway
+ if (data[3]:0 == 1)
+ {
+ y2debug("Skipping read-only partition %1", part);
+ continue;
+ }
+
+ // add slash if missing (needed for target_dir)
+ if (part != "/" && size(part) >= 1 && substring(part, 0, 1) != "/")
+ {
+ part = "/" + part;
+ }
+
+ string target_dir = Installation::destdir + part;
+ integer disk_available = Pkg::TargetAvailable(target_dir);
+
+ y2debug("partition: %1 (%2), available: %3", part, target_dir, disk_available);
+
+ if (disk_available < data[2]:0)
+ {
+ y2warning("Not enought free space in %1 (%2): available: %3, required: %4", part, target_dir, disk_available, data[2]:0);
+
+ boolean cont = YesNoAgainWarning(
+ // warning popup - %1 is directory name (e.g. /boot)
+ sformat(_("The disk space in partition %1 is nearly exhausted.\nContinue with the installation?"), part));
+
+ if (!cont)
+ {
+ SlideShow::SetUserAbort(true);
+ }
+
+ // don't check the other partitions
+ break;
+ }
+ }
+ );
+ }
+ else
+ {
+ // disk usage for each partition is not known
+ // assume that all files will be installed into the root directory
+ integer disk_available = Pkg::TargetAvailable(Installation::destdir);
+
+ y2milestone("Available space (%1): %2", Installation::destdir, disk_available);
+
+ if (disk_available < pkg_size)
+ {
+ y2warning("Not enough free space in %1: available: %2, required: %3", Installation::destdir, disk_available, pkg_size);
+
+ boolean cont = YesNoAgainWarning(
+ // yes-no popup
+ _("The disk space is nearly exhausted.\nContinue with the installation?")
+ );
+
+ if (!cont)
+ {
+ SlideShow::SetUserAbort(true);
+ }
+ }
+ }
+ }
+ }
+
+
+ /**
+ * at start of package install
+ */
+ global void StartPackage( string name, string summary, integer install_size, boolean is_delete )
+ {
+ PackageCallbacks::_package_name = name;
+ PackageCallbacks::_package_size = install_size;
+ PackageCallbacks::_deleting_package = is_delete;
+
+ DisplayStartInstall( name,
+ summary,
+ install_size,
+ is_delete);
+ }
+
+
+ /**
+ * ProgressPackage percent
+ **/
+ global boolean ProgressPackage ( integer pkg_percent )
+ {
+ HandleInput();
+
+ if (!SlideShow::GetUserAbort())
+ {
+ PackageSlideShow::UpdateCurrentPackageProgress ( pkg_percent );
+ }
+
+ if (SlideShow::GetUserAbort())
+ {
+ y2milestone("Aborted at %1%%", pkg_percent);
+ }
+
+ return ! SlideShow::GetUserAbort();
+ };
+
+ /**
+ * at end of install
+ * just to override the PackageCallbacks default (which does a 'CloseDialog' :-})
+ */
+ global string DonePackage( integer error, string reason )
+ {
+ if (SlideShow::GetUserAbort())
+ return "I";
+ PackageSlideShow::UpdateCurrentPackageProgress (100);
+
+ string ret = "";
+ if (error != 0)
+ {
+ ret = PackageCallbacks::DonePackage( error, reason );
+ }
+ if (size (ret) == 0 || tolower (substring (ret, 0, 1)) != "r")
+ {
+ PackageSlideShow::SlideDisplayDone(
+ PackageCallbacks::_package_name,
+ PackageCallbacks::_package_size,
+ PackageCallbacks::_deleting_package);
+ }
+ return ret;
+ }
+
+
+ /**
+ * at start of file providal
+ */
+ global void StartDeltaProvide( string name, integer archivesize )
+ {
+ PackageSlideShow::SlideGenericProvideStart (name , archivesize, _("Downloading delta RPM %1 (download size %2)"), true /*remote*/);
+ _remote_provide = true;
+ }
+
+ /**
+ * at start of file providal
+ */
+ global void StartDeltaApply( string name )
+ {
+ PackageSlideShow::SlideDeltaApplyStart (name);
+ _remote_provide = true;
+ }
+ /**
+ * at start of file providal
+ */
+ global void StartPatchProvide( string name, integer archivesize )
+ {
+ PackageSlideShow::SlideGenericProvideStart (name , archivesize, _("Downloading patch RPM %1 (download size %2)"), true /*remote*/);
+ _remote_provide = true;
+ }
+
+ /**
+ * during file providal
+ */
+ global void ProgressDeltaApply( integer percent )
+ {
+ PackageSlideShow::UpdateCurrentPackageProgress ( percent );
+ }
+
+ /**
+ * at end of file providal
+ */
+ global void FinishPatchDeltaProvide()
+ {
+ _remote_provide = false;
+ }
+
+ global void ProblemDeltaDownload (string descr) {
+ _remote_provide = false;
+ // error in installation log, %1 is detail error description
+ SlideShow::AppendMessageToInstLog (sformat (_("Failed to download delta RPM: %1"), descr));
+ }
+
+ global void ProblemDeltaApply (string descr) {
+ _remote_provide = false;
+ // error in installation log, %1 is detail error description
+ SlideShow::AppendMessageToInstLog (sformat (_("Failed to apply delta RPM: %1"), descr));
+ }
+
+ global void ProblemPatchDownload (string descr) {
+ _remote_provide = false;
+ // error in installation log, %1 is detail error description
+ SlideShow::AppendMessageToInstLog (sformat (_("Failed to download patch RPM: %1"), descr));
+ }
+
+ /**
+ * change of repository
+ * source: 0 .. n-1
+ * media: 1 .. n
+ **/
+ global void CallbackSourceChange( integer source, integer media)
+ {
+ PackageCallbacks::SourceChange( source, media ); // inform PackageCallbacks about the change
+ PackageSlideShow::SetCurrentCdNo( source, media );
+ PackageSlideShow::UpdateCurrentPackageProgress(0);
+ PackageSlideShow::UpdateAllCdProgress(false);
+ };
+
+ global string MediaChange (string error_code, string error, string url, string product,
+ integer current, string current_label,
+ integer wanted, string wanted_label,
+ boolean double_sided, list<string> devices, integer current_device)
+ {
+ if (!Mode::normal ())
+ {
+ SlideShow::StopTimer();
+ }
+
+ string ret = PackageCallbacks::MediaChange(error_code, error, url, product, current, current_label, wanted,
+ wanted_label, double_sided, devices, current_device);
+
+ if (!Mode::normal ())
+ {
+ SlideShow::StartTimer();
+
+ // moved from PackageCallbacks
+ if (ret == "" || URL::Check(ret))
+ {
+ PackageSlideShow::SetCurrentCdNo (PackageCallbacks::_current_source, wanted);
+ }
+ }
+
+ return ret;
+ }
+
+ /**
+ * Install callbacks for slideshow. Should be in SlideShowCallbacks but
+ * that doesn't work at the moment.
+ */
+ global void InstallSlideShowCallbacks()
+ {
+ y2milestone( "InstallSlideShowCallbacks");
+
+ Pkg::CallbackStartPackage (SlideShowCallbacks::StartPackage);
+ Pkg::CallbackProgressPackage (SlideShowCallbacks::ProgressPackage);
+ Pkg::CallbackDonePackage (SlideShowCallbacks::DonePackage);
+
+ Pkg::CallbackStartProvide (SlideShowCallbacks::StartProvide);
+ Pkg::CallbackProgressProvide (SlideShowCallbacks::ProgressProvide);
+ Pkg::CallbackDoneProvide (SlideShowCallbacks::DoneProvide);
+ Pkg::CallbackProgressDownload(SlideShowCallbacks::ProgressDownload);
+
+ Pkg::CallbackSourceChange (SlideShowCallbacks::CallbackSourceChange);
+
+ Pkg::CallbackStartDeltaDownload (SlideShowCallbacks::StartDeltaProvide);
+ Pkg::CallbackProgressDeltaDownload (SlideShowCallbacks::ProgressProvide);
+ Pkg::CallbackProblemDeltaDownload (SlideShowCallbacks::ProblemDeltaDownload);
+ Pkg::CallbackFinishDeltaDownload (SlideShowCallbacks::FinishPatchDeltaProvide);
+
+ Pkg::CallbackStartDeltaApply (SlideShowCallbacks::StartDeltaApply);
+ Pkg::CallbackProgressDeltaApply (SlideShowCallbacks::ProgressDeltaApply);
+ Pkg::CallbackProblemDeltaApply (SlideShowCallbacks::ProblemDeltaApply);
+ Pkg::CallbackFinishDeltaApply (SlideShowCallbacks::FinishPatchDeltaProvide);
+
+ Pkg::CallbackStartPatchDownload (SlideShowCallbacks::StartPatchProvide);
+ Pkg::CallbackProgressPatchDownload (SlideShowCallbacks::ProgressProvide);
+ Pkg::CallbackProblemPatchDownload (SlideShowCallbacks::ProblemPatchDownload);
+ Pkg::CallbackFinishPatchDownload (SlideShowCallbacks::FinishPatchDeltaProvide);
+
+ Pkg::CallbackScriptStart(SlideShowCallbacks::ScriptStart);
+ Pkg::CallbackScriptProgress(SlideShowCallbacks::ScriptProgress);
+ Pkg::CallbackScriptProblem(SlideShowCallbacks::ScriptProblem);
+ Pkg::CallbackScriptFinish(SlideShowCallbacks::ScriptFinish);
+
+ Pkg::CallbackMessage(PackageCallbacks::Message);
+
+ Pkg::CallbackMediaChange(SlideShowCallbacks::MediaChange);
+ }
+
+ /**
+ * Remove callbacks for slideshow. Should be in SlideShowCallbacks but
+ * that doesn't work at the moment.
+ */
+ global void RemoveSlideShowCallbacks()
+ {
+ y2milestone( "RemoveSlideShowCallbacks");
+
+ Pkg::CallbackStartPackage (nil);
+ Pkg::CallbackProgressPackage (nil);
+ Pkg::CallbackDonePackage (nil);
+
+ Pkg::CallbackStartProvide (nil);
+ Pkg::CallbackProgressProvide (nil);
+ Pkg::CallbackDoneProvide (nil);
+
+ Pkg::CallbackSourceChange (nil);
+
+ Pkg::CallbackStartDeltaDownload (nil);
+ Pkg::CallbackProgressDeltaDownload (nil);
+ Pkg::CallbackProblemDeltaDownload (nil);
+ Pkg::CallbackFinishDeltaDownload (nil);
+
+ Pkg::CallbackStartDeltaApply (nil);
+ Pkg::CallbackProgressDeltaApply (nil);
+ Pkg::CallbackProblemDeltaApply (nil);
+ Pkg::CallbackFinishDeltaApply (nil);
+
+ Pkg::CallbackStartPatchDownload (nil);
+ Pkg::CallbackProgressPatchDownload (nil);
+ Pkg::CallbackProblemPatchDownload (nil);
+ Pkg::CallbackFinishPatchDownload (nil);
+
+ Pkg::CallbackScriptStart(nil);
+ Pkg::CallbackScriptProgress(nil);
+ Pkg::CallbackScriptProblem(nil);
+ Pkg::CallbackScriptFinish(nil);
+
+ Pkg::CallbackMessage(nil);
+ }
+
+}
Added: branches/tmp/visnov/progress/packager/Slides.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/visnov/progress/packager/…
==============================================================================
--- branches/tmp/visnov/progress/packager/Slides.ycp (added)
+++ branches/tmp/visnov/progress/packager/Slides.ycp Fri Aug 29 15:19:13 2008
@@ -0,0 +1,205 @@
+/**
+ * Module: Slides.ycp
+ *
+ * Purpose: Module to access slides from installation repository
+ *
+ * Author: Stefan Hundhammer <sh(a)suse.de>
+ * Stanislav Visnovsky <visnov(a)suse.cz>
+ *
+ */
+{
+ module "Slides";
+
+ textdomain "packager";
+
+ import "FileUtils";
+ import "Installation";
+
+ // list of currently known slides, in the order they should be shown
+ global list<string> slides = [];
+ // base path to look for slides
+ global string slide_base_path = Installation::sourcedir + "/suse/setup/slide";
+ // path to look for texts of slides
+ global string slide_txt_path = "";
+ // path to look for images of slides
+ global string slide_pic_path = "";
+ // if no other language is configured, use this fallback
+ global string fallback_lang = "en";
+
+
+
+ /**
+ * Get a list of available slides (images) for the slide show.
+ * @param lang language of slides to load
+ * @return list slides
+ **/
+ list<string> GetSlideList( string lang )
+ {
+ list<string> slide_list = nil;
+
+ string txt_path = sformat( "%1/txt/%2", slide_base_path, lang );
+ if (FileUtils::Exists (txt_path)) {
+ slide_list = (list<string>) SCR::Read (.target.dir, txt_path );
+ }
+
+ if ( slide_list == nil )
+ {
+ y2error( "Directory %1 does not exist", txt_path );
+ if ( size( lang ) > 2 )
+ {
+ lang = substring( lang, 0, 2 );
+ txt_path = sformat( "%1/txt/%2", slide_base_path, lang );
+
+ if (FileUtils::Exists (txt_path)) {
+ slide_list = (list<string>) SCR::Read (.target.dir, txt_path );
+ }
+ }
+ }
+
+ if ( slide_list == nil )
+ {
+ y2milestone( "Slideshow directory %1 does not exist", txt_path );
+ }
+ else
+ {
+ y2milestone ("Using slides from '%1' (%2 slides)", txt_path, size (slide_list));
+
+ slide_list = sort( filter( string filename, slide_list, ``{
+ // Check for valid extensions - ignore editor save files and other leftover stuff
+ return regexpmatch( filename, ".*\.(rtf|RTF|html|HTML|htm|HTM)$" );
+ } ) );
+
+ y2debug( "GetSlideList(): Slides at %1: %2", txt_path, slide_list );
+ }
+
+ if ( slide_list != nil && size( slide_list ) > 0 ) // Slide texts found
+ {
+ slide_txt_path = txt_path;
+ slide_pic_path = slide_base_path + "/pic";
+
+ y2milestone ("Using TXT: %1, PIC: %2", slide_txt_path, slide_pic_path);
+ }
+ else // No slide texts found
+ {
+ y2debug( "No slides found at %1", txt_path );
+
+ // function calls itself!
+ if ( lang != fallback_lang )
+ {
+ y2debug( "Trying to load slides from fallback: %1", fallback_lang );
+ slide_list = GetSlideList( fallback_lang );
+ }
+ }
+
+ return slide_list;
+ }
+
+
+ /**
+ * Check if showing slides is supported.
+ *
+ * Not to be confused with HaveSlides() which checks if there are slides available.
+ * @return boolean if the current UI is capable of showing slides
+ **/
+ global boolean HaveSlideSupport()
+ {
+ map disp = UI::GetDisplayInfo();
+
+ if (disp != nil // This shouldn't happen, but who knows?
+ && disp["HasImageSupport"]:false
+ && disp["DefaultWidth"]:-1 >= 800
+ && disp["DefaultHeight"]:-1 >= 600
+ && disp["Depth"]:-1 >= 8 )
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+
+ /**
+ * Check if slides are available.
+ *
+ * Not to be confused with HaveSlideSupport() which checks
+ * if slides could be displayed if there are any.
+ * @return boolean if the loaded list of slides contains any slides
+ **/
+ global boolean HaveSlides()
+ {
+ return size( slides ) > 0;
+ }
+
+ /**
+ * Load one slide from files complete with image and textual description.
+ * Also adapt img links
+ * @param slide_name name of the slide
+ * @return true if OK, false if error
+ **/
+ global string LoadSlideFile( string slide_name )
+ {
+ string text_file_name = sformat ("%1/%2", slide_txt_path, slide_name );
+ // returns empty string if not found
+ string text = (string) SCR::Read( .target.string, [text_file_name, ""] );
+
+ //
+ // Fix <img src> tags: Replace image path with current slide_pic_path
+ //
+ while (true)
+ {
+ string replaced = regexpsub( text, "(.*)&imagedir;(.*)",
+ sformat("\\1%1\\2", slide_pic_path ) );
+ if ( replaced == nil ) break;
+ text = replaced;
+ }
+
+ return text;
+ }
+
+
+ /**
+ * Set the slide show directory
+ */
+ global void SetSlideDir( string dir )
+ {
+ slide_base_path = dir;
+
+ map tmp = (map) WFM::Read (.local.stat, slide_base_path);
+
+ if ( ! tmp["isdir"]:false )
+ {
+ y2error( "Using default path instead of %1", tmp );
+ slide_base_path = "/var/adm/YaST/InstSrcManager/tmp/CurrentMedia/suse/setup/slide";
+ }
+
+ y2milestone( "SetSlideDir: %1", slide_base_path );
+ }
+
+ /**
+ * Load slides for the given language and store them in the internal variables.
+ * @param language requested language of the slides
+ */
+ global void LoadSlides( string language )
+ {
+ slides = GetSlideList( language );
+ }
+
+ /**
+ * Check, if the base path set up for slides is valid (it exists and contains slides)
+ * @return boolean true, if it is possible to load the slides
+ */
+ global boolean CheckBasePath()
+ {
+ map tmp = (map) WFM::Read(.local.stat, slide_base_path);
+ if (! tmp["isdir"]:false)
+ {
+ y2error( "Using default path instead of %1", slide_base_path );
+ slide_base_path = "/var/adm/YaST/InstSrcManager/tmp/CurrentMedia/suse/setup/slide";
+
+ return false;
+ }
+ return true;
+ }
+}
Modified: branches/tmp/visnov/progress/packager/inst_rpmcopy.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/visnov/progress/packager/…
==============================================================================
--- branches/tmp/visnov/progress/packager/inst_rpmcopy.ycp (original)
+++ branches/tmp/visnov/progress/packager/inst_rpmcopy.ycp Fri Aug 29 15:19:13 2008
@@ -13,7 +13,7 @@
* Packages module :
* "installed"
*
- * $Id: inst_rpmcopy.ycp 47221 2008-04-30 12:00:20Z locilka $
+ * $Id: inst_rpmcopy.ycp 50357 2008-08-25 12:12:48Z ug $
*/
{
@@ -27,6 +27,7 @@
import "PackageInstallation";
import "Packages";
import "SlideShow";
+ import "PackageSlideShow";
import "SlideShowCallbacks";
import "Popup";
import "Report";
@@ -660,7 +661,31 @@
});
}
- Pkg::PkgSolve (false);
+ list<string> failed = [];
+ list<string> patterns = []; // WORKAROUND, REMOVE!!! AutoinstData::post_patterns;
+ /* set SoftLock to avoid the installation of recommended patterns (#159466) */
+ foreach( map<string,any> p, Pkg::ResolvableProperties ("", `pattern, ""), ``{
+ Pkg::ResolvableSetSoftLock( p["name"]:"", `pattern );
+ });
+ foreach(string p, toset(patterns),
+ ``{
+ if (! Pkg::ResolvableInstall( p, `pattern ) )
+ {
+ failed = add(failed, p);
+ }
+ });
+
+ if (size(failed) > 0 )
+ {
+ y2error("Error while setting pattern: %1", mergestring(failed, ","));
+ Report::Warning(sformat(_("Could not set patterns: %1."), mergestring(failed, ",")));
+ }
+ //
+ // Solve dependencies
+ //
+ if( !Pkg::PkgSolve(false) ) {
+ Report::Error( _("The package resolver run failed. Please check your software section in the autoyast profile.") );
+ }
}
symbol InstallPackagesFromMedia (integer current_cd_no, integer maxnumbercds) {
@@ -849,7 +874,7 @@
RestoreDiskCacheSettings ();
// in 1st stage, this is opened already
- SlideShow::OpenSlideShowDialog ();
+ SlideShow::OpenDialog ();
}
Pkg::TargetLogfile (Installation::destdir + Directory::logdir + "/y2logRPM");
@@ -877,7 +902,7 @@
integer current_cd_no = cdnumbers["current_cd_no"]:1;
// re-initialize package information
- SlideShow::InitPkgData(true);
+ PackageSlideShow::InitPkgData(true);
// we want the table
SlideShow::ShowTable();
// move the progress to the packages stage
@@ -893,7 +918,7 @@
Pkg::PkgCommit (9999);
}
- SlideShow::CloseSlideShowDialog();
+ SlideShow::CloseDialog();
if (result != `abort)
{
Added: branches/tmp/visnov/progress/packager/sw_single.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/visnov/progress/packager/…
==============================================================================
--- branches/tmp/visnov/progress/packager/sw_single.ycp (added)
+++ branches/tmp/visnov/progress/packager/sw_single.ycp Fri Aug 29 15:19:13 2008
@@ -0,0 +1,593 @@
+/**
+ * Module: sw_single.ycp
+ *
+ * Authors: Gabriele Strattner (gs(a)suse.de)
+ * Klaus Kaempf <kkaempf(a)suse.de>
+ *
+ * Purpose: contains dialog loop for workflows:
+ * "Install/Remove software"
+ *
+ * $Id: sw_single.ycp 49329 2008-07-22 15:15:36Z lslezak $
+ *
+ * Note: sw_single accepts a map parameter: $[ "dialog_type" : symbol,
+ * "repo_mgmt" : boolean ]
+ *
+ * "dialog_type" can be `patternSelector, `searchMode, `summaryMode
+ * "repo_mgmt" enables "Repositories" -> "Repository Manager..." menu option
+ */
+
+{
+ textdomain "packager";
+
+ import "Arch";
+ import "Confirm";
+ import "Installation";
+ import "Directory";
+ import "Mode";
+ import "PackageCallbacks";
+ import "PackageLock";
+ import "SlideShow";
+ import "SlideShowCallbacks";
+ import "Kernel";
+ import "Wizard";
+ import "Popup";
+ import "GetInstArgs";
+ import "Label";
+ import "PackageSystem";
+ import "Report";
+ import "FileUtils";
+ import "PackagesUI";
+ import "CommandLine";
+ import "Progress";
+
+symbol StartSWSingle()
+{
+
+ Wizard::CreateDialog();
+ Wizard::SetDesktopIcon("sw_single");
+
+ // a stage in the progress dialog
+ list<string> stages = [_("Initialize the Target System"), _("Load the Configured Repositories")];
+
+ // an extra step is needed in dir inst mode
+ if (Installation::destdir != "/")
+ {
+ y2internal("Extra step is needed");
+ // %1 is path to the target system (e.g. /tmp/dirinstall
+ sformat(_("Reset the target system to %1"), Installation::destdir);
+ }
+
+ // a stage in the progress dialog
+ Progress::New(_("Starting the Package Manager"), "", 2, stages, [], "");
+ Progress::NextStage();
+
+ import "Packages";
+
+ list<string> packagelist = []; // list of packages to act on
+
+ // `install
+ // `remove, `update: used from gnome-main-menu (#222757)
+ symbol action = `install;
+
+ boolean test_popup = false;
+ boolean skip_source = false;
+
+ // =============================================================
+
+ // check test_popup
+ // test_mode is checked for in Installation constructor
+
+ define list<string> CheckArguments ()
+ {
+ integer arg_n = size (WFM::Args()) - 1;
+
+ list<string> arg_list = [];
+
+ while (arg_n >= 0)
+ {
+ if (WFM::Args(arg_n) == .test)
+ {
+ Mode::SetTest ("test");
+ }
+ else if (WFM::Args(arg_n) == .testp)
+ {
+ Mode::SetTest ("test"); // .testp implies .test
+ test_popup = true;
+ }
+ else if (is (WFM::Args(arg_n), string))
+ {
+ string s = tostring (WFM::Args(arg_n));
+ if (s == "--install")
+ action = `install;
+ else if (s == "--remove")
+ action = `remove;
+ else if (s == "--update")
+ action = `update;
+ else
+ arg_list = add (arg_list, s);
+ }
+ else if (is (WFM::Args(arg_n), list))
+ {
+ foreach (any arg, (list)WFM::Args(arg_n), ``{ arg_list = add (arg_list, tostring (arg));});
+ }
+ arg_n = arg_n - 1;
+ }
+
+ y2milestone ("action: %1", action);
+ return arg_list;
+
+ }; // CheckArguments
+
+ //
+ // CheckWhichPackages
+ //
+ // Check arg_list:
+ // If we're called with an absolute package path just install
+ // this package without paying attention to dependencies.
+ //
+ // returns `done all done
+ // `failed package not found
+ // `next workflow "Change source of installation"
+ // `found_descr started package manager
+ // `unknown_descr found nothing
+ //
+
+ define symbol CheckWhichPackages (list<string> arg_list)
+ {
+ PackageSystem::EnsureTargetInit();
+
+ y2milestone ("CheckWhichPackages (%1)", arg_list);
+ // if sw_single is called with a list of packages or a package name
+
+ string first_arg = "";
+
+ if (size (arg_list) > 0)
+ {
+ first_arg = arg_list[0]:"";
+ }
+
+ /*
+ * If the first argument is a package ending with .rpm call Pkg::TargetInstall for
+ * each arg.
+ */
+ if (regexpmatch (first_arg, "\\.rpm$")) // package name given
+ {
+ // if sw_single is called with an absolute package-pathname, there is no need to
+ // mount the source medium or check SuSE version or dependencies
+
+ Pkg::TargetLogfile (Installation::destdir + Directory::logdir + "/y2logRPM");
+
+ SlideShow::InitPkgData(true); // force reinitialization
+
+ foreach (string package, arg_list, {
+ if (SCR::Read (.target.size, package) > 0)
+ {
+ y2milestone ("SW_SINGLE: installing %1", package);
+ boolean installed = Pkg::TargetInstall (package);
+
+ if (!installed)
+ {
+ // Error message:
+ // %1 = package name (may include complete RPM file name)
+ // %2 = error message
+ Report::Error(sformat(_("Package %1 could not be installed.
+
+Details:
+%2
+"), package, Pkg::LastError()));
+ }
+ }
+ else
+ {
+ // error popup, %1 is the name of the .rpm package
+ string message = sformat (_("Package %1 was not found on the medium."), package);
+ y2error ("SW_SINGLE: Package %1 was not found on the medium", package);
+ Popup::Message (message);
+ return `failed;
+ }
+ });
+
+ // package is installed without paying attention to SuSE dependencies
+ // don't call SuSEConfig -> dialog loop ends
+ return `done;
+ }
+ else if (first_arg != "") // firstarg given, but not *.rpm
+ {
+ string arg_name = arg_list[0]:"";
+
+ if ( ! FileUtils::IsFile(arg_name) || FileUtils::GetSize(arg_name) <= 0 ) // Check: a local file ? bigger than 0?
+ {
+ packagelist = arg_list; // No: expect package names
+ }
+ else // Yes: try to read the file
+ {
+ y2milestone("Reading file %1", arg_name );
+ packagelist = (list<string>) SCR::Read( .target.ycp, arg_name); // try .ycp list first
+ if ((packagelist == nil)
+ || (packagelist == []))
+ {
+ string packagestr = (string) SCR::Read( .target.string, arg_name); // string ascii file next
+ packagelist = splitstring (packagestr, "\n");
+ // filter empty lines out, bug #158226
+ packagelist = filter (string package, packagelist, { return !regexpmatch(package, "^ *$"); });
+ }
+ }
+ y2milestone("packagelist: %1", packagelist );
+ }
+
+ // start package manager
+ const boolean enabled_only = true;
+
+ Progress::NextStage();
+ boolean mgr_ok = Pkg::SourceStartManager(enabled_only);
+ if (!mgr_ok)
+ {
+ Report::LongWarning(_("There was an error in the repository initialization.") + "\n" + Pkg::LastError ());
+ }
+ if (size(Pkg::SourceGetCurrent(enabled_only)) == 0)
+ {
+
+ Report::Warning(_("No repository is defined.
+Only installed packages are displayed."));
+ }
+
+ // reset the target if needed (e.g. dirinstall mode)
+ // EnsureTargetInit() uses "/" as root
+ if (Installation::destdir != "/")
+ {
+ y2milestone("Setting a new target: %1", Installation::destdir);
+ Progress::NextStage();
+ Pkg::TargetInit (Installation::destdir, false);
+ }
+
+ return `found_descr;
+
+ }; // CheckWhichPackages
+
+ // originally stolen from inst_do_net_test.ycp:IsDownloadedVersionNewer
+ /**
+ * Function checks two versions of installed rpm and decides
+ * whether the second one is newer than the first one. This
+ * function ignores non-numerical values in versions.
+ * Version and Release parts are merged!
+ * FIXME make a binding to librpm.
+ * @param string first version
+ * @param string second version
+ * @return boolean true if the second one is newer than the first one
+ */
+ boolean VersionALtB (string a_version, string b_version) {
+ list <string> a_version_l = filter(string s, splitstring(a_version, "-\."), {
+ return regexpmatch(s, "^[0123456789]+$");
+ });
+ list <string> b_version_l = filter(string s, splitstring(b_version, "-\."), {
+ return regexpmatch(s, "^[0123456789]+$");
+ });
+
+ y2milestone("Comparing versions %1 and %2", a_version_l, b_version_l);
+ integer a_size = size (a_version_l);
+ integer b_size = size (b_version_l);
+ integer longer_size = a_size > b_size? a_size: b_size;
+
+ boolean b_version_is_newer = false;
+ integer compare = 0; // <0 if a<b, =0 if a==b, >0 if a>b
+ integer i = 0;
+ while (i < longer_size) {
+ // -1 will make the desirable outcome of "2" < "2.0"
+ integer a_item = tointeger(a_version_l[i]:"-1");
+ integer b_item = tointeger(b_version_l[i]:"-1");
+ if (a_item < b_item) {
+ compare = -1;
+ break;
+ }
+ if (a_item > b_item) {
+ compare = 1;
+ break;
+ }
+ i = i + 1;
+ };
+
+ y2milestone("%1 <=> %2 -> %3", a_version, b_version, compare);
+ return compare < 0;
+ }
+
+ /**
+ * Check if there is an uninstalled package of the same name with a
+ * higher version. Otherwise we would forcefully reinstall it. #222757#c9
+ */
+ boolean CanBeUpdated (string package) {
+ list< map<string,any> > props = Pkg::ResolvableProperties (package, `package, "" /*any version*/);
+ // find maximum version and remember
+ // if it is installed
+ string max_ver = "0";
+ boolean max_is_installed = false;
+ foreach (map<string,any> prop, props, {
+ string cur_ver = prop["version"]:"0";
+ if (VersionALtB (max_ver, cur_ver)) {
+ max_ver = cur_ver;
+ // `installed or `selected is ok
+ max_is_installed = prop["status"]:`available != `available;
+ y2milestone ("new max: installed: %1", max_is_installed);
+ }
+ });
+ return !max_is_installed;
+ }
+
+ map GetPackagerOptions()
+ {
+ // defaults
+ symbol mode = nil;
+ boolean repo_management = nil;
+
+ y2milestone("Args: %1", WFM::Args());
+
+ foreach(any a, WFM::Args(),
+ {
+ if (is(a, map))
+ {
+ map m = (map)a;
+
+ if (haskey(m, "dialog_type"))
+ {
+ mode = m["dialog_type"]:`searchMode;
+ }
+
+ if (haskey(m, "repo_mgmt"))
+ {
+ repo_management = m["repo_mgmt"]:false;
+ }
+ }
+ }
+ );
+
+ // use default parameters for missing or invalid values
+ if (mode == nil)
+ {
+ mode = `searchMode;
+ }
+ if (repo_management == nil)
+ {
+ repo_management = Mode::normal();
+ }
+
+ map ret = $[ "dialog_type" : mode, "repo_mgmt" : repo_management ];
+
+ y2milestone("inst_packages config: %1", ret);
+
+ return ret;
+ }
+
+ // =============================================================
+
+
+ // check whether running as root
+ // and having the packager for ourselves
+ if (! Confirm::MustBeRoot ())
+ {
+ UI::CloseDialog ();
+ return `abort;
+ }
+
+ if (!PackageLock::Connect(false)["connected"]:false)
+ {
+ // SW management is already in use, access denied
+ // the yast module cannot be started
+ UI::CloseDialog ();
+ return `abort;
+ }
+
+ // check Args
+ // set test_mode, test_popup
+ list<string> arg_list = CheckArguments();
+
+ // check the arguments and try the mount/search for local description
+ symbol result = CheckWhichPackages (arg_list);
+
+ Progress::Finish();
+
+ Pkg::SetTextLocale (UI::GetLanguage (true));
+
+ y2milestone ("SW_SINGLE: result CheckWhichPackages %1", result);
+
+ if ((result == `done)
+ || (result == `failed))
+ {
+ UI::CloseDialog();
+ return `next;
+ }
+
+
+ boolean force_restart = false;
+ boolean found_descr = result == `found_descr;
+
+ do
+ {
+ force_restart = false;
+
+ list<string> old_failed_packs = [];
+ if ((integer)SCR::Read (.target.size,
+ "/var/lib/YaST2/failed_packages") > 0)
+ {
+ old_failed_packs = (list<string>)
+ SCR::Read (.target.ycp, "/var/lib/YaST2/failed_packages");
+ }
+ if (size (old_failed_packs) > 0 && Popup::YesNo (
+_("During the last package installation,
+several package failed to install.
+Install them now?
+")))
+ {
+ foreach (string p, old_failed_packs, {
+ Pkg::PkgInstall (p);
+ });
+ }
+
+ if ( found_descr )
+ {
+ if (size (packagelist) == 0) // packages given ?
+ {
+ // names of taboo packages
+ list<string> taboo_packages = Pkg::GetPackages(`taboo, true);
+
+ map opts = GetPackagerOptions();
+ y2milestone("Using packager widget options: %1", opts);
+
+ result = (symbol)WFM::CallFunction( "inst_packages", [opts]); // No: ask user via package selection widget
+ y2milestone ("inst_packages returns %1", result);
+ if (result == `accept)
+ {
+ result = `next;
+ }
+ // start the repository manager
+ else if (result == `repo_mgr)
+ {
+ symbol repo_result = (symbol)WFM::CallFunction( "repositories", [ `sw_single_mode ]);
+
+ if (repo_result != `abort)
+ {
+ force_restart = true;
+ }
+ }
+ }
+ else
+ {
+ list<string>nonexisting = filter (string p, packagelist, {
+ return ! Pkg::IsAvailable (p);
+ });
+ if (action != `remove && size (nonexisting) > 0)
+ {
+ string missing = mergestring (nonexisting, ", ");
+ y2error ("Tags %1 aren't available",
+ mergestring (nonexisting, ", "));
+ Report::LongError (sformat (
+ // error report, %1 is a list of packages
+ _("Following packages haven't been found on the medium:\n%1"),
+ mergestring (nonexisting, "\n")));
+ return `cancel;
+ }
+ foreach (string package, packagelist, // Yes: install them
+ {
+ if (action == `install
+ // TODO `update: tell the user if already up to date
+ || (action == `update && CanBeUpdated (package))) {
+ // select package for installation
+ if (!Pkg::PkgInstall (package)) {
+ // oops, package not found ? try capability
+ Pkg::DoProvide ([package]);
+ }
+ }
+ else if (action == `remove) {
+ if (!Pkg::PkgDelete (package)) {
+ // package failed, try capability
+ Pkg::DoRemove ([package]);
+ }
+ }
+ });
+
+ // confirm removal by user (bnc#399795)
+ if (action == `remove)
+ {
+ map opts = $[ "dialog_type" : `summaryMode, "repo_mgmt" : true ];
+ y2milestone("Using packager widget options: %1", opts);
+
+ result = (symbol)WFM::CallFunction( "inst_packages", [opts]);
+
+ if (result != `accept)
+ return `abort;
+ }
+
+ if (Pkg::PkgSolve (false)) // Solve dependencies
+ {
+ result = `next; // go-on if no conflicts
+ }
+ else
+ {
+ result = (symbol)WFM::CallFunction( "inst_packages", [ $["repo_mgmt" : true] ]); // Ask user if conflicts
+ y2milestone ("inst_packages returns %1", result);
+ if (result == `accept)
+ result = `next;
+ }
+ }
+ }
+
+ if (result == `next) // packages selected ?
+ {
+ // ask user to confirm all remaining licenses (#242298)
+ boolean licenses_accepted = PackagesUI::ConfirmLicenses();
+
+ // all licenses accepted?
+ if (!licenses_accepted)
+ {
+ // no, go back to the package selection
+ force_restart = true;
+ continue;
+ }
+
+ SCR::Write (.target.ycp, "/var/lib/YaST2/failed_packages", []);
+ boolean anyToDelete = Pkg::PkgAnyToDelete();
+ SlideShow::SetLanguage (UI::GetLanguage(true));
+ SlideShow::InitPkgData(true); // force reinitialization
+ SlideShow::OpenSlideShowDialog();
+
+ list< map<string,any> > stages = [
+ $[
+ "name" : "packages",
+ "description": _("Installing Packages..."),
+ "value" : SlideShow::total_size_to_install / 1024 , // kilobytes
+ "units" : `kb,
+ ],
+ ];
+
+ SlideShow::Setup( stages );
+
+ SlideShow::MoveToStage( "packages" );
+
+ import "PackageInstallation";
+ Pkg::TargetLogfile (Installation::destdir + Directory::logdir + "/y2logRPM");
+ integer oldvmlinuzsize = (integer) SCR::Read(.target.size, "/boot/vmlinuz");
+ list commit_result = PackageInstallation::CommitPackages (0, 0); // Y: commit them !
+ integer newvmlinuzsize = (integer) SCR::Read(.target.size, "/boot/vmlinuz");
+
+ SlideShow::CloseSlideShowDialog();
+
+ if (Mode::normal () // run SuSEconfig only in normal system, not during installation
+ && Installation::destdir == "/"
+ && ((commit_result[0]:0 > 0)
+ || anyToDelete))
+ {
+ // prepare "you must boot" popup in inst_suseconfig
+ Kernel::SetInformAboutKernelChange (oldvmlinuzsize != newvmlinuzsize);
+
+ result = (symbol) WFM::CallFunction ("inst_suseconfig", [GetInstArgs::Buttons(false, false)]);
+ }
+ }
+ } while ( force_restart );
+
+ UI::CloseDialog();
+
+ return (symbol) result;
+}
+
+/*
+ * Start commandline interface only when the parameter is "help", otherwise start standard GUI.
+ * The reason is that "yast2 -i package" is translated to "yast2 sw_single package",
+ * we don't know wheter "package" is a command or a package name.
+ * Package name is assumed for backward compatibility.
+ */
+if (WFM::Args() == ["help"])
+{
+ map cmdline_description = $[
+ "id" : "sw_single",
+ /* Command line help text for the software management module, %1 is "zypper" */
+ "help" : sformat(_("Software installation - this module doesn't support the command line interface, use '%1' instead."), "zypper"),
+ "guihandler" : StartSWSingle,
+ ];
+
+ return CommandLine::Run(cmdline_description);
+}
+else
+{
+ return StartSWSingle();
+}
+
+}
+
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r50483 - in /trunk/storage/storage/src/include: custom_part_check_generated.ycp custom_part_dialogs.ycp custom_part_helptexts.ycp
by aschnell@svn.opensuse.org 29 Aug '08
by aschnell@svn.opensuse.org 29 Aug '08
29 Aug '08
Author: aschnell
Date: Fri Aug 29 15:02:17 2008
New Revision: 50483
URL: http://svn.opensuse.org/viewcvs/yast?rev=50483&view=rev
Log:
- removed "EVMS" from text messages
Modified:
trunk/storage/storage/src/include/custom_part_check_generated.ycp
trunk/storage/storage/src/include/custom_part_dialogs.ycp
trunk/storage/storage/src/include/custom_part_helptexts.ycp
Modified: trunk/storage/storage/src/include/custom_part_check_generated.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/cust…
==============================================================================
--- trunk/storage/storage/src/include/custom_part_check_generated.ycp (original)
+++ trunk/storage/storage/src/include/custom_part_check_generated.ycp Fri Aug 29 15:02:17 2008
@@ -341,8 +341,7 @@
});
- whole_disk = whole_disk || diskinfo["type"]:`CT_UNKNOWN==`CT_LVM ||
- diskinfo["type"]:`CT_UNKNOWN==`CT_EVMS;
+ whole_disk = whole_disk || diskinfo["type"]:`CT_UNKNOWN==`CT_LVM;
diskinfo = add( diskinfo, "whole_disk", whole_disk );
all_whole_disk = all_whole_disk && whole_disk;
targetMap = add( targetMap, disk, diskinfo );
@@ -742,11 +741,6 @@
if( !tg["/dev/"+p["used_by"]:"","create"]:false )
ppl = add( ppl, p );
}
- else if( p["used_by_type"]:`UB_NONE==`UB_EVMS )
- {
- if( !tg["/dev/evms/"+p["used_by"]:"","create"]:false )
- ppl = add( ppl, p );
- }
});
pl = ppl;
}
@@ -788,13 +782,6 @@
Remove it from the volume group before editing it.
"),curr_part["used_by"]:"" ));
}
- else if( used == `UB_EVMS )
- {
- // popup text %1 is replaced by a name e.g. system
- Popup::Message(sformat(_("The selected device is used by EVMS volume (%1).
-Remove the EVMS volume before editing it.
-"), curr_part["used_by"]:"" ));
- }
else if( used != `UB_NONE )
{
// popup text %1 is replaced by a name e.g. system
@@ -847,17 +834,9 @@
Remove it from the RAID before deleting it.
"), curr_part["used_by"]:"", part_name ));
}
-
- else if( used == `UB_EVMS)
- {
- // popup text %2 is a device name, %1 is the EVMS name
- Popup::Message(sformat(_("The device (%2) is used by EVMS object (%1).
-Remove the EVMS object before deleting it.
-"), curr_part["used_by"]:"", part_name ));
- }
else
{
- // popup text %2 is a device name, %1 is the EVMS name
+ // popup text, %1 and %2 are device names
Popup::Message(sformat(_("The device (%2) is used by %1.
Remove %1 before deleting it.
"), curr_part["used_by"]:"", part_name ));
@@ -929,7 +908,7 @@
}
if( !ok )
{
- // popup text %2 is a device name, %1 is the EVMS name
+ // popup text, %1 is a device name
Popup::Message(sformat(_("The device (%1) cannot be removed
Since it is a logical partition and another logical
partition with higher number is in use.
@@ -1023,15 +1002,6 @@
deleting the extended partition.
"));
}
- else if( used == `UB_EVMS )
- {
- // popup text, Do not translate EVMS.
- Popup::Message(_("
-The selected extended partition contains at least one partition
-that is used by an EVMS volume. Remove the EVMS volume
-before deleting the extended partition.
-"));
- }
else if( used != `UB_NONE )
{
// popup text, Do not translate RAID.
Modified: trunk/storage/storage/src/include/custom_part_dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/cust…
==============================================================================
--- trunk/storage/storage/src/include/custom_part_dialogs.ycp (original)
+++ trunk/storage/storage/src/include/custom_part_dialogs.ycp Fri Aug 29 15:02:17 2008
@@ -1610,15 +1610,6 @@
deleting the device.
"));
}
- else if( used == `UB_EVMS )
- {
- // popup text, Do not translate EVMS.
- Popup::Message(_("
-The selected device contains at least one partition
-that is used by an EVMS device. Delete the EVMS device
-before deleting the device.
-"));
- }
else if( used != `UB_NONE )
{
// popup text
Modified: trunk/storage/storage/src/include/custom_part_helptexts.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/cust…
==============================================================================
--- trunk/storage/storage/src/include/custom_part_helptexts.ycp (original)
+++ trunk/storage/storage/src/include/custom_part_helptexts.ycp Fri Aug 29 15:02:17 2008
@@ -311,7 +311,7 @@
");
// helptext expert partitioning. 19
help_text = help_text + _("<p>
-<b>Used By</b> tells if a device is used by LVM, RAID or EVMS. If you do not use such
+<b>Used By</b> tells if a device is used by LVM or RAID. If you do not use such
things, it is perfectly normal for this column to be empty.
</p>
");
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
29 Aug '08
Author: jsmeix
Date: Fri Aug 29 14:48:46 2008
New Revision: 50482
URL: http://svn.opensuse.org/viewcvs/yast?rev=50482&view=rev
Log:
Created tag stable-2_17_7 for printer
Added:
tags/stable-2_17_7/printer/
- copied from r50481, trunk/printer/
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r50481 - in /trunk/printer: VERSION package/yast2-printer.changes src/Printerlib.ycp src/basicmodify.ycp src/overview.ycp src/printingvianetwork.ycp tools/cups_client_only
by jsmeix@svn.opensuse.org 29 Aug '08
by jsmeix@svn.opensuse.org 29 Aug '08
29 Aug '08
Author: jsmeix
Date: Fri Aug 29 14:48:36 2008
New Revision: 50481
URL: http://svn.opensuse.org/viewcvs/yast?rev=50481&view=rev
Log:
- Some code cleanup.
- 2.17.7
Modified:
trunk/printer/VERSION
trunk/printer/package/yast2-printer.changes
trunk/printer/src/Printerlib.ycp
trunk/printer/src/basicmodify.ycp
trunk/printer/src/overview.ycp
trunk/printer/src/printingvianetwork.ycp
trunk/printer/tools/cups_client_only
Modified: trunk/printer/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/VERSION?rev=50481&r1=504…
==============================================================================
--- trunk/printer/VERSION (original)
+++ trunk/printer/VERSION Fri Aug 29 14:48:36 2008
@@ -1 +1 @@
-2.17.6
+2.17.7
Modified: trunk/printer/package/yast2-printer.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/package/yast2-printer.ch…
==============================================================================
--- trunk/printer/package/yast2-printer.changes (original)
+++ trunk/printer/package/yast2-printer.changes Fri Aug 29 14:48:36 2008
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Fri Aug 29 14:45:28 CEST 2008 - jsmeix(a)suse.de
+
+- Some code cleanup.
+- 2.17.7
+
+-------------------------------------------------------------------
Thu Aug 28 18:19:32 CEST 2008 - jsmeix(a)suse.de
- Fixed build (new scripts were not packaged).
Modified: trunk/printer/src/Printerlib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/Printerlib.ycp?rev=5…
==============================================================================
--- trunk/printer/src/Printerlib.ycp (original)
+++ trunk/printer/src/Printerlib.ycp Fri Aug 29 14:48:36 2008
@@ -10,22 +10,6 @@
// rpm -qlp /work/CDs/all/full-sle10-sp2*/suse/*/yast2-printer.rpm | grep '/YaST2/bin/' | grep -v '/usr/lib/YaST2/bin/'
global string yast_bin_dir = "/usr/lib/YaST2/bin/";
-// By default there is no active "ServerName" entry in /etc/cups/client.conf:
-global boolean client_only = false;
-global string client_conf_server_name = "";
-
-// By default there is "Browsing On" in /etc/cups/cupsd.conf
-// which is even the fallback if there is no "Browsing" entry at all
-// or when the "Browsing" entry is deactivated by a leading '#' character.
-// Therefore browsing_on is only false if "Browsing Off" or "Browsing No"
-// is explicitely set in /etc/cups/cupsd.conf.
-global boolean browsing_on = true;
-
-// By default there is "BrowseAllow all" in /etc/cups/cupsd.conf
-// which is even the fallback if there is no "BrowseAllow" entry at all
-// or when the "BrowseAllow" entries are deactivated by a leading '#' character.
-global string cupsd_conf_browse_allow = "all";
-
// The result map is used as a simple common local store for whatever additional results
// (in particular commandline exit code, stdout, stderr, and whatever messages)
// so that the local functions in this module can be of easy-to-use boolean type.
@@ -57,41 +41,97 @@
return true;
}
-global map<string, any> operation_policy = $[];
-
-global map<string, any> cups_autoconfig = $[];
+// By default there is no active "ServerName" entry in /etc/cups/client.conf:
+global string client_conf_server_name = "";
+global boolean client_only = false;
-global void Read()
-{ // Determine the 'Browsing [ On | Off ]' value in /etc/cups/cupsd.conf:
- if( Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "modify_cupsd_conf Browsing" ) )
- { // Ignore when this command fails and use the fallback "Printerlib::browsing_on = true"
- string browsing = tolower( Printerlib::result["stdout"]:"On" );
- if( "off" == browsing || "no" == browsing )
- { Printerlib::browsing_on = false;
- }
- }
- // Determine the 'BrowseAllow [ all | none | @LOCAL | IP-address[/netmask] ]' values in /etc/cups/cupsd.conf:
- if( Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "modify_cupsd_conf BrowseAllow" ) )
- { // Ignore when this command fails and use the fallback "Printerlib::cupsd_conf_browse_allow = "all"
- Printerlib::cupsd_conf_browse_allow = Printerlib::result["stdout"]:"all";
- }
- // Determine the 'ServerName' value in /etc/cups/client.conf:
- if( Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "cups_client_only" ) )
- { // Ignore when this command fails and use the fallback "Printerlib::client_only = false"
- // and the fallback "Printerlib::client_conf_server_name = ""
- Printerlib::client_conf_server_name = Printerlib::result["stdout"]:"";
- if( "" != Printerlib::client_conf_server_name
- && "localhost" != Printerlib::client_conf_server_name )
- { // Note that even 'localhost' is a valid ServerName value
+global boolean DetermineClientOnly()
+{ // Determine the 'ServerName' value in /etc/cups/client.conf:
+ if( ExecuteBashCommand( yast_bin_dir + "cups_client_only" ) )
+ { client_conf_server_name = result["stdout"]:"";
+ if( "" != client_conf_server_name
+ && "localhost" != client_conf_server_name
+ && "127.0.0.1" != client_conf_server_name )
+ { // Note that even 'localhost' or '127.0.0.1' is a valid ServerName value
// which is used to force client tools (e.g. lpadmin, lpinfo, lpstat)
- // to ask the local cupsd via the IPP port on localhost (localhost:631)
+ // to ask the local cupsd via the IPP port on localhost (127.0.0.1:631)
// and not via the domain socket (/var/run/cups/cups.sock) because
// the latter failed in the past for certain third-party clients (e.g. Java).
// If the ServerName value in /etc/cups/client.conf is 'localhost'
// it is actually no client-only config because the local cupsd is used.
- Printerlib::client_only = true;
+ client_only = true;
+ }
+ else
+ { client_only = false;
}
}
+ else
+ { client_conf_server_name = "";
+ client_only = false;
+ }
+ // Ignore when it fails:
+ return true;
+}
+
+// By default there is "Browsing On" in /etc/cups/cupsd.conf
+// which is even the fallback if there is no "Browsing" entry at all
+// or when the "Browsing" entry is deactivated by a leading '#' character.
+// Therefore browsing_on is only false if "Browsing Off" or "Browsing No"
+// is explicitely set in /etc/cups/cupsd.conf.
+global boolean browsing_on = true;
+
+global boolean DetermineBrowsing()
+{ // Determine the 'Browsing [ On | Off ]' value in /etc/cups/cupsd.conf:
+ if( ExecuteBashCommand( yast_bin_dir + "modify_cupsd_conf Browsing" ) )
+ { string browsing = tolower( result["stdout"]:"On" );
+ if( "off" == browsing || "no" == browsing )
+ { browsing_on = false;
+ }
+ else
+ { browsing_on = true;
+ }
+ }
+ // Ignore when it fails:
+ return true;
+}
+
+// By default there is "BrowseAllow all" in /etc/cups/cupsd.conf
+// which is even the fallback if there is no "BrowseAllow" entry at all
+// or when the "BrowseAllow" entries are deactivated by a leading '#' character.
+// Multiple BrowseAllow lines are allowed, e.g.:
+// BrowseAllow from @LOCAL
+// BrowseAllow from 192.168.200.1
+// BrowseAllow from 192.168.100.0/255.255.255.0
+// so that each BrowseAllow line value is stored as one string
+// in the cupsd_conf_browse_allow list of strings:
+global list< string > cupsd_conf_browse_allow = [ "all" ];
+
+global boolean DetermineBrowseAllow()
+{ // Determine the 'BrowseAllow [ all | none | @LOCAL | IP-address[/netmask] ]' values in /etc/cups/cupsd.conf:
+ if( ExecuteBashCommand( yast_bin_dir + "modify_cupsd_conf BrowseAllow" ) )
+ { // The command outputs a line where multiple BrowseAllow values are separated by space
+ // but possible duplicate BrowseAllow values are not removed in the command output:
+ cupsd_conf_browse_allow = toset( splitstring( Printerlib::result["stdout"]:"all", " " ) );
+ }
+ else
+ { cupsd_conf_browse_allow = [ "all" ];
+ }
+ // Ignore when it fails:
+ return true;
+}
+
+global map<string, any> operation_policy = $[];
+
+global map<string, any> cups_autoconfig = $[];
+
+global void Read()
+{ // Determine the 'Browsing [ On | Off ]' value in /etc/cups/cupsd.conf and ignore when it fails:
+ DetermineBrowsing();
+ // Determine the 'BrowseAllow [ all | none | @LOCAL | IP-address[/netmask] ]'
+ // values in /etc/cups/cupsd.conf and ignore when it fails:
+ DetermineBrowseAllow();
+ // Determine the 'ServerName' value in /etc/cups/client.conf and ignore when it fails:
+ DetermineClientOnly();
// Read cups-autoconfiguration settings:
cups_autoconfig = (map<string, any>)SCR::Read(.etc.cups-auto.all);
y2internal("read cups-auto %1", cups_autoconfig);
Modified: trunk/printer/src/basicmodify.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/basicmodify.ycp?rev=…
==============================================================================
--- trunk/printer/src/basicmodify.ycp (original)
+++ trunk/printer/src/basicmodify.ycp Fri Aug 29 14:48:36 2008
@@ -446,10 +446,13 @@
Wizard::EnableNextButton();
}
else
- { Popup::TimedMessage( // Message of a Popup where %1 will be replaced by the queue name:
- sformat( _("Nothing changed for queue %1."), name ),
- 2
+ { Popup::ShowFeedback( // No title for such a simple feedback message:
+ "",
+ // Message of a Popup::ShowFeedback when nothing was changed:
+ _("Nothing changed.")
);
+ sleep( 1000 );
+ Popup::ClearFeedback();
}
// Exit this dialog in any case:
break;
Modified: trunk/printer/src/overview.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/overview.ycp?rev=504…
==============================================================================
--- trunk/printer/src/overview.ycp (original)
+++ trunk/printer/src/overview.ycp Fri Aug 29 14:48:36 2008
@@ -87,14 +87,11 @@
// By default there is no /etc/cups/client.conf file at all
// and usually there is no ServerName entry in a /etc/cups/client.conf file.
// Therefore client_only is only true if there is a /etc/cups/client.conf file
- // with an active ServerName entry:
+ // with an active ServerName entry which is not "localhost" or "127.0.0.1".
if( Printerlib::client_only )
- { // YCP string quoting: A double backslash '\\' results a single backslash '\' in the string.
- // At least the trailing newline character must be removed.
-
- if( Printerlib::client_conf_server_name == "localhost" )
- {
- local_content_selected = true;
+ { if( Printerlib::client_conf_server_name == "localhost"
+ || Printerlib::client_conf_server_name == "127.0.0.1" )
+ { local_content_selected = true;
remote_content_selected = true;
}
else
@@ -104,11 +101,9 @@
}
}
if( local_cupsd_required && ! local_cupsd_accessible )
- {
- Popup::ErrorDetails( _("Start local running CUPS daemon"),
- _("A local running CUPS daemon is needed for your setup.")
- );
-
+ { Popup::ErrorDetails( _("Start local running CUPS daemon"),
+ _("A local running CUPS daemon is needed for your setup.")
+ );
if( ! Service::Start("cups") )
{ Report::Error( // Message of a Report::Error.
// Only a simple message because this error does not happen on a normal system
@@ -180,21 +175,20 @@
_("Do not delete it"),
`focus_no
))
- {
- // To be safe invalidate Printer::selected_queues_index in any case:
- Printer::selected_queues_index = -1;
- y2milestone( "To be deleted:'%1', selected_queue_index = %2", queue_name, selected_queue_index );
- if( ! Printer::DeleteQueue( queue_name ) )
- { Popup::Error( // Message of a Popup::Error
- // where %1 will be replaced by the queue name.
- // Only a simple message because before the function Printer::DeleteQueue
- // was called and this function would have shown more specific messages.
- sformat( _("Failed to delete queue %1."), queue_name )
- );
- }
- // Re-run the OverviewDialog (with a re-created list of queues) via the sequencer:
- return `delete;
- }
+ { // To be safe invalidate Printer::selected_queues_index in any case:
+ Printer::selected_queues_index = -1;
+ y2milestone( "To be deleted:'%1', selected_queue_index = %2", queue_name, selected_queue_index );
+ if( ! Printer::DeleteQueue( queue_name ) )
+ { Popup::Error( // Message of a Popup::Error
+ // where %1 will be replaced by the queue name.
+ // Only a simple message because before the function Printer::DeleteQueue
+ // was called and this function would have shown more specific messages.
+ sformat( _("Failed to delete queue %1."), queue_name )
+ );
+ }
+ // Re-run the OverviewDialog (with a re-created list of queues) via the sequencer:
+ return `delete;
+ }
}
if (event["EventReason"]:"" == "Activated" && event["ID"]:nil == `test){
@@ -226,11 +220,12 @@
return nil;
}
if( "local" == Printer::queues[selected_queue_index,"config"]:"remote" )
- Printer::selected_queues_index = selected_queue_index;
+ { Printer::selected_queues_index = selected_queue_index;
+ }
if( ! Printerlib::ExecuteBashCommand( "/usr/bin/lp -d '"
- + queue_name
- + "' -o page-label=\"Testprint:$(hostname)\" /usr/share/cups/data/testprint.ps"
- )
+ + queue_name
+ + "' -o page-label=\"Testprint:$(hostname)\" /usr/share/cups/data/testprint.ps"
+ )
)
{ Popup::Error( // Message of a Popup::Error
// where %1 will be replaced by the queue name.
@@ -251,18 +246,20 @@
if (event["EventReason"]:"" == "Activated" && event["ID"]:nil == `add){
// client only
- if( Printerlib::client_only && Printerlib::client_conf_server_name != "localhost" )
+ if( Printerlib::client_only
+ && Printerlib::client_conf_server_name != "localhost"
+ && Printerlib::client_conf_server_name != "127.0.0.1" )
{ if( ! Popup::YesNoHeadline( "Disable remote CUPS server setting",
"A remote CUPS server setting conflicts with adding a print queue."
)
)
return nil;
- // Disable the 'ServerName' entry in /etc/cups/client.conf:
- if( ! Printerlib::ExecuteBashCommand( "sed -i.yast2.save -e 's/^[Se][Ee][Rr][Vv][Ee][Rr][Nn][Aa][Mm][Ee]/#ServerName/' /etc/cups/client.conf" ) )
+ // Remove the 'ServerName' entry in /etc/cups/client.conf:
+ if( ! Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "cups_client_only none" ) )
{ Report::Error( // Message of a Report::Error.
// Only a simple message because this error does not happen on a normal system
// (i.e. a system which is not totally broken or totally messed up).
- _("Failed to disable the 'ServerName' entry in /etc/cups/client.conf")
+ _("Failed to remove the 'ServerName' entry in /etc/cups/client.conf")
);
return nil;
}
Modified: trunk/printer/src/printingvianetwork.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/printingvianetwork.y…
==============================================================================
--- trunk/printer/src/printingvianetwork.ycp (original)
+++ trunk/printer/src/printingvianetwork.ycp Fri Aug 29 14:48:36 2008
@@ -41,101 +41,170 @@
include "printer/helps.ycp";
-term widgetNetworkPrinting =
- `VBox( `VStretch(),
- `Frame( _("Use CUPS to Print Via Network"),
- `RadioButtonGroup( `id(`browsing_or_client_only_check_boxs),
- `VBox( `Left( `RadioButton( `id(`cupsd_conf_browsing_off_radio_button),
- `opt(`notify),
- _("&Do not Receive Printer Information from Remote CUPS servers")
- )
- ),
- `Left( `RadioButton( `id(`cupsd_conf_browsing_on_radio_button),
- `opt(`notify),
- _("Receive Printer &Information from Remote CUPS servers")
- )
- ),
- `HBox( `HSpacing( 3 ),
- `TextEntry( `id(`cupsd_conf_browse_allow_input),
- _("Accept Information from those &Servers (separated by a space)")
- )
- ),
- `VSpacing( 1 ),
- `Left( `RadioButton( `id(`client_only_radio_button),
- `opt(`notify),
- _("Do All Your Printing Directly via &One Remote CUPS Server")
- )
- ),
- `HBox( `HSpacing( 3 ),
- `HWeight( 2,
- `TextEntry( `id(`client_conf_server_name_input),
- _("&Hostname / IP Address")
- )
- ),
- `HWeight( 1,
- `PushButton( `id(`test_client_conf_server),
- _("&Test Server")
- )
- ),
- `HStretch()
- )
- )
- )
+boolean something_has_changed = false;
+boolean cupsd_restart_required = false;
+boolean cupsd_start_required = false;
+boolean cupsd_stop_required = false;
+
+boolean ApplyNetworkPrintingSettings()
+{ if( ! something_has_changed )
+ { y2milestone( "Nothing changed in 'Printing via Network' dialog." );
+ Popup::ShowFeedback( // No title for such a simple feedback message:
+ "",
+ // Message of a Popup::ShowFeedback when nothing was changed:
+ _("Nothing changed.")
+ );
+ sleep( 1000 );
+ Popup::ClearFeedback();
+ return true;
+ }
+ y2milestone( "Writing 'NetworkPrinting' settings to the system." );
+ // Nothing implemented yet:
+ Popup::AnyMessage( // Header of a Popup::AnyMessage when "ApplyNetworkPrintingSettings" is called:
+ _("Not yet implemented"),
+ // Body of a Popup::AnyMessage when the "ApplyNetworkPrintingSettings" is called:
+ _("Writing the settings to the system is not yet implemented.")
+ );
+ return false;
+}
+
+term widgetNetworkPrinting = `VBox
+ ( `VStretch(),
+ `Frame
+ ( _("Use CUPS to Print Via Network"),
+ `RadioButtonGroup
+ ( `id(`browsing_or_client_only_check_boxs),
+ `VBox
+ ( `Left
+ ( `RadioButton
+ ( `id(`cupsd_conf_browsing_off_radio_button),
+ `opt(`notify),
+ _("&Do not Receive Printer Information from Remote CUPS servers")
+ )
+ ),
+ `Left
+ ( `RadioButton
+ ( `id(`cupsd_conf_browsing_on_radio_button),
+ `opt(`notify),
+ _("Receive Printer &Information from Remote CUPS servers")
+ )
+ ),
+ `HBox
+ ( `HSpacing( 3 ),
+ `VBox
+ ( `Left
+ ( `Label
+ ( `id(`cupsd_conf_browse_allow_label),
+ _("Accept Information from the Following Servers")
+ )
+ ),
+ `Left
+ ( `ComboBox
+ ( `id(`cupsd_conf_browse_allow_combo_box),
+ _("Usual &General Setting"),
+ [ `item( `id(`browse_allow_local), "hosts in the local network" ),
+ `item( `id(`browse_allow_all), "all hosts" )
+ ]
+ )
+ ),
+ `Left
+ ( `TextEntry
+ ( `id(`cupsd_conf_browse_allow_input),
+ _("Specific IP Addresses or &Network/Netmask (separated by space)")
+ )
+ )
+ )
+ ),
+ `VSpacing( 1 ),
+ `Left
+ ( `RadioButton
+ ( `id(`client_only_radio_button),
+ `opt(`notify),
+ _("Do All Your Printing Directly via &One Remote CUPS Server")
+ )
+ ),
+ `HBox
+ ( `HSpacing( 3 ),
+ `HWeight
+ ( 2,
+ `TextEntry
+ ( `id(`client_conf_server_name_input),
+ _("&Hostname / IP Address")
+ )
+ ),
+ `HWeight
+ ( 1,
+ `PushButton
+ ( `id(`test_client_conf_server),
+ _("&Test Server")
+ )
+ ),
+ `HStretch()
+ )
+ )
+ )
),
- `VStretch(),
- `Frame( _("Use Another Print Server or Use a Network Printer Directly"),
- `Left( `PushButton( `id(`connection_wizard),
- _("&Connection Wizard")
- )
- )
+ `VStretch(),
+ `Frame
+ ( _("Use Another Print Server or Use a Network Printer Directly"),
+ `Left
+ ( `PushButton
+ ( `id(`connection_wizard),
+ _("&Connection Wizard")
+ )
+ )
),
- `VStretch()
- );
+ `VStretch(),
+ `Right
+ ( `PushButton
+ ( `id(`apply),
+ _("Apply")
+ )
+ )
+ );
-void initNetworkPrinting(string key)
+void initNetworkPrinting( string key )
{ y2milestone( "entering initNetworkPrinting with key '%1'", key );
- // Determine the 'Browsing [ On | Off ]' value in /etc/cups/cupsd.conf:
- if( Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "modify_cupsd_conf Browsing" ) )
- { // Ignore when this command fails and use initially the fallback "Printerlib::browsing_on = true"
- string browsing = tolower( Printerlib::result["stdout"]:"On" );
- if( "off" == browsing || "no" == browsing )
- { Printerlib::browsing_on = false;
- }
- else
- { Printerlib::browsing_on = true;
- }
- }
- // Determine the 'BrowseAllow [ all | none | @LOCAL | IP-address[/netmask] ]' values in /etc/cups/cupsd.conf:
- if( Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "modify_cupsd_conf BrowseAllow" ) )
- { // Ignore when this command fails and use initially the fallback "Printerlib::cupsd_conf_browse_allow = "all"
- Printerlib::cupsd_conf_browse_allow = Printerlib::result["stdout"]:"all";
- }
- // Determine the 'ServerName' value in /etc/cups/client.conf:
- if( Printerlib::ExecuteBashCommand( Printerlib::yast_bin_dir + "cups_client_only" ) )
- { // Ignore when this command fails and use initially the fallback "Printerlib::client_only = false"
- // and the initiall fallback "Printerlib::client_conf_server_name = ""
- Printerlib::client_conf_server_name = Printerlib::result["stdout"]:"";
- if( "" != Printerlib::client_conf_server_name
- && "localhost" != Printerlib::client_conf_server_name )
- { // Note that even 'localhost' is a valid ServerName value
- // which is used to force client tools (e.g. lpadmin, lpinfo, lpstat)
- // to ask the local cupsd via the IPP port on localhost (localhost:631)
- // and not via the domain socket (/var/run/cups/cups.sock) because
- // the latter failed in the past for certain third-party clients (e.g. Java).
- // If the ServerName value in /etc/cups/client.conf is 'localhost'
- // it is actually no client-only config because the local cupsd is used.
- Printerlib::client_only = true;
- }
- else
- { Printerlib::client_only = false;
- }
- }
+ // Determine the 'Browsing [ On | Off ]' value in /etc/cups/cupsd.conf and ignore when it fails:
+ Printerlib::DetermineBrowsing();
+ // Determine the 'BrowseAllow [ all | none | @LOCAL | IP-address[/netmask] ]'
+ // values in /etc/cups/cupsd.conf and ignore when it fails:
+ Printerlib::DetermineBrowseAllow();
+ // Determine the 'ServerName' value in /etc/cups/client.conf and ignore when it fails:
+ Printerlib::DetermineClientOnly();
// Have all widgets disabled initially
// but nevertheless fill in the values of the current settings in the system:
UI::ChangeWidget( `id(`cupsd_conf_browsing_off_radio_button), `Value, false );
UI::ChangeWidget( `id(`cupsd_conf_browsing_on_radio_button), `Value, false );
+ UI::ChangeWidget( `id(`cupsd_conf_browse_allow_label), `Enabled, false );
+ UI::ChangeWidget( `id(`cupsd_conf_browse_allow_combo_box), `Enabled, false );
+ // When by accident "all" and "@LOCAL" were set as BrowseAllow values,
+ // the "@LOCAL" entry is preselected in cupsd_conf_browse_allow_combo_box
+ // because this is the more secure setting:
+ if( contains( Printerlib::cupsd_conf_browse_allow, "all" ) )
+ { UI::ChangeWidget( `id(`cupsd_conf_browse_allow_combo_box), `Value, `id(`browse_allow_all) );
+ }
+ if( contains( Printerlib::cupsd_conf_browse_allow, "@LOCAL" ) )
+ { UI::ChangeWidget( `id(`cupsd_conf_browse_allow_combo_box), `Value, `id(`browse_allow_local) );
+ }
UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, false );
- UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Value, Printerlib::cupsd_conf_browse_allow );
+ // The preset entry in cupsd_conf_browse_allow_input field
+ // should not contain "all" or "@LOCAL" because those are
+ // already selectable via cupsd_conf_browse_allow_combo_box
+ // and it should also not contain "none" because this setting
+ // is implicitely done via cupsd_conf_browsing_off_radio_button:
+ string cupsd_conf_browse_allow_input_value = mergestring( filter( string value,
+ Printerlib::cupsd_conf_browse_allow,
+ { value = tolower( value ) ;
+ return( "all" != value
+ && "@local" != value
+ && "none" != value
+ );
+ }
+ ),
+ " "
+ );
+ UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Value, cupsd_conf_browse_allow_input_value );
UI::ChangeWidget( `id(`client_only_radio_button), `Value, false );
UI::ChangeWidget( `id(`client_conf_server_name_input), `Enabled, false );
UI::ChangeWidget( `id(`client_conf_server_name_input), `Value, Printerlib::client_conf_server_name );
@@ -152,8 +221,13 @@
}
else
{ UI::ChangeWidget( `id(`connection_wizard), `Enabled, true );
- if( Printerlib::browsing_on )
+ // If "none" is present as a BrowseAllow value, no 'Browsing On' widget is enabled:
+ if( Printerlib::browsing_on
+ && ! contains( Printerlib::cupsd_conf_browse_allow, "none" )
+ )
{ UI::ChangeWidget( `id(`cupsd_conf_browsing_on_radio_button), `Value, true );
+ UI::ChangeWidget( `id(`cupsd_conf_browse_allow_label), `Enabled, true );
+ UI::ChangeWidget( `id(`cupsd_conf_browse_allow_combo_box), `Enabled, true );
UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, true );
}
else
@@ -163,30 +237,45 @@
y2milestone( "leaving initNetworkPrinting" );
}
-symbol handleNetworkPrinting(string key, map event)
+symbol handleNetworkPrinting( string key, map event )
{ y2milestone( "entering handleNetworkPrinting with key '%1'\nand event '%2'", key, event );
if( "ValueChanged" == event["EventReason"]:"" )
{ if( `cupsd_conf_browsing_on_radio_button == event["ID"]:nil )
- { UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, true );
+ { UI::ChangeWidget( `id(`cupsd_conf_browse_allow_label), `Enabled, true );
+ UI::ChangeWidget( `id(`cupsd_conf_browse_allow_combo_box), `Enabled, true );
+ UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, true );
UI::ChangeWidget( `id(`client_conf_server_name_input), `Enabled, false );
UI::ChangeWidget( `id(`test_client_conf_server), `Enabled, false );
UI::ChangeWidget( `id(`connection_wizard), `Enabled, true );
}
if( `cupsd_conf_browsing_off_radio_button == event["ID"]:nil )
- { UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, false );
+ { UI::ChangeWidget( `id(`cupsd_conf_browse_allow_label), `Enabled, false );
+ UI::ChangeWidget( `id(`cupsd_conf_browse_allow_combo_box), `Enabled, false );
+ UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, false );
UI::ChangeWidget( `id(`client_conf_server_name_input), `Enabled, false );
UI::ChangeWidget( `id(`test_client_conf_server), `Enabled, false );
UI::ChangeWidget( `id(`connection_wizard), `Enabled, true );
}
if( `client_only_radio_button == event["ID"]:nil )
- { UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, false );
+ { UI::ChangeWidget( `id(`cupsd_conf_browse_allow_label), `Enabled, false );
+ UI::ChangeWidget( `id(`cupsd_conf_browse_allow_combo_box), `Enabled, false );
+ UI::ChangeWidget( `id(`cupsd_conf_browse_allow_input), `Enabled, false );
UI::ChangeWidget( `id(`client_conf_server_name_input), `Enabled, true );
UI::ChangeWidget( `id(`test_client_conf_server), `Enabled, true );
UI::ChangeWidget( `id(`connection_wizard), `Enabled, false );
}
}
if( "Activated" == event["EventReason"]:"" )
- { if( `connection_wizard == event["ID"]:nil )
+ { if( `apply == event["ID"]:nil )
+ { if( ! ApplyNetworkPrintingSettings() )
+ { Report::Error( // Message of a Report::Error.
+ // Only a simple message because this error does not happen on a normal system
+ // (i.e. a system which is not totally broken or totally messed up).
+ _("Failed to apply the settings to the system.")
+ );
+ }
+ }
+ if( `connection_wizard == event["ID"]:nil )
{ return `connection_wizard;
}
}
@@ -195,12 +284,21 @@
return nil;
}
-void storeNetworkPrinting(string key, map event)
+void storeNetworkPrinting( string key, map event )
{ y2milestone( "entering storeNetworkPrinting with key '%1'\nand event '%2'", key, event );
+ if( ! ApplyNetworkPrintingSettings() )
+ { Report::Error( // Message of a Report::Error.
+ // Only a simple message because this error does not happen on a normal system
+ // (i.e. a system which is not totally broken or totally messed up).
+ _("Failed to apply the settings to the system.")
+ );
+ }
y2milestone( "leaving storeNetworkPrinting" );
}
+
+
/**
* Printing via network dialog
* @return dialog result
Modified: trunk/printer/tools/cups_client_only
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/tools/cups_client_only?r…
==============================================================================
--- trunk/printer/tools/cups_client_only (original)
+++ trunk/printer/tools/cups_client_only Fri Aug 29 14:48:36 2008
@@ -9,15 +9,18 @@
export LANG="POSIX"
umask 022
-SERVERNAME="$1"
+# When 'localhost' or its IP-address is to be set,
+# it is unified so that only 'localhost' or '127.0.0.1' are set
+# (but not stuff like 'LocalHost' or '127.000.000.001').
+SERVERNAME="$( echo $1 | sed -e 's/localhost/localhost/i' -e 's/127\.0*0\.0*0\.0*1/127.0.0.1/' )"
if test -n "$SERVERNAME"
then # When a SERVERNAME is specified, set it in /etc/cups/client.conf
# if SERVERNAME is not the magic word 'none' which
# is used to only remove all active ServerName entries.
- # Note that even 'localhost' is a valid entry there
+ # Note that even 'localhost' or '127.0.0.1' is a valid entry there
# which is used to force client tools (e.g. lpadmin, lpinfo, lpstat)
- # to ask the local cupsd via the IPP port on localhost (localhost:631)
+ # to ask the local cupsd via the IPP port on localhost (127.0.0.1:631)
# and not via the domain socket (/var/run/cups/cups.sock) because
# the latter failed in the past for certain third-party clients (e.g. Java).
# Note that (according to Michael Sweet) it is not a supported configuration
@@ -45,7 +48,10 @@
# the output is the empty string (i.e. nothing at all - not even a '\n' character).
# The 'tr ... [:blank:]' makes sure that all active ServerName entries
# are found if there is more than one which is a broken config.
-SERVERNAME="$( grep -i '^ServerName ' /etc/cups/client.conf | tr -s '[:blank:]' ' ' | cut -s -d' ' -f2 | tr -s '\n' ' ' | sed -e 's/ *$//' )"
+# Trailing spaces are removed and when 'localhost' or its IP-address is set,
+# it is unified so that YaST only needs to test for 'localhost' and '127.0.0.1'
+# (but not for stuff like 'LocalHost' or '127.000.000.001').
+SERVERNAME="$( grep -i '^ServerName ' /etc/cups/client.conf | tr -s '[:blank:]' ' ' | cut -s -d' ' -f2 | tr -s '\n' ' ' | sed -e 's/ *$//' -e 's/localhost/localhost/i' -e 's/127\.0*0\.0*0\.0*1/127.0.0.1/' )"
echo -n "$SERVERNAME"
# For a nicer output on a terminal where stdout and stderr is mixed up,
# output a '\n' on stderr to get subsequent stuff (e.g. the shell prompt
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r50480 - /trunk/storage/storage/src/include/target_modify.ycp
by aschnell@svn.opensuse.org 29 Aug '08
by aschnell@svn.opensuse.org 29 Aug '08
29 Aug '08
Author: aschnell
Date: Fri Aug 29 14:34:01 2008
New Revision: 50480
URL: http://svn.opensuse.org/viewcvs/yast?rev=50480&view=rev
Log:
- disabled code that looks obsolete for years
Modified:
trunk/storage/storage/src/include/target_modify.ycp
Modified: trunk/storage/storage/src/include/target_modify.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/targ…
==============================================================================
--- trunk/storage/storage/src/include/target_modify.ycp (original)
+++ trunk/storage/storage/src/include/target_modify.ycp Fri Aug 29 14:34:01 2008
@@ -21,6 +21,7 @@
import "Partitions";
import "Storage";
+/*
define void RemoveUsedNonEvmsDm( map<string,map> target )
``{
boolean ret = true;
@@ -54,7 +55,9 @@
y2milestone( "RemoveUsedNonEvmsDm %1",
SCR::Execute( .target.bash_output, "/sbin/dmsetup ls" ));
}
+*/
+/*
define map<integer,map> HandleDeletedVgs( map<string,map> tg,
map<integer,map> modify_targets )
``{
@@ -77,5 +80,6 @@
y2milestone( "HandleDeletedVgs ret %1", modify_targets );
return( modify_targets );
}
+*/
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r50479 - /trunk/storage/storage/src/modules/Storage.ycp
by aschnell@svn.opensuse.org 29 Aug '08
by aschnell@svn.opensuse.org 29 Aug '08
29 Aug '08
Author: aschnell
Date: Fri Aug 29 14:15:18 2008
New Revision: 50479
URL: http://svn.opensuse.org/viewcvs/yast?rev=50479&view=rev
Log:
- disabled code that looks obsolete with evms removal
Modified:
trunk/storage/storage/src/modules/Storage.ycp
Modified: trunk/storage/storage/src/modules/Storage.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/modules/Stor…
==============================================================================
--- trunk/storage/storage/src/modules/Storage.ycp (original)
+++ trunk/storage/storage/src/modules/Storage.ycp Fri Aug 29 14:15:18 2008
@@ -220,6 +220,7 @@
* @param string dev
* @return string EvmsDevDisk
*/
+/*
global string EvmsDevDisk( string dev )
{
string ret = "/dev/" + substring( dev, 10 );
@@ -233,7 +234,7 @@
ret = String::Replace( ret, "|", "/" );
return( ret );
}
-
+*/
/* Storage = TargetMap
/* Storage = $[ "targets" : $[],
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0
[yast-commit] r50478 - /trunk/storage/storage/src/modules/Storage.ycp
by aschnell@svn.opensuse.org 29 Aug '08
by aschnell@svn.opensuse.org 29 Aug '08
29 Aug '08
Author: aschnell
Date: Fri Aug 29 14:11:40 2008
New Revision: 50478
URL: http://svn.opensuse.org/viewcvs/yast?rev=50478&view=rev
Log:
- disabled code that looks obsolete with evms removal
Modified:
trunk/storage/storage/src/modules/Storage.ycp
Modified: trunk/storage/storage/src/modules/Storage.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/modules/Stor…
==============================================================================
--- trunk/storage/storage/src/modules/Storage.ycp (original)
+++ trunk/storage/storage/src/modules/Storage.ycp Fri Aug 29 14:11:40 2008
@@ -5435,6 +5435,7 @@
return( ret );
}
+/*
global define list GetUsedLvmGroups( map<string,map> tg )
``{
list groups = [];
@@ -5453,6 +5454,7 @@
y2milestone( "GetUsedLvmGroups ret %1", groups );
return( groups );
};
+*/
/**
* Get used real disks
@@ -5461,6 +5463,7 @@
* @param boolean ignore boot
* @return list <string> disks List of disks
*/
+/*
global define list<string> GetUsedRealDisksNew( map<string,map> tg,
boolean ignore_boot )
``{
@@ -5492,12 +5495,16 @@
ignore_boot, disks );
return( disks );
};
+*/
+/*
global define list<string> GetUsedRealDisks( map<string,map> tg )
{
return( GetUsedRealDisksNew( tg, false ));
};
+*/
+/*
global define list<string> GetEvmsRealDisk( map<string,map> tg, map p )
``{
list<string> rdisk = [];
@@ -5555,7 +5562,9 @@
y2milestone( "GetEvmsRealDisk %1 is %2", p["device"]:"", rdisk );
return( rdisk );
}
+*/
+/*
global define list<string> GetUsedEvmsDisks( map<string,map> tg )
``{
list<string> disks = [];
@@ -5600,8 +5609,9 @@
y2milestone( "GetUsedEvmsDisks ret %1", disks );
return( disks );
};
+*/
-
+/*
global list<map> GetPrepBoot( map<string,map> tg )
{
list<map> ret = [];
@@ -5617,6 +5627,7 @@
y2milestone( "GetPrepBoot ret:%1", ret );
return( ret );
}
+*/
void CallInsserv( boolean on, string name )
{
@@ -5641,6 +5652,7 @@
if( Stage::initial() )
{
HandleModulesOnBoot( tg );
+/*
list evms = GetUsedEvmsDisks( tg );
y2milestone( "FinishInstall evms %1", evms );
if( size(evms)>0 )
@@ -5692,6 +5704,7 @@
i = i+1;
}
}
+*/
}
boolean need_crypt = false;
boolean need_md = false;
--
To unsubscribe, e-mail: yast-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: yast-commit+help(a)opensuse.org
1
0