aboutsummaryrefslogtreecommitdiffstats
path: root/po/zh_TW.po
diff options
context:
space:
mode:
Diffstat (limited to 'po/zh_TW.po')
-rw-r--r--po/zh_TW.po1534
1 files changed, 767 insertions, 767 deletions
diff --git a/po/zh_TW.po b/po/zh_TW.po
index 2165312e..8e0476e9 100644
--- a/po/zh_TW.po
+++ b/po/zh_TW.po
@@ -7,7 +7,7 @@
msgid ""
msgstr ""
"Project-Id-Version: grpmi\n"
-"POT-Creation-Date: 2003-05-02 20:15+0200\n"
+"POT-Creation-Date: 2003-05-13 13:06+0200\n"
"PO-Revision-Date: 2002-08-25 06:10+0800\n"
"Last-Translator: Kenduest Lee <kenduest@i18n.linux.org.tw>\n"
"Language-Team: Chinese <zh-l10n@linux.org.tw>\n"
@@ -15,20 +15,16 @@ msgstr ""
"Content-Type: text/plain; charset=big5\n"
"Content-Transfer-Encoding: 8bit\n"
-#: ../edit-urpm-sources.pl:1
-#, c-format
-msgid "Enabled?"
-msgstr "開啟"
-
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1 ../edit-urpm-sources.pl:1
#, c-format
-msgid "Path or mount point:"
-msgstr "路徑或是掛載點:"
-
-#: ../rpmdrake.pm:1
-#, fuzzy, c-format
-msgid "Portugal"
-msgstr "埠號:"
+msgid ""
+"%s\n"
+"\n"
+"Is it ok to continue?"
+msgstr ""
+"%s\n"
+"\n"
+"您要繼續嗎?"
#: ../rpmdrake:1
#, c-format
@@ -45,151 +41,144 @@ msgstr ""
#: ../rpmdrake:1
#, c-format
-msgid "by group"
-msgstr "依群組分類"
-
-#: ../edit-urpm-sources.pl:1
-#, fuzzy, c-format
-msgid "Name:"
-msgstr "名稱"
-
-#: ../rpmdrake.pm:1
-#, fuzzy, c-format
-msgid "Italy"
-msgstr "安裝"
+msgid ""
+"Welcome to MandrakeUpdate!\n"
+"\n"
+"This tool will help you choose the updates you want to install on your\n"
+"computer."
+msgstr ""
+"歡迎來到套件更新程式!\n"
+"接下來程式將會引導你完成套件更新與安裝。"
#: ../rpmdrake:1
#, c-format
-msgid "How to choose manually your mirror"
-msgstr "如何手動選擇您需要的映射站台"
+msgid ""
+"Welcome to the software removal tool!\n"
+"\n"
+"This tool will help you choose which software you want to remove from\n"
+"your computer."
+msgstr ""
+"歡迎來到套件移除程式!\n"
+"\n"
+"接下來程式將會引導你完成移除您認為不需要的套件項目。"
-#: ../edit-urpm-sources.pl:1
-#, c-format
-msgid "URL:"
-msgstr "URL:"
+#: ../rpmdrake:1
+#, fuzzy, c-format
+msgid ""
+"There was a problem during the removal of packages:\n"
+"\n"
+"%s"
+msgstr ""
+"安裝套件時發生了下面的錯誤:\n"
+"\n"
+"%s"
#: ../rpmdrake:1
-#, c-format
-msgid "Some packages need to be removed"
-msgstr "某些套件需要順便移除"
+#, fuzzy, c-format
+msgid "Problem during removal"
+msgstr "安裝時發生問題"
#: ../rpmdrake:1
-#, c-format
-msgid "Already existing update sources"
+#, fuzzy, c-format
+msgid "Please wait, removing packages..."
msgstr ""
+"請稍候\n"
+"排序套件"
#: ../rpmdrake:1
-#, c-format
-msgid "More information on package..."
-msgstr "更多該套件資訊..."
-
-#: ../rpmdrake.pm:1
-#, c-format
-msgid "Yes"
-msgstr "是"
+#, fuzzy, c-format
+msgid "Please wait, reading packages database..."
+msgstr ""
+"請稍候\n"
+"排序套件"
#: ../rpmdrake:1
-#, c-format
+#, fuzzy, c-format
msgid ""
-"Because of their dependencies, the following package(s) must be\n"
-"unselected now:\n"
+"There was a problem during the installation:\n"
"\n"
+"%s"
msgstr ""
-"由於相依性的要求,下面的套件將會取消選取以便於能夠繼續進行下去:\n"
+"安裝套件時發生了下面的錯誤:\n"
"\n"
+"%s"
#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "everything was installed correctly"
-msgstr "所有項目已經都安裝成功了。"
+msgid "Installation failed"
+msgstr "全部安裝"
#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "%s KB"
-msgstr "%.1f KB"
+msgid "Unrecoverable error: no package found for installation, sorry."
+msgstr "正在準備安裝"
#: ../rpmdrake:1
-#, c-format
-msgid ""
-"Welcome to the software removal tool!\n"
-"\n"
-"This tool will help you choose which software you want to remove from\n"
-"your computer."
-msgstr ""
-"歡迎來到套件移除程式!\n"
-"\n"
-"接下來程式將會引導你完成移除您認為不需要的套件項目。"
+#, fuzzy, c-format
+msgid "No package found for installation."
+msgstr "正在準備安裝"
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1
#, c-format
-msgid ""
-"In order to save the changes, you need to insert the medium in the drive."
-msgstr "為了能夠儲存變更,請置入該媒介裝置後於磁碟機繼續。"
+msgid "All requested packages were installed successfully."
+msgstr "已經成功地安裝您需要的套件。"
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1
#, c-format
-msgid "Save and quit"
-msgstr "儲存並離開"
+msgid "Everything installed successfully"
+msgstr "所有項目已經都安裝成功了。"
#: ../rpmdrake:1
-#, fuzzy, c-format
+#, c-format
msgid ""
-"There was a problem during the removal of packages:\n"
+"The installation is finished; %s.\n"
"\n"
-"%s"
+"Some configuration files were created as `.rpmnew' or `.rpmsave',\n"
+"you may now inspect some in order to take actions:"
msgstr ""
-"安裝套件時發生了下面的錯誤:\n"
+"已經完成安裝 %s 套件了。\n"
"\n"
-"%s"
+"請注意一下,該套件可能另外產生了 '.rpmnew' 新版本設定檔案,\n"
+"或者是把原本設定檔案重新命名為 '.rpmsave',為了能夠讓程式\n"
+"能夠正常執行工作,您需要檢視下面的步驟:"
#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "Size: "
-msgstr "大小"
+msgid "everything was installed correctly"
+msgstr "所有項目已經都安裝成功了。"
-#: ../rpmdrake:1 ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "Security updates"
-msgstr "顯示安全更新套件"
+msgid "Problem during installation"
+msgstr "安裝時發生問題"
#: ../rpmdrake:1
#, c-format
-msgid "Maximum information"
-msgstr "完整資訊"
+msgid "Installing package `%s' (%s/%s)..."
+msgstr "正在安裝套件 '%s (%s/%s)..."
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "Proxy..."
-msgstr "錯誤..."
-
-#: ../rpmdrake.pm:1
-#, c-format
-msgid "United Kingdom"
-msgstr "聯合國"
-
-#: ../edit-urpm-sources.pl:1
-#, c-format
-msgid "Configure sources"
-msgstr "設定套件來源位置?"
+msgid "Preparing packages installation..."
+msgstr "正在準備安裝"
#: ../rpmdrake:1
#, c-format
-msgid "in names"
-msgstr "依名稱"
+msgid ""
+"\n"
+"\n"
+"Error(s) reported:\n"
+"%s"
+msgstr ""
-#: ../rpmdrake.pm:1
+#: ../rpmdrake:1
#, c-format
msgid ""
-"I can't find any suitable mirror.\n"
-"\n"
-"There can be many reasons for this problem; the most frequent is\n"
-"the case when the architecture of your processor is not supported\n"
-"by Mandrake Linux Official Updates."
+"Installation failed, some files are missing.\n"
+"You may want to update your sources database."
msgstr ""
-"安裝程式找不到適合的映射站台。\n"
-"\n"
-"會發生這個問題的情況相當多,比方 Mandrake Linux\n"
-"更新站台目前尚不支援您目前用的機器平台。"
+"安裝失敗。安裝程式找不到一些要安裝上的程式套件。\n"
+"也許是系統資料庫太舊了,請先更新資料庫後再繼續。"
#: ../rpmdrake:1
#, fuzzy, c-format
@@ -198,7 +187,7 @@ msgid ""
"\n"
"%s\n"
"\n"
-"\\Do you want to continue installation?"
+"Do you want to continue installation?"
msgstr ""
"下列的套件需要順便移除,以便於能夠進行其他套件的安裝更新:\n"
"\n"
@@ -208,475 +197,525 @@ msgstr ""
#: ../rpmdrake:1
#, c-format
-msgid "Remove .%s"
-msgstr "移除 .%s"
+msgid "Verifying packages signatures..."
+msgstr ""
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1
#, c-format
-msgid "Source"
-msgstr "來源"
+msgid "Downloading package `%s' (%s/%s)..."
+msgstr "正在下載「%s」(%s/%s)..."
-#: ../rpmdrake.pm:1
+#: ../rpmdrake:1 ../edit-urpm-sources.pl:1 ../rpmdrake.pm:1
#, c-format
-msgid "Finland"
-msgstr "芬蘭"
+msgid "Cancel"
+msgstr "取消"
-#: ../rpmdrake:1
+#: ../rpmdrake:1 ../edit-urpm-sources.pl:1 ../rpmdrake.pm:1
#, c-format
-msgid "Verifying packages signatures..."
-msgstr ""
+msgid "Ok"
+msgstr "確定"
-#: ../rpmdrake.pm:1
+#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "France"
-msgstr "強迫"
+msgid "Please insert the medium named \"%s\" on device [%s]"
+msgstr "請置入媒介名稱為 \"%s\" 的項目放置於 %s 裝置"
-#. -PO: Keep it short, this is gonna be on a button
#: ../rpmdrake:1
#, c-format
-msgid "More info"
-msgstr ""
-
-#: ../rpmdrake:1 ../edit-urpm-sources.pl:1
-#, c-format
-msgid ""
-"%s\n"
-"\n"
-"Is it ok to continue?"
-msgstr ""
-"%s\n"
-"\n"
-"您要繼續嗎?"
+msgid "Change medium"
+msgstr "變更媒介"
#: ../rpmdrake:1
#, c-format
-msgid "Reload the packages list"
-msgstr "重新載入套件清單"
-
-#: ../edit-urpm-sources.pl:1
-#, c-format
-msgid "Choose a mirror..."
-msgstr "選擇映射地址..."
+msgid "Initializing..."
+msgstr "初始化中..."
-#: ../edit-urpm-sources.pl:1
-#, c-format
-msgid "Adding a source:"
-msgstr "新增來源:"
+#: ../rpmdrake:1
+#, fuzzy, c-format
+msgid "Package installation..."
+msgstr "正在準備安裝"
#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "Some packages can't be installed"
-msgstr "套件 '%s' 無法被安裝\n"
+msgid "Unable to get source packages, sorry. %s"
+msgstr "抱歉,您需要具備 root 權限身份才可以進行套件安裝。"
#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "Unrecoverable error: no package found for installation, sorry."
-msgstr "正在準備安裝"
+msgid "Unable to get source packages."
+msgstr "選擇套件"
#: ../rpmdrake:1
#, c-format
-msgid "All packages,"
-msgstr "所有套件,"
+msgid "Inspect..."
+msgstr "檢查..."
#: ../rpmdrake:1
-#, c-format
-msgid "in files"
-msgstr "依檔案"
+#, fuzzy, c-format
+msgid "Installation finished"
+msgstr "已安裝"
#: ../rpmdrake:1
#, c-format
-msgid "All requested packages were installed successfully."
-msgstr "已經成功地安裝您需要的套件。"
-
-#: ../edit-urpm-sources.pl:1
-#, fuzzy, c-format
-msgid "Proxy hostname:"
-msgstr "使用者名稱 (代理伺服器):"
+msgid "Do nothing"
+msgstr "沒有進行任何動作"
-#: ../rpmdrake:1 ../rpmdrake.pm:1
+#: ../rpmdrake:1
#, c-format
-msgid "Update source(s)"
-msgstr "更新來源"
+msgid "Use .%s as main file"
+msgstr "使用 .%s 為主要檔案"
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1
#, c-format
-msgid "Local files"
-msgstr "本機檔案"
+msgid "Remove .%s"
+msgstr "移除 .%s"
+
+#: ../rpmdrake:1
+#, fuzzy, c-format
+msgid "changes:"
+msgstr "儲存變更"
#: ../rpmdrake:1
#, c-format
msgid "Inspecting %s"
msgstr "正在檢查 %s"
-#: ../rpmdrake.pm:1
-#, fuzzy, c-format
-msgid "Israel"
-msgstr "安裝"
-
#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "Help"
-msgstr "/說明 (_H)"
+msgid "Please wait, finding available packages..."
+msgstr ""
+"請稍候\n"
+"排序套件"
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1 ../edit-urpm-sources.pl:1
#, c-format
-msgid "HTTP server"
-msgstr "HTTP 主機"
+msgid "Please wait, adding medium..."
+msgstr "請稍後,正在加入媒介來源..."
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1
#, c-format
msgid ""
-"Welcome to the packages source editor!\n"
+"You may also choose your desired mirror manually: to do so,\n"
+"launch the Software Sources Manager, and then add a `Security\n"
+"updates' source.\n"
"\n"
-"This tool will help you configure the packages sources you wish to use on\n"
-"your computer. They will then be available to install new software package\n"
-"or to perform updates."
+"Then, restart MandrakeUpdate."
msgstr ""
-"歡迎來到套件來源編輯程式!\n"
+"您已經手動選擇您需要的映射站台了,建議您請稍後手動執行\n"
+"套件來源管理員,針對您的映射站台另外加入「安全修正」項目。\n"
"\n"
-"接下來程式將會引導你完成編輯套件來源的項目,\n"
-"以便於提供您能夠使用您所設定的項目進行軟體的安裝與更新。"
-
-#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Installation failed"
-msgstr "全部安裝"
+"完成後,請重新啟動 MandrakeUpdate 程式。"
#: ../rpmdrake:1
#, c-format
-msgid "Use .%s as main file"
-msgstr "使用 .%s 為主要檔案"
+msgid "How to choose manually your mirror"
+msgstr "如何手動選擇您需要的映射站台"
#: ../rpmdrake:1
#, c-format
-msgid "Search results"
-msgstr "搜尋結果"
-
-#: ../rpmdrake.pm:1
-#, fuzzy, c-format
-msgid " failed!"
-msgstr "依檔案"
+msgid ""
+"You already have at least one update source configured, but\n"
+"all of them are currently disabled. You should run the Software\n"
+"Sources Manager to enable at least one (check it in the Enabled?\n"
+"column).\n"
+"\n"
+"Then, restart MandrakeUpdate."
+msgstr ""
-#: ../rpmdrake.pm:1
+#: ../rpmdrake:1
#, c-format
-msgid "Brazil"
-msgstr "巴西"
+msgid "Already existing update sources"
+msgstr ""
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1
#, c-format
msgid ""
-"There is already a medium by that name, do you\n"
-"really want to replace it?"
+"I need to contact the mirror to get latest update packages.\n"
+"Please check that your network is currently running.\n"
+"\n"
+"Is it ok to continue?"
msgstr ""
-"該媒介裝置項目已經存在了,\n"
-"您確定要置換原本項目嗎?"
+"安裝程式需要連線到映射站台以便於取回最新的更新套件。\n"
+"請確定您目前的網路能夠正常連線到外面。\n"
+"\n"
+"您現在要繼續嗎?"
#: ../rpmdrake:1
#, c-format
-msgid "Find:"
-msgstr "尋找:"
+msgid "A fatal error occurred: %s."
+msgstr ""
#: ../rpmdrake:1
-#, c-format
-msgid "All packages, alphabetical"
-msgstr "所有套件,依照字母順序分類"
+#, fuzzy, c-format
+msgid "Fatal error"
+msgstr "檔案錯誤"
#: ../rpmdrake:1
-#, c-format
-msgid "Please wait, searching..."
-msgstr "請稍候,搜尋中..."
+#, fuzzy, c-format
+msgid "Software Packages Installation"
+msgstr "正在準備安裝"
#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "Please wait, reading packages database..."
-msgstr ""
-"請稍候\n"
-"排序套件"
+msgid "Mandrake Update"
+msgstr "MandrakeUpdate 編好設定"
+
+#: ../rpmdrake:1
+#, c-format
+msgid "Software Packages Removal"
+msgstr "移除套件程式"
+
+#: ../rpmdrake:1 ../edit-urpm-sources.pl:1
+#, c-format
+msgid "Quit"
+msgstr "離開"
+
+#: ../rpmdrake:1
+#, c-format
+msgid "Install"
+msgstr "安裝"
+
+#: ../rpmdrake:1 ../edit-urpm-sources.pl:1
+#, c-format
+msgid "Remove"
+msgstr "移除"
#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "unknown package "
-msgstr "不詳"
+msgid "Help"
+msgstr "/說明 (_H)"
#: ../rpmdrake:1
#, c-format
-msgid "Reset the selection"
-msgstr "重置選取項目"
+msgid "Search"
+msgstr "尋找"
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1
#, c-format
-msgid ""
-"If you need a proxy, enter the hostname and an optional port (syntax: "
-"<proxyhost[:port]>):"
-msgstr ""
-"如果您需要透過代理伺服器連線,請輸入該主機名稱與連結埠埠號(比方 proxy.hinet."
-"net:80):"
+msgid "Find:"
+msgstr "尋找:"
#: ../rpmdrake:1
#, c-format
msgid ""
-"Because of their dependencies, the following package(s) also need to be\n"
-"removed:\n"
+"The following packages have to be removed for others to be upgraded:\n"
"\n"
+"%s\n"
+"\n"
+"Is it ok to continue?"
msgstr ""
-"為了要滿足相依性需求,這些套件需要被移除:\n"
+"下列的套件需要順便移除,以便於能夠進行其他套件的安裝更新:\n"
+"\n"
+"%s\n"
"\n"
+"您確定要繼續嗎?"
-#: ../rpmdrake.pm:1
+#: ../rpmdrake:1
#, c-format
-msgid "Costa Rica"
-msgstr "哥斯大黎加"
+msgid "Some packages need to be removed"
+msgstr "某些套件需要順便移除"
#: ../rpmdrake:1
-#, fuzzy, c-format
+#, c-format
msgid ""
-"There was a problem during the installation:\n"
+"Warning: it seems that you are attempting to add so much\n"
+"packages that your filesystem may run out of free diskspace,\n"
+"during or after package installation ; this is particularly\n"
+"dangerous and should be considered with care.\n"
"\n"
-"%s"
+"Do you really want to install all the selected packages?"
msgstr ""
-"安裝套件時發生了下面的錯誤:\n"
-"\n"
-"%s"
+"警告: 您選取了許多要安裝更新的套件,不過您的磁碟空間\n"
+"似乎已經不敷使用,建議您先整理挪出可用的空間再進行下面\n"
+"的安裝,以避免任何問題發生。\n"
+"您確定還是要安裝您所選取的套件嗎?"
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1
#, c-format
-msgid "Please wait, removing medium..."
-msgstr "請稍後,正在移除媒介來源..."
+msgid "Too many packages are selected"
+msgstr "選取太多了套件項目"
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1
#, c-format
-msgid "Password:"
-msgstr "密碼:"
+msgid "Maximum information"
+msgstr "完整資訊"
-#: ../rpmdrake.pm:1
+#: ../rpmdrake:1
#, c-format
-msgid "Examining distant file of source `%s'..."
-msgstr ""
+msgid "Normal information"
+msgstr "一般資訊"
-#: ../rpmdrake.pm:1
+#: ../rpmdrake:1 ../rpmdrake.pm:1
#, c-format
-msgid "Taiwan"
-msgstr "台灣"
+msgid "Update source(s)"
+msgstr "更新來源"
-#: ../edit-urpm-sources.pl:1
-#, fuzzy, c-format
-msgid "User:"
-msgstr "使用者名稱:"
+#: ../rpmdrake:1
+#, c-format
+msgid "Reload the packages list"
+msgstr "重新載入套件清單"
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1
#, c-format
-msgid "Please wait, updating medium..."
-msgstr "請稍後,更新媒介中..."
+msgid "Reset the selection"
+msgstr "重置選取項目"
+
+#: ../rpmdrake:1
+#, c-format
+msgid "in files"
+msgstr "依檔案"
#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "Please wait, listing packages..."
-msgstr ""
-"請稍候\n"
-"排序套件"
+msgid "in descriptions"
+msgstr "描述"
#: ../rpmdrake:1
#, c-format
-msgid ""
-"You already have at least one update source configured, but\n"
-"all of them are currently disabled. You should run the Software\n"
-"Sources Manager to enable at least one (check it in the Enabled?\n"
-"column).\n"
-"\n"
-"Then, restart MandrakeUpdate."
-msgstr ""
+msgid "in names"
+msgstr "依名稱"
#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Information on packages"
-msgstr "選擇套件"
+#, c-format
+msgid "by update availability"
+msgstr "依可供更新分類"
-#: ../rpmdrake:1 ../edit-urpm-sources.pl:1 ../rpmdrake.pm:1
+#: ../rpmdrake:1
#, c-format
-msgid "Cancel"
-msgstr "取消"
+msgid "by source repository"
+msgstr "依來源倉儲分類"
#: ../rpmdrake:1
#, c-format
-msgid "Everything installed successfully"
-msgstr "所有項目已經都安裝成功了。"
+msgid "by selection state"
+msgstr "依選擇狀態分類"
-#: ../rpmdrake.pm:1
+#: ../rpmdrake:1
#, c-format
-msgid "Please wait, updating media..."
-msgstr "請稍後,更新媒介中..."
+msgid "by size"
+msgstr "依大小分類"
#: ../rpmdrake:1
#, c-format
-msgid "A fatal error occurred: %s."
-msgstr ""
+msgid "by group"
+msgstr "依群組分類"
#: ../rpmdrake:1
#, c-format
-msgid ""
-"The following packages have to be removed for others to be upgraded:\n"
-"\n"
-"%s\n"
-"\n"
-"Is it ok to continue?"
-msgstr ""
-"下列的套件需要順便移除,以便於能夠進行其他套件的安裝更新:\n"
-"\n"
-"%s\n"
-"\n"
-"您確定要繼續嗎?"
+msgid "All packages,"
+msgstr "所有套件,"
+
+#: ../rpmdrake:1
+#, c-format
+msgid "All packages, alphabetical"
+msgstr "所有套件,依照字母順序分類"
+
+#: ../rpmdrake:1
+#, c-format
+msgid "Mandrake choices"
+msgstr "Mandrake 分類"
#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "in descriptions"
+msgid "Normal updates"
+msgstr "正常更新"
+
+#: ../rpmdrake:1
+#, fuzzy, c-format
+msgid "Bugfixes updates"
+msgstr "顯示修正錯誤的更新套件"
+
+#: ../rpmdrake:1 ../edit-urpm-sources.pl:1
+#, fuzzy, c-format
+msgid "Security updates"
+msgstr "顯示安全更新套件"
+
+#: ../rpmdrake:1
+#, fuzzy, c-format
+msgid "Description: "
msgstr "描述"
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1
#, c-format
-msgid "Configure proxies"
-msgstr "設定代理伺服器"
+msgid "Reason for update: "
+msgstr "更新的原因: "
-#: ../rpmdrake.pm:1
-#, c-format
-msgid ""
-"I need to contact MandrakeSoft website to get the mirrors list.\n"
-"Please check that your network is currently running.\n"
-"\n"
-"Is it ok to continue?"
-msgstr ""
-"安裝程式需要連線到 MandrakeSoft 總部取回映射站台的清單檔案。\n"
-"請確定您目前網路能夠正常連線出去。\n"
-"\n"
-"您要繼續嗎?"
+#: ../rpmdrake:1
+#, fuzzy, c-format
+msgid "Summary: "
+msgstr "摘要"
#: ../rpmdrake:1
#, c-format
-msgid "Please choose"
-msgstr "請選擇"
+msgid "Importance: "
+msgstr "重要性: "
#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "Selected size: %d MB"
-msgstr "選擇了 %d 個套件:%.1f MB"
+msgid "%s KB"
+msgstr "%.1f KB"
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "Add a source"
-msgstr "新增來源:"
+msgid "Size: "
+msgstr "大小"
+
+#: ../rpmdrake:1
+#, fuzzy, c-format
+msgid "Version: "
+msgstr "版本:"
+
+#: ../rpmdrake:1
+#, fuzzy, c-format
+msgid "Name: "
+msgstr "名稱: %s"
#: ../rpmdrake:1
#, c-format
-msgid "Initializing..."
-msgstr "初始化中..."
+msgid "Currently installed version: "
+msgstr "目前已安裝的版本:"
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1
+#, fuzzy, c-format
+msgid "Source: "
+msgstr "來源"
+
+#: ../rpmdrake:1
#, c-format
-msgid "Save changes"
-msgstr "儲存變更"
+msgid "(Not available)"
+msgstr "(無法使用)"
-#: ../rpmdrake.pm:1
+#: ../rpmdrake:1
#, c-format
-msgid "Error during download"
-msgstr "下載發生錯誤"
+msgid "Changelog:\n"
+msgstr "變更紀錄:\n"
#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "Package installation..."
-msgstr "正在準備安裝"
+msgid "Files:\n"
+msgstr "/檔案 (_F)"
+
+#: ../rpmdrake:1
+#, fuzzy, c-format
+msgid "Selected size: %d MB"
+msgstr "選擇了 %d 個套件:%.1f MB"
#: ../rpmdrake:1
#, c-format
-msgid "Importance: "
-msgstr "重要性: "
+msgid "Selected: %d MB / Free disk space: %d MB"
+msgstr "已選擇:%d MB / 可用磁碟空間:%d MB"
#: ../rpmdrake:1
#, c-format
msgid ""
-"To satisfy dependencies, the following package(s) also need\n"
-"to be installed:\n"
+"Because of their dependencies, the following package(s) must be\n"
+"unselected now:\n"
"\n"
msgstr ""
-"為了能夠滿足相依性的要求,下面的套件也必須一同安裝上:\n"
+"由於相依性的要求,下面的套件將會取消選取以便於能夠繼續進行下去:\n"
"\n"
-#: ../edit-urpm-sources.pl:1
-#, c-format
-msgid "Add..."
-msgstr "新增..."
+#: ../rpmdrake:1
+#, fuzzy, c-format
+msgid ""
+"Sorry, the following package(s) can't be selected:\n"
+"\n"
+"%s\n"
+"\n"
+"Reasons follow:\n"
+"\n"
+"%s"
+msgstr ""
+"抱歉,下面的套件項目將不能夠被選取:\n"
+"\n"
-#: ../rpmdrake.pm:1
-#, c-format
-msgid "Unable to create medium."
-msgstr "無法建立媒介項目。"
+#: ../rpmdrake:1
+#, fuzzy, c-format
+msgid "%s conflicts with %s"
+msgstr " 與 %s-%s-%s 沖突"
+
+#: ../rpmdrake:1
+#, fuzzy, c-format
+msgid "Some packages can't be installed"
+msgstr "套件 '%s' 無法被安裝\n"
#: ../rpmdrake:1
#, c-format
msgid ""
-"The installation is finished; %s.\n"
+"To satisfy dependencies, the following package(s) also need\n"
+"to be installed:\n"
"\n"
-"Some configuration files were created as `.rpmnew' or `.rpmsave',\n"
-"you may now inspect some in order to take actions:"
msgstr ""
-"已經完成安裝 %s 套件了。\n"
+"為了能夠滿足相依性的要求,下面的套件也必須一同安裝上:\n"
"\n"
-"請注意一下,該套件可能另外產生了 '.rpmnew' 新版本設定檔案,\n"
-"或者是把原本設定檔案重新命名為 '.rpmsave',為了能夠讓程式\n"
-"能夠正常執行工作,您需要檢視下面的步驟:"
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1
#, c-format
-msgid "Browse..."
-msgstr "瀏覽..."
+msgid "Additional packages needed"
+msgstr "需要額外的套件項目"
#: ../rpmdrake:1
#, fuzzy, c-format
msgid "Some packages can't be removed"
msgstr "套件 '%s' 無法被安裝\n"
-#: ../rpmdrake.pm:1
-#, c-format
-msgid "Info..."
-msgstr "資訊..."
+#: ../rpmdrake:1
+#, fuzzy, c-format
+msgid ""
+"Removing these packages would break your system, sorry:\n"
+"\n"
+msgstr "抱歉,若是移除下面這些套件可能會讓您的系統出錯:\n"
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1
#, c-format
-msgid "You need to insert the medium to continue"
-msgstr "請插入媒介裝置後繼續"
+msgid ""
+"Because of their dependencies, the following package(s) also need to be\n"
+"removed:\n"
+"\n"
+msgstr ""
+"為了要滿足相依性需求,這些套件需要被移除:\n"
+"\n"
-#: ../rpmdrake:1 ../edit-urpm-sources.pl:1
+#: ../rpmdrake:1
#, c-format
-msgid "Remove"
-msgstr "移除"
+msgid "Some additional packages need to be removed"
+msgstr "為了可以全面運作正常這些額外的套件必須一同安裝"
#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Preparing packages installation..."
-msgstr "正在準備安裝"
+#, c-format
+msgid "More information on package..."
+msgstr "更多該套件資訊..."
-#: ../rpmdrake.pm:1
+#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "No mirror"
-msgstr "映射:"
+msgid "Information on packages"
+msgstr "選擇套件"
-#: ../edit-urpm-sources.pl:1
+#. -PO: Keep it short, this is gonna be on a button
+#: ../rpmdrake:1
#, c-format
-msgid "You need to fill up at least the two first entries."
-msgstr "您至少需要輸入前面兩個項目。"
+msgid "More info"
+msgstr ""
#: ../rpmdrake:1
#, c-format
-msgid "Install"
-msgstr "安裝"
+msgid "Addable"
+msgstr "可供加入"
-#: ../rpmdrake.pm:1
-#, c-format
-msgid "Japan"
-msgstr "日本"
+#: ../rpmdrake:1
+#, fuzzy, c-format
+msgid "Upgradable"
+msgstr "更新"
#: ../rpmdrake:1
#, c-format
-msgid "Do nothing"
-msgstr "沒有進行任何動作"
+msgid ""
+"The list of updates is void. This means that either there is\n"
+"no available update for the packages installed on your computer,\n"
+"or you already installed all of them."
+msgstr ""
+"更新的清單項目是空的,也許是您尚未新增任何更新的媒介項目,\n"
+"或者是您的系統目前都已經安裝上最新的套件了。"
#: ../rpmdrake:1
#, fuzzy, c-format
@@ -684,346 +723,381 @@ msgid "No update"
msgstr "更新"
#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Description: "
-msgstr "描述"
+#, c-format
+msgid "(none)"
+msgstr "(無)"
#: ../rpmdrake:1
-#, c-format
-msgid ""
-"Installation failed, some files are missing.\n"
-"You may want to update your sources database."
+#, fuzzy, c-format
+msgid "Please wait, listing packages..."
msgstr ""
-"安裝失敗。安裝程式找不到一些要安裝上的程式套件。\n"
-"也許是系統資料庫太舊了,請先更新資料庫後再繼續。"
+"請稍候\n"
+"排序套件"
+
+#: ../rpmdrake:1
+#, fuzzy, c-format
+msgid "unknown package "
+msgstr "不詳"
#: ../rpmdrake:1
#, c-format
-msgid ""
-"Warning: it seems that you are attempting to add so much\n"
-"packages that your filesystem may run out of free diskspace,\n"
-"during or after package installation ; this is particularly\n"
-"dangerous and should be considered with care.\n"
-"\n"
-"Do you really want to install all the selected packages?"
-msgstr ""
-"警告: 您選取了許多要安裝更新的套件,不過您的磁碟空間\n"
-"似乎已經不敷使用,建議您先整理挪出可用的空間再進行下面\n"
-"的安裝,以避免任何問題發生。\n"
-"您確定還是要安裝您所選取的套件嗎?"
+msgid "One of the following packages is needed:"
+msgstr "將需要下列的其中之一套件:"
#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Name: "
-msgstr "名稱: %s"
+#, c-format
+msgid "Please choose"
+msgstr "請選擇"
#: ../rpmdrake:1
#, c-format
-msgid "Inspect..."
-msgstr "檢查..."
+msgid "rpmdrake"
+msgstr "rpmdrake"
#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "No package found for installation."
-msgstr "正在準備安裝"
+msgid "Not selected"
+msgstr "偵測到相衝突的資訊"
-#: ../rpmdrake.pm:1
+#: ../rpmdrake:1
+#, fuzzy, c-format
+msgid "Selected"
+msgstr ""
+"全\n"
+"選 "
+
+#: ../rpmdrake:1
#, c-format
-msgid "Australia"
-msgstr "澳洲"
+msgid "Search results"
+msgstr "搜尋結果"
#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Installation finished"
-msgstr "已安裝"
+#, c-format
+msgid "Stop"
+msgstr "停止"
#: ../rpmdrake:1
#, c-format
-msgid "by update availability"
-msgstr "依可供更新分類"
+msgid "Please wait, searching..."
+msgstr "請稍候,搜尋中..."
-#: ../rpmdrake.pm:1
+#: ../rpmdrake:1
#, c-format
-msgid "Poland"
-msgstr "波蘭"
+msgid "Search results (none)"
+msgstr "搜尋結果 (無任何符合的項目)"
#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Version: "
-msgstr "版本:"
+#, c-format
+msgid "Other"
+msgstr "其他"
#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "You may specify a user/password for the proxy authentication:"
-msgstr "您需要指定使用者帳號/密碼,以便於能夠使用代理伺服器認證:"
+msgid ""
+"Welcome to the packages source editor!\n"
+"\n"
+"This tool will help you configure the packages sources you wish to use on\n"
+"your computer. They will then be available to install new software package\n"
+"or to perform updates."
+msgstr ""
+"歡迎來到套件來源編輯程式!\n"
+"\n"
+"接下來程式將會引導你完成編輯套件來源的項目,\n"
+"以便於提供您能夠使用您所設定的項目進行軟體的安裝與更新。"
+
+#: ../edit-urpm-sources.pl:1
+#, c-format
+msgid "Save and quit"
+msgstr "儲存並離開"
#: ../edit-urpm-sources.pl:1
#, fuzzy, c-format
-msgid "Editing source \\\"%s\\\":"
-msgstr "編輯來源 \"%s\":"
+msgid "Proxy..."
+msgstr "錯誤..."
-#: ../rpmdrake:1
+#: ../edit-urpm-sources.pl:1
#, fuzzy, c-format
-msgid "Upgradable"
+msgid "Update..."
msgstr "更新"
-#: ../rpmdrake.pm:1
+#: ../edit-urpm-sources.pl:1
#, c-format
-msgid " done."
-msgstr ""
+msgid "Add..."
+msgstr "新增..."
-#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Software Packages Installation"
-msgstr "正在準備安裝"
+#: ../edit-urpm-sources.pl:1
+#, c-format
+msgid "Edit"
+msgstr "編輯"
-#: ../rpmdrake.pm:1
+#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "Examining file of source `%s'..."
-msgstr ""
+msgid "Source"
+msgstr "來源"
-#: ../rpmdrake:1
+#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "Additional packages needed"
-msgstr "需要額外的套件項目"
+msgid "Enabled?"
+msgstr "開啟"
-#: ../rpmdrake:1
+#: ../edit-urpm-sources.pl:1
+#, c-format
+msgid "Configure sources"
+msgstr "設定套件來源位置?"
+
+#: ../edit-urpm-sources.pl:1
+#, c-format
+msgid "Password:"
+msgstr "密碼:"
+
+#: ../edit-urpm-sources.pl:1
#, fuzzy, c-format
-msgid "Bugfixes updates"
-msgstr "顯示修正錯誤的更新套件"
+msgid "User:"
+msgstr "使用者名稱:"
-#: ../rpmdrake.pm:1
+#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "Download of `%s', time to go:%s, speed:%s"
+msgid "You may specify a user/password for the proxy authentication:"
+msgstr "您需要指定使用者帳號/密碼,以便於能夠使用代理伺服器認證:"
+
+#: ../edit-urpm-sources.pl:1
+#, fuzzy, c-format
+msgid "Proxy hostname:"
+msgstr "使用者名稱 (代理伺服器):"
+
+#: ../edit-urpm-sources.pl:1
+#, c-format
+msgid ""
+"If you need a proxy, enter the hostname and an optional port (syntax: "
+"<proxyhost[:port]>):"
msgstr ""
+"如果您需要透過代理伺服器連線,請輸入該主機名稱與連結埠埠號(比方 proxy.hinet."
+"net:80):"
-#: ../rpmdrake.pm:1
+#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "Germany"
-msgstr "德國"
+msgid "Configure proxies"
+msgstr "設定代理伺服器"
-#: ../rpmdrake.pm:1
+#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "Russia"
-msgstr "蘇俄"
+msgid "Please wait, updating medium..."
+msgstr "請稍後,更新媒介中..."
-#: ../rpmdrake.pm:1
+#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "Norway"
-msgstr "挪威"
+msgid ""
+"In order to save the changes, you need to insert the medium in the drive."
+msgstr "為了能夠儲存變更,請置入該媒介裝置後於磁碟機繼續。"
-#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Problem during installation"
-msgstr "安裝時發生問題"
+#: ../edit-urpm-sources.pl:1
+#, c-format
+msgid "You need to insert the medium to continue"
+msgstr "請插入媒介裝置後繼續"
-#: ../rpmdrake:1
+#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "Search"
-msgstr "尋找"
+msgid "Save changes"
+msgstr "儲存變更"
+
+#: ../edit-urpm-sources.pl:1
+#, c-format
+msgid "Relative path to synthesis/hdlist:"
+msgstr "synthesis/hdlist 檔案的相對路徑:"
+
+#: ../edit-urpm-sources.pl:1
+#, c-format
+msgid "URL:"
+msgstr "URL:"
+
+#: ../edit-urpm-sources.pl:1
+#, fuzzy, c-format
+msgid "Editing source \"%s\":"
+msgstr "編輯來源 \"%s\":"
#: ../edit-urpm-sources.pl:1
#, c-format
msgid "Edit a source"
msgstr "編輯套件來源"
-#: ../rpmdrake.pm:1
+#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "Czech Republic"
-msgstr "捷克共和國"
+msgid "Please wait, removing medium..."
+msgstr "請稍後,正在移除媒介來源..."
-#: ../rpmdrake:1
+#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "Stop"
-msgstr "停止"
+msgid "Type of source:"
+msgstr "來源類別:"
-#: ../rpmdrake.pm:1
+#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "Update"
-msgstr "更新"
+msgid "Adding a source:"
+msgstr "新增來源:"
-#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Please wait, removing packages..."
+#: ../edit-urpm-sources.pl:1
+#, c-format
+msgid ""
+"There is already a medium by that name, do you\n"
+"really want to replace it?"
msgstr ""
-"請稍候\n"
-"排序套件"
+"該媒介裝置項目已經存在了,\n"
+"您確定要置換原本項目嗎?"
-#: ../rpmdrake:1
+#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "Normal information"
-msgstr "一般資訊"
+msgid "You need to fill up at least the two first entries."
+msgstr "您至少需要輸入前面兩個項目。"
-#: ../rpmdrake:1
-#, c-format
-msgid "Downloading package `%s' (%s/%s)..."
-msgstr "正在下載「%s」(%s/%s)..."
+#: ../edit-urpm-sources.pl:1
+#, fuzzy, c-format
+msgid "Name:"
+msgstr "名稱"
-#: ../rpmdrake:1
+#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "Selected: %d MB / Free disk space: %d MB"
-msgstr "已選擇:%d MB / 可用磁碟空間:%d MB"
+msgid "Login:"
+msgstr "登入:"
-#: ../rpmdrake.pm:1
+#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "Spain"
-msgstr "西班牙"
+msgid "Choose a mirror..."
+msgstr "選擇映射地址..."
-#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Normal updates"
-msgstr "正常更新"
+#: ../edit-urpm-sources.pl:1
+#, c-format
+msgid "Browse..."
+msgstr "瀏覽..."
-#: ../rpmdrake:1
+#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "by selection state"
-msgstr "依選擇狀態分類"
+msgid "Path or mount point:"
+msgstr "路徑或是掛載點:"
-#: ../rpmdrake.pm:1
+#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "Please wait, downloading mirrors addresses from MandrakeSoft website."
-msgstr "請稍後,正在由 MandrakeSoft 總部取回映射站台清單。"
+msgid "Removable device"
+msgstr "可移除裝置"
#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "Login:"
-msgstr "登入:"
+msgid "HTTP server"
+msgstr "HTTP 主機"
-#: ../rpmdrake.pm:1
+#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "Austria"
-msgstr "奧地利"
+msgid "FTP server"
+msgstr "FTP 主機"
-#: ../rpmdrake:1
+#: ../edit-urpm-sources.pl:1
#, fuzzy, c-format
-msgid "Fatal error"
-msgstr "檔案錯誤"
+msgid "Path:"
+msgstr "埠號:"
-#: ../rpmdrake.pm:1
+#: ../edit-urpm-sources.pl:1
#, c-format
-msgid "Select the source(s) you wish to update:"
-msgstr "請選擇您要更新的來源:"
+msgid "Local files"
+msgstr "本機檔案"
#: ../edit-urpm-sources.pl:1
#, fuzzy, c-format
-msgid "Update..."
-msgstr "更新"
+msgid "Add a source"
+msgstr "新增來源:"
#: ../rpmdrake.pm:1
#, fuzzy, c-format
-msgid "Starting download of `%s'..."
-msgstr "確認 '%s' 套件的簽名資訊"
-
-#: ../rpmdrake:1
-#, c-format
-msgid "(none)"
-msgstr "(無)"
-
-#: ../rpmdrake:1
-#, fuzzy, c-format
msgid ""
-"Removing these packages would break your system, sorry:\n"
+"Unable to update medium; it will be automatically disabled.\n"
"\n"
-msgstr "抱歉,若是移除下面這些套件可能會讓您的系統出錯:\n"
+"Errors:\n"
+"%s"
+msgstr "無法更新媒介,該項目將會暫時自動關閉。"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "Installing package `%s' (%s/%s)..."
-msgstr "正在安裝套件 '%s (%s/%s)..."
+msgid "Unable to create medium."
+msgstr "無法建立媒介項目。"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "Currently installed version: "
-msgstr "目前已安裝的版本:"
+msgid "Update"
+msgstr "更新"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "Other"
-msgstr "其他"
+msgid "Select the source(s) you wish to update:"
+msgstr "請選擇您要更新的來源:"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "Reason for update: "
-msgstr "更新的原因: "
+msgid "Please wait, updating media..."
+msgstr "請稍後,更新媒介中..."
#: ../rpmdrake.pm:1
#, fuzzy, c-format
-msgid "Please choose the desired mirror."
-msgstr ""
-"請稍候\n"
-"正在取回映射地址的清單"
+msgid " failed!"
+msgstr "依檔案"
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "Edit"
-msgstr "編輯"
-
-#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Please wait, finding available packages..."
+msgid " done."
msgstr ""
-"請稍候\n"
-"排序套件"
-
-#: ../edit-urpm-sources.pl:1
-#, c-format
-msgid "Relative path to synthesis/hdlist:"
-msgstr "synthesis/hdlist 檔案的相對路徑:"
-
-#: ../rpmdrake:1
-#, c-format
-msgid "Search results (none)"
-msgstr "搜尋結果 (無任何符合的項目)"
#: ../rpmdrake.pm:1
#, c-format
-msgid "Danmark"
-msgstr "丹麥"
+msgid "Download of `%s', speed:%s"
+msgstr ""
#: ../rpmdrake.pm:1
#, c-format
-msgid "China"
-msgstr "中國大陸"
+msgid "Download of `%s', time to go:%s, speed:%s"
+msgstr ""
#: ../rpmdrake.pm:1
-#, c-format
-msgid "United States"
-msgstr "美國"
-
-#: ../rpmdrake:1
#, fuzzy, c-format
-msgid "changes:"
-msgstr "儲存變更"
+msgid "Starting download of `%s'..."
+msgstr "確認 '%s' 套件的簽名資訊"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "Some additional packages need to be removed"
-msgstr "為了可以全面運作正常這些額外的套件必須一同安裝"
+msgid "Examining distant file of source `%s'..."
+msgstr ""
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "rpmdrake"
-msgstr "rpmdrake"
+msgid "Examining file of source `%s'..."
+msgstr ""
#: ../rpmdrake.pm:1
#, c-format
-msgid "No"
-msgstr "否"
+msgid "Copying file for source `%s'..."
+msgstr ""
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, fuzzy, c-format
-msgid "Summary: "
-msgstr "摘要"
+msgid "Please choose the desired mirror."
+msgstr ""
+"請稍候\n"
+"正在取回映射地址的清單"
#: ../rpmdrake.pm:1
#, c-format
-msgid "Canada"
-msgstr "加拿大"
+msgid ""
+"I can't find any suitable mirror.\n"
+"\n"
+"There can be many reasons for this problem; the most frequent is\n"
+"the case when the architecture of your processor is not supported\n"
+"by Mandrake Linux Official Updates."
+msgstr ""
+"安裝程式找不到適合的映射站台。\n"
+"\n"
+"會發生這個問題的情況相當多,比方 Mandrake Linux\n"
+"更新站台目前尚不支援您目前用的機器平台。"
#: ../rpmdrake.pm:1
-#, c-format
-msgid "Greece"
-msgstr "希臘"
+#, fuzzy, c-format
+msgid "No mirror"
+msgstr "映射:"
#: ../rpmdrake.pm:1
#, c-format
@@ -1040,252 +1114,178 @@ msgstr ""
"也許是網路連線失敗,或者是 MandrakeSoft 站台暫時無法聯繫上,\n"
"請稍後再試。"
-#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Source: "
-msgstr "來源"
-
#: ../rpmdrake.pm:1
#, c-format
-msgid "Copying file for source `%s'..."
-msgstr ""
-
-#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Unable to get source packages, sorry. %s"
-msgstr "抱歉,您需要具備 root 權限身份才可以進行套件安裝。"
-
-#: ../edit-urpm-sources.pl:1
-#, fuzzy, c-format
-msgid "Path:"
-msgstr "埠號:"
-
-#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Problem during removal"
-msgstr "安裝時發生問題"
-
-#: ../rpmdrake:1
-#, c-format
-msgid "by source repository"
-msgstr "依來源倉儲分類"
-
-#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Selected"
-msgstr ""
-"全\n"
-"選 "
+msgid "Error during download"
+msgstr "下載發生錯誤"
#: ../rpmdrake.pm:1
#, c-format
-msgid "Netherlands"
-msgstr "荷蘭"
-
-#: ../rpmdrake:1
-#, c-format
-msgid "Addable"
-msgstr "可供加入"
+msgid "Please wait, downloading mirrors addresses from MandrakeSoft website."
+msgstr "請稍後,正在由 MandrakeSoft 總部取回映射站台清單。"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "(Not available)"
-msgstr "(無法使用)"
-
-#: ../rpmdrake:1
-#, fuzzy, c-format
msgid ""
-"Sorry, the following package(s) can't be selected:\n"
-"\n"
-"%s\n"
-"\n"
-"Reasons follow:\n"
+"I need to contact MandrakeSoft website to get the mirrors list.\n"
+"Please check that your network is currently running.\n"
"\n"
-"%s"
+"Is it ok to continue?"
msgstr ""
-"抱歉,下面的套件項目將不能夠被選取:\n"
+"安裝程式需要連線到 MandrakeSoft 總部取回映射站台的清單檔案。\n"
+"請確定您目前網路能夠正常連線出去。\n"
"\n"
+"您要繼續嗎?"
-#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Not selected"
-msgstr "偵測到相衝突的資訊"
-
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "Software Packages Removal"
-msgstr "移除套件程式"
+msgid "United States"
+msgstr "美國"
#: ../rpmdrake.pm:1
#, c-format
-msgid "Sweden"
-msgstr "瑞典"
+msgid "China"
+msgstr "中國大陸"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid ""
-"\n"
-"\n"
-"Error(s) reported:\n"
-"%s"
-msgstr ""
+msgid "United Kingdom"
+msgstr "聯合國"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid ""
-"The list of updates is void. This means that either there is\n"
-"no available update for the packages installed on your computer,\n"
-"or you already installed all of them."
-msgstr ""
-"更新的清單項目是空的,也許是您尚未新增任何更新的媒介項目,\n"
-"或者是您的系統目前都已經安裝上最新的套件了。"
+msgid "Taiwan"
+msgstr "台灣"
#: ../rpmdrake.pm:1
#, c-format
-msgid "Download of `%s', speed:%s"
-msgstr ""
+msgid "Sweden"
+msgstr "瑞典"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "One of the following packages is needed:"
-msgstr "將需要下列的其中之一套件:"
+msgid "Russia"
+msgstr "蘇俄"
-#: ../rpmdrake:1 ../edit-urpm-sources.pl:1
-#, c-format
-msgid "Quit"
-msgstr "離開"
+#: ../rpmdrake.pm:1
+#, fuzzy, c-format
+msgid "Portugal"
+msgstr "埠號:"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid ""
-"I need to contact the mirror to get latest update packages.\n"
-"Please check that your network is currently running.\n"
-"\n"
-"Is it ok to continue?"
-msgstr ""
-"安裝程式需要連線到映射站台以便於取回最新的更新套件。\n"
-"請確定您目前的網路能夠正常連線到外面。\n"
-"\n"
-"您現在要繼續嗎?"
+msgid "Poland"
+msgstr "波蘭"
-#: ../rpmdrake:1 ../edit-urpm-sources.pl:1 ../rpmdrake.pm:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "Ok"
-msgstr "確定"
+msgid "Norway"
+msgstr "挪威"
-#: ../rpmdrake:1 ../edit-urpm-sources.pl:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "Please wait, adding medium..."
-msgstr "請稍後,正在加入媒介來源..."
+msgid "Netherlands"
+msgstr "荷蘭"
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake.pm:1
+#, fuzzy, c-format
+msgid "Korea"
+msgstr "強迫"
+
+#: ../rpmdrake.pm:1
#, c-format
-msgid "Type of source:"
-msgstr "來源類別:"
+msgid "Japan"
+msgstr "日本"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, fuzzy, c-format
-msgid "Please insert the medium named \\\"%s\\\" on device [%s]"
-msgstr "請置入媒介名稱為 \"%s\" 的項目放置於 %s 裝置"
+msgid "Italy"
+msgstr "安裝"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, fuzzy, c-format
-msgid "Unable to get source packages."
-msgstr "選擇套件"
+msgid "Israel"
+msgstr "安裝"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "Too many packages are selected"
-msgstr "選取太多了套件項目"
+msgid "Greece"
+msgstr "希臘"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, fuzzy, c-format
-msgid "%s conflicts with %s"
-msgstr " 與 %s-%s-%s 沖突"
+msgid "France"
+msgstr "強迫"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid ""
-"Welcome to MandrakeUpdate!\n"
-"\n"
-"This tool will help you choose the updates you want to install on your\n"
-"computer."
-msgstr ""
-"歡迎來到套件更新程式!\n"
-"接下來程式將會引導你完成套件更新與安裝。"
+msgid "Finland"
+msgstr "芬蘭"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "Mandrake choices"
-msgstr "Mandrake 分類"
+msgid "Spain"
+msgstr "西班牙"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid ""
-"You may also choose your desired mirror manually: to do so,\n"
-"launch the Software Sources Manager, and then add a `Security\n"
-"updates' source.\n"
-"\n"
-"Then, restart MandrakeUpdate."
-msgstr ""
-"您已經手動選擇您需要的映射站台了,建議您請稍後手動執行\n"
-"套件來源管理員,針對您的映射站台另外加入「安全修正」項目。\n"
-"\n"
-"完成後,請重新啟動 MandrakeUpdate 程式。"
+msgid "Danmark"
+msgstr "丹麥"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "Changelog:\n"
-msgstr "變更紀錄:\n"
+msgid "Germany"
+msgstr "德國"
#: ../rpmdrake.pm:1
-#, fuzzy, c-format
-msgid "Korea"
-msgstr "強迫"
+#, c-format
+msgid "Czech Republic"
+msgstr "捷克共和國"
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "Removable device"
-msgstr "可移除裝置"
+msgid "Costa Rica"
+msgstr "哥斯大黎加"
+
+#: ../rpmdrake.pm:1
+#, c-format
+msgid "Canada"
+msgstr "加拿大"
+
+#: ../rpmdrake.pm:1
+#, c-format
+msgid "Brazil"
+msgstr "巴西"
#: ../rpmdrake.pm:1
#, c-format
msgid "Belgium"
msgstr "比利時"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "Change medium"
-msgstr "變更媒介"
-
-#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Mandrake Update"
-msgstr "MandrakeUpdate 編好設定"
+msgid "Australia"
+msgstr "澳洲"
-#: ../rpmdrake:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "by size"
-msgstr "依大小分類"
+msgid "Austria"
+msgstr "奧地利"
-#: ../edit-urpm-sources.pl:1
+#: ../rpmdrake.pm:1
#, c-format
-msgid "FTP server"
-msgstr "FTP 主機"
+msgid "Info..."
+msgstr "資訊..."
-#: ../rpmdrake:1
-#, fuzzy, c-format
-msgid "Files:\n"
-msgstr "/檔案 (_F)"
+#: ../rpmdrake.pm:1
+#, c-format
+msgid "No"
+msgstr "否"
#: ../rpmdrake.pm:1
-#, fuzzy, c-format
-msgid ""
-"Unable to update medium; it will be automatically disabled.\n"
-"\n"
-"Errors:\n"
-"%s"
-msgstr "無法更新媒介,該項目將會暫時自動關閉。"
+#, c-format
+msgid "Yes"
+msgstr "是"
#: ../grpmi/curl_download/curl_download.xs:86
msgid "Download directory does not exist"
2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512
package urpm;

# $Id$

no warnings 'utf8';
use strict;
use File::Find ();
use urpm::msg;
use urpm::download;
use urpm::util;
use urpm::sys;
use urpm::cfg;
use MDV::Distribconf;

our $VERSION = '4.8.23';
our @ISA = qw(URPM);

use URPM;
use URPM::Resolve;

BEGIN {
    # this doesn't work for perls >= 5.9.4
    if ($ENV{DEBUG_URPMI}) {
	require encoding::warnings;
	encoding::warnings->import;
    }
}

#- this violently overrides is_arch_compat() to always return true.
sub shunt_ignorearch {
    eval q( sub URPM::Package::is_arch_compat { 1 } );
}

#- create a new urpm object.
sub new {
    my ($class) = @_;
    my $self;
    $self = bless {
	# from URPM
	depslist   => [],
	provides   => {},

	config     => "/etc/urpmi/urpmi.cfg",
	skiplist   => "/etc/urpmi/skip.list",
	instlist   => "/etc/urpmi/inst.list",
	statedir   => "/var/lib/urpmi",
	cachedir   => "/var/cache/urpmi",
	media      => undef,
	options    => {},

	#- sync: first argument is options hashref, others are urls to fetch.
	sync       => sub { $self->sync_webfetch(@_) },
	fatal      => sub { printf STDERR "%s\n", $_[1]; exit($_[0]) },
	error      => sub { printf STDERR "%s\n", $_[0] },
	log        => sub { printf "%s\n", $_[0] },
	ui_msg     => sub {
	    $self->{log}($_[0]);
	    ref $self->{ui} && ref $self->{ui}{msg} and $self->{ui}{msg}->($_[1]);
	},
    }, $class;
    $self->set_nofatal(1);
    $self;
}

#- syncing algorithms.
sub sync_webfetch {
    my $urpm = shift;
    my $options = shift;
    my %files;
    #- currently ftp and http protocols are managed by curl or wget,
    #- ssh and rsync protocols are managed by rsync *AND* ssh.
    foreach (@_) {
	/^([^:_]*)[^:]*:/ or die N("unknown protocol defined for %s", $_);
	push @{$files{$1}}, $_;
    }
    if ($files{removable} || $files{file}) {
	eval {
	    sync_file($options, @{$files{removable} || []}, @{$files{file} || []});
	};
	$urpm->{fatal}(10, $@) if $@;
	delete @files{qw(removable file)};
    }
    for my $cpt (qw(wget-options curl-options rsync-options)) {
	$options->{$cpt} = $urpm->{options}{$cpt} if defined $urpm->{options}{$cpt};
    }
    if ($files{ftp} || $files{http} || $files{https}) {
	my @webfetch = qw(curl wget);
	my @available_webfetch = grep { -x "/usr/bin/$_" || -x "/bin/$_" } @webfetch;
	#- use user default downloader if provided and available
	my $option_downloader = $urpm->{options}{downloader}; #- cmd-line switch
	if (!$option_downloader && $options->{media}) { #- per-media config
	    (my $m) = grep { $_->{name} eq $options->{media} } @{$urpm->{media}};
	    ref $m && $m->{downloader} and $option_downloader = $m->{downloader};
	}
	#- global config
	!$option_downloader && exists $urpm->{global_config}{downloader}
	    and $option_downloader = $urpm->{global_config}{downloader};
	my ($preferred) = grep { $_ eq $option_downloader } @available_webfetch;
	#- else first downloader of @webfetch is the default one
	$preferred ||= $available_webfetch[0];
	if ($option_downloader ne $preferred && $option_downloader && !our $webfetch_not_available) {
	    $urpm->{log}(N("%s is not available, falling back on %s", $option_downloader, $preferred));
	    $webfetch_not_available = 1;
	}
	if ($preferred eq 'curl') {
	    sync_curl($options, @{$files{ftp} || []}, @{$files{http} || []}, @{$files{https} || []});
	} elsif ($preferred eq 'wget') {
	    sync_wget($options, @{$files{ftp} || []}, @{$files{http} || []}, @{$files{https} || []});
	} else {
	    die N("no webfetch found, supported webfetch are: %s\n", join(", ", @webfetch));
	}
	delete @files{qw(ftp http https)};
    }
    if ($files{rsync}) {
	sync_rsync($options, @{$files{rsync} || []});
	delete $files{rsync};
    }
    if ($files{ssh}) {
	my @ssh_files;
	foreach (@{$files{ssh} || []}) {
	    m|^ssh://([^/]*)(.*)| and push @ssh_files, "$1:$2";
	}
	sync_ssh($options, @ssh_files);
	delete $files{ssh};
    }
    %files and die N("unable to handle protocol: %s", join ', ', keys %files);
}

our @PER_MEDIA_OPT = qw(
    downloader
    hdlist
    ignore
    key-ids
    list
    md5sum
    noreconfigure
    priority
    removable
    static
    synthesis
    update
    verify-rpm
    virtual
    with_hdlist
);

#- Loads /etc/urpmi/urpmi.cfg and performs basic checks.
#- Does not handle old format: <name> <url> [with <path_hdlist>]
#- options :
#-    - nocheck_access : don't check presence of hdlist and other files
sub read_config {
    my ($urpm, %options) = @_;
    return if $urpm->{media}; #- media already loaded
    $urpm->{media} = [];
    my $config = urpm::cfg::load_config($urpm->{config})
	or $urpm->{fatal}(6, $urpm::cfg::err);

    #- global options
    if ($config->{''}) {
	foreach my $opt (qw(
	    allow-force
	    allow-nodeps
	    auto
	    compress
	    downloader
	    default-media
	    excludedocs
	    excludepath
	    fuzzy
	    ignoresize
	    keep
	    key-ids
	    limit-rate
	    nopubkey
	    norebuild
	    post-clean
	    pre-clean
	    priority-upgrade
	    prohibit-remove
	    repackage
	    resume
	    retry
	    split-length
	    split-level
	    strict-arch
	    verify-rpm
	    curl-options
	    rsync-options
	    wget-options
	)) {
	    if (defined $config->{''}{$opt} && !exists $urpm->{options}{$opt}) {
		$urpm->{options}{$opt} = $config->{''}{$opt};
	    }
	}
    }
    #- per-media options
    foreach my $m (grep { $_ ne '' } keys %$config) {
	my $medium = { name => $m, clear_url => $config->{$m}{url} };
	foreach my $opt (@PER_MEDIA_OPT) {
	    defined $config->{$m}{$opt} and $medium->{$opt} = $config->{$m}{$opt};
	}
	$urpm->probe_medium($medium, %options) and push @{$urpm->{media}}, $medium;
    }

    eval { require urpm::ldap; urpm::ldap::load_ldap_media($urpm, %options) };

    #- load default values
    foreach (qw(post-clean verify-rpm)) {
	exists $urpm->{options}{$_} or $urpm->{options}{$_} = 1;
    }

    $urpm->{media} = [ sort { $a->{priority} <=> $b->{priority} } @{$urpm->{media}} ];

    #- remember if an hdlist or list file is already used
    my %filelists;
    foreach (@{$urpm->{media}}) {
	foreach my $filetype (qw(hdlist list)) {
	    if ($_->{$filetype}) {
		exists($filelists{$filetype}{$_->{$filetype}})
		    and $_->{ignore} = 1,
		    $urpm->{error}(
			$filetype eq 'hdlist'
			    ? N("medium \"%s\" trying to use an already used hdlist, medium ignored", $_->{name})
			    : N("medium \"%s\" trying to use an already used list, medium ignored",   $_->{name})
		    );
		$filelists{$filetype}{$_->{$filetype}} = undef;
	    }
	}
    }

    #- check the presence of hdlist and list files if necessary.
    unless ($options{nocheck_access}) {
	foreach (@{$urpm->{media}}) {
	    $_->{ignore} and next;
	    -r "$urpm->{statedir}/$_->{hdlist}" || -r "$urpm->{statedir}/synthesis.$_->{hdlist}" && $_->{synthesis}
		or $_->{ignore} = 1,
		$urpm->{error}(N("unable to access hdlist file of \"%s\", medium ignored", $_->{name}));
	    $_->{list} && -r "$urpm->{statedir}/$_->{list}" || defined $_->{url}
		or $_->{ignore} = 1,
		$urpm->{error}(N("unable to access list file of \"%s\", medium ignored", $_->{name}));
	}
    }

    #- read MD5 sums (usually not in urpmi.cfg but in a separate file)
    my $md5sum = $urpm->open_safe("<", "$urpm->{statedir}/MD5SUM");
    if ($md5sum) {
	local $_;
	while (<$md5sum>) {
	    my ($md5sum, $file) = /(\S*)\s+(.*)/;
	    foreach (@{$urpm->{media}}) {
		($_->{synthesis} ? "synthesis." : "") . $_->{hdlist} eq $file
		    and $_->{md5sum} = $md5sum, last;
	    }
	}
	close $md5sum;
    }

    #- remember global options for write_config
    $urpm->{global_config} = $config->{''};
}

#- probe medium to be used, take old medium into account too.
sub probe_medium {
    my ($urpm, $medium, %options) = @_;
    local $_;

    foreach (@{$urpm->{media}}) {
	if ($_->{name} eq $medium->{name}) {
	    $urpm->{error}(N("trying to override existing medium \"%s\", skipping", $medium->{name}));
	    return;
	}
    }

    $medium->{url} ||= $medium->{clear_url};

    if ($medium->{virtual}) {
	#- a virtual medium needs to have an url available without using a list file.
	if ($medium->{hdlist} || $medium->{list}) {
	    $medium->{ignore} = 1;
	    $urpm->{error}(N("virtual medium \"%s\" should not have defined hdlist or list file, medium ignored",
			     $medium->{name}));
	}
	unless ($medium->{url}) {
	    $medium->{ignore} = 1;
	    $urpm->{error}(N("virtual medium \"%s\" should have a clear url, medium ignored",
			     $medium->{name}));
	}
    } else {
	unless ($medium->{ignore} || $medium->{hdlist}) {
	    $medium->{hdlist} = "hdlist.$medium->{name}.cz";
	    -e "$urpm->{statedir}/$medium->{hdlist}" or $medium->{hdlist} = "hdlist.$medium->{name}.cz2";
	    -e "$urpm->{statedir}/$medium->{hdlist}" or
	      $medium->{ignore} = 1,
		$urpm->{error}(N("unable to find hdlist file for \"%s\", medium ignored", $medium->{name}));
	}
	unless ($medium->{ignore} || $medium->{list}) {
	    unless (defined $medium->{url}) {
		$medium->{list} = "list.$medium->{name}";
		unless (-e "$urpm->{statedir}/$medium->{list}") {
		    $medium->{ignore} = 1,
		      $urpm->{error}(N("unable to find list file for \"%s\", medium ignored", $medium->{name}));
		}
	    }
	}

	#- there is a little more to do at this point as url is not known, inspect directly list file for it.
	unless ($medium->{url}) {
	    my %probe;
	    if (-r "$urpm->{statedir}/$medium->{list}") {
		my $listfile = $urpm->open_safe("<", "$urpm->{statedir}/$medium->{list}");
		if ($listfile) {
		    while (<$listfile>) {
			#- /./ is end of url marker in list file (typically generated by a
			#- find . -name "*.rpm" > list
			#- for exportable list file.
			m|^(.*)/\./| and $probe{$1} = undef;
			m|^(.*)/[^/]*$| and $probe{$1} = undef;
		    }
		    close $listfile;
		}
	    }
	    foreach (sort { length($a) <=> length($b) } keys %probe) {
		if ($medium->{url}) {
		    if ($medium->{url} ne substr($_, 0, length($medium->{url}))) {
			$medium->{ignore} or $urpm->{error}(N("inconsistent list file for \"%s\", medium ignored", $medium->{name}));
			$medium->{ignore} = 1;
			last;
		    }
		} else {
		    $medium->{url} = $_;
		}
	    }
	    unless ($options{nocheck_access}) {
		unless ($medium->{url}) {
		    $medium->{ignore} or $urpm->{error}(N("unable to inspect list file for \"%s\", medium ignored", $medium->{name}));
		    $medium->{ignore} = 1;
		}
	    }
	}
    }

    #- probe removable device.
    $urpm->probe_removable_device($medium);

    #- clear URLs for trailing /es.
    $medium->{url} and $medium->{url} =~ s|(.*?)/*$|$1|;
    $medium->{clear_url} and $medium->{clear_url} =~ s|(.*?)/*$|$1|;

    $medium;
}

#- returns the removable device name if it corresponds to an iso image, '' otherwise
sub is_iso {
    my ($removable_dev) = @_;
    $removable_dev && $removable_dev =~ /\.iso$/i ? $removable_dev : '';
}

#- probe device associated with a removable device.
sub probe_removable_device {
    my ($urpm, $medium) = @_;

    #- try to find device name in url scheme
    if ($medium->{url} && $medium->{url} =~ /^removable_?([^_:]*)(?:_[^:]*)?:/) {
	$medium->{removable} ||= $1 && "/dev/$1";
    } else {
	delete $medium->{removable};
    }

    #- try to find device to open/close for removable medium.
    if (exists($medium->{removable})) {
	if (my ($dir) = $medium->{url} =~ m!^(?:(?:file|removable)[^:]*:/)?(/.*)!) {
	    my %infos;
	    my @mntpoints = urpm::sys::find_mntpoints($dir, \%infos);
	    if (@mntpoints > 1) { #- return value is suitable for an hash.
		$urpm->{log}(N("too many mount points for removable medium \"%s\"", $medium->{name}));
		$urpm->{log}(N("taking removable device as \"%s\"", join ',', map { $infos{$_}{device} } @mntpoints));
	    }
	    if (is_iso($medium->{removable})) {
		$urpm->{log}(N("Medium \"%s\" is an ISO image, will be mounted on-the-fly", $medium->{name}));
	    } elsif (@mntpoints) {
		if ($medium->{removable} && $medium->{removable} ne $infos{$mntpoints[-1]}{device}) {
		    $urpm->{log}(N("using different removable device [%s] for \"%s\"",
				   $infos{$mntpoints[-1]}{device}, $medium->{name}));
		}
		$medium->{removable} = $infos{$mntpoints[-1]}{device};
	    } else {
		$urpm->{error}(N("unable to retrieve pathname for removable medium \"%s\"", $medium->{name}));
	    }
	} else {
	    $urpm->{error}(N("unable to retrieve pathname for removable medium \"%s\"", $medium->{name}));
	}
    }
}

#- Writes the urpmi.cfg file.
sub write_config {
    my ($urpm) = @_;

    #- avoid trashing exiting configuration if it wasn't loaded
    $urpm->{media} or return;

    my $config = {
	#- global config options found in the config file, without the ones
	#- set from the command-line
	'' => $urpm->{global_config},
    };
    foreach my $medium (@{$urpm->{media}}) {
	next if $medium->{external};
	my $medium_name = $medium->{name};
	$config->{$medium_name}{url} = $medium->{clear_url};
	foreach (qw(hdlist with_hdlist list removable key-ids priority priority-upgrade update noreconfigure static ignore synthesis virtual)) {
	    defined $medium->{$_} and $config->{$medium_name}{$_} = $medium->{$_};
	}
    }
    urpm::cfg::dump_config($urpm->{config}, $config)
	or $urpm->{fatal}(6, N("unable to write config file [%s]", $urpm->{config}));

    #- write MD5SUM file
    my $md5sum = $urpm->open_safe('>', "$urpm->{statedir}/MD5SUM") or return 0;
    foreach my $medium (@{$urpm->{media}}) {
	$medium->{md5sum}
	    and print $md5sum "$medium->{md5sum}  " . ($medium->{synthesis} && "synthesis.") . $medium->{hdlist} . "\n";
    }
    close $md5sum;

    $urpm->{log}(N("wrote config file [%s]", $urpm->{config}));

    #- everything should be synced now.
    delete $urpm->{modified};
}

#- read urpmi.cfg file as well as necessary synthesis files
#- options :
#-	callback
#-	call_back_only_once
#-	excludemedia
#-	hdlist
#-	media
#-	nodepslist
#-	noinstalling
#-	noskipping
#-	parallel
#-	root
#-	searchmedia
#-	skip
#-	sortmedia
#-	update
#-	usedistrib
sub configure {
    my ($urpm, %options) = @_;

    $urpm->clean;

    $options{parallel} && $options{usedistrib} and $urpm->{fatal}(1, N("Can't use parallel mode with use-distrib mode"));

    if ($options{parallel}) {
	my ($parallel_options, $parallel_handler);
	#- read parallel configuration
	local $_;
	my $parallel = $urpm->open_safe("<", "/etc/urpmi/parallel.cfg");
	if ($parallel) {
	    while (<$parallel>) {
		chomp; s/#.*$//; s/^\s*//; s/\s*$//;
		/\s*([^:]*):(.*)/ or $urpm->{error}(N("unable to parse \"%s\" in file [%s]", $_, "/etc/urpmi/parallel.cfg")), next;
		$1 eq $options{parallel} and $parallel_options = ($parallel_options && "\n") . $2;
	    }
	    close $parallel;
	}
	#- if a configuration option has been found, use it; else fatal error.
	if ($parallel_options) {
	    foreach my $dir (grep { -d $_ } map { "$_/urpm" } @INC) {
		my $dh = $urpm->opendir_safe($dir);
		if ($dh) {
		    while (defined ($_ = readdir $dh)) { #- load parallel modules
			/parallel.*\.pm$/ && -f "$dir/$_" or next;
			$urpm->{log}->(N("examining parallel handler in file [%s]", "$dir/$_"));
			eval { require "$dir/$_"; $parallel_handler = $urpm->handle_parallel_options($parallel_options) };
			$parallel_handler and last;
		    }
		    closedir $dh;
		}
		$parallel_handler and last;
	    }
	}
	if ($parallel_handler) {
	    if ($parallel_handler->{nodes}) {
		$urpm->{log}->(N("found parallel handler for nodes: %s", join(', ', keys %{$parallel_handler->{nodes}})));
	    }
	    if (!$options{media} && $parallel_handler->{media}) {
		$options{media} = $parallel_handler->{media};
		$urpm->{log}->(N("using associated media for parallel mode: %s", $options{media}));
	    }
	    $urpm->{parallel_handler} = $parallel_handler;
	} else {
	    $urpm->{fatal}(1, N("unable to use parallel option \"%s\"", $options{parallel}));
	}
    } else {
	#- parallel is exclusive against root options.
	$urpm->{root} = $options{root};
    }

    $urpm->{root} && ! -c "$urpm->{root}/dev/null"
	and $urpm->{error}(N("there doesn't seem to be devices in the chroot in \"%s\"", $urpm->{root}));

    if ($options{synthesis}) {
	if ($options{synthesis} ne 'none') {
	    #- synthesis take precedence over media, update options.
	    $options{media} || $options{excludemedia} || $options{sortmedia} || $options{update} || $options{parallel} and
	      $urpm->{fatal}(1, N("--synthesis cannot be used with --media, --excludemedia, --sortmedia, --update or --parallel"));
	    $urpm->parse_synthesis($options{synthesis});
	    #- synthesis disables the split of transaction (too risky and not useful).
	    $urpm->{options}{'split-length'} = 0;
	}
    } else {
        if ($options{usedistrib}) {
            $urpm->{media} = [];
            $urpm->add_distrib_media("Virtual", $options{usedistrib}, %options, 'virtual' => 1);
        } else {
	    $urpm->read_config(%options);
	    if (!$options{media} && $urpm->{options}{'default-media'}) {
		$options{media} = $urpm->{options}{'default-media'};
	    }
        }
	if ($options{media}) {
	    delete $_->{modified} foreach @{$urpm->{media} || []};
	    $urpm->select_media(split /,/, $options{media});
	    foreach (grep { !$_->{modified} } @{$urpm->{media} || []}) {
		#- this is only a local ignore that will not be saved.
		$_->{ignore} = 1;
	    }
	}
	if ($options{searchmedia}) {
	   $urpm->select_media($options{searchmedia}); #- Ensure this media has been selected
	   foreach (grep { !$_->{ignore} } @{$urpm->{media} || []}) {
		$_->{name} eq $options{searchmedia} and do {
			$_->{searchmedia} = 1;
			last;
		};
	   }
	}
	if ($options{excludemedia}) {
	    delete $_->{modified} foreach @{$urpm->{media} || []};
	    $urpm->select_media(split /,/, $options{excludemedia});
	    foreach (grep { $_->{modified} } @{$urpm->{media} || []}) {
		#- this is only a local ignore that will not be saved.
		$_->{ignore} = 1;
	    }
	}
	if ($options{sortmedia}) {
	    delete $_->{modified} foreach @{$urpm->{media} || []};
	    my @oldmedia = @{$urpm->{media} || []};
	    my @newmedia;
	    foreach (split /,/, $options{sortmedia}) {
		$urpm->select_media($_);
		push @newmedia, grep { $_->{modified} } @oldmedia;
		@oldmedia = grep { !$_->{modified} } @oldmedia;
	    }
	    #- anything not selected should be added here, as it's after the selected ones.
	    $urpm->{media} = [ @newmedia, @oldmedia ];
	    #- forget remaining modified flags.
	    delete $_->{modified} foreach @{$urpm->{media} || []};
	}
	unless ($options{nodepslist}) {
	    my $second_pass;
	    do {
		foreach (grep { !$_->{ignore} && (!$options{update} || $_->{update}) } @{$urpm->{media} || []}) {
		    our $currentmedia = $_; #- hack for urpmf
		    delete @$_{qw(start end)};
		    if ($_->{virtual}) {
			my $path = $_->{url} =~ m!^(?:file:/*)?(/[^/].*[^/])/*\Z! && $1;
			if ($path) {
			    if ($_->{synthesis}) {
				$urpm->{log}(N("examining synthesis file [%s]", "$path/$_->{with_hdlist}"));
				($_->{start}, $_->{end}) = $urpm->parse_synthesis(
				    "$path/$_->{with_hdlist}", callback => $options{callback});
			    } else {
				$urpm->{log}(N("examining hdlist file [%s]", "$path/$_->{with_hdlist}"));
				#- we'll need a second pass
				defined $second_pass or $second_pass = 1;
				($_->{start}, $_->{end}) = $urpm->parse_hdlist(
				    "$path/$_->{with_hdlist}",
				    packing => 1,
				    callback => $options{call_back_only_once} && $second_pass ? undef : $options{callback},
				);
			    }
			} else {
			    $urpm->{error}(N("virtual medium \"%s\" is not local, medium ignored", $_->{name}));
			    $_->{ignore} = 1;
			}
		    } else {
			if ($options{hdlist} && -e "$urpm->{statedir}/$_->{hdlist}" && -s _ > 32) {
			    $urpm->{log}(N("examining hdlist file [%s]", "$urpm->{statedir}/$_->{hdlist}"));
			    ($_->{start}, $_->{end}) = $urpm->parse_hdlist(
				"$urpm->{statedir}/$_->{hdlist}",
				packing => 1,
				callback => $options{callback},
			    );
			} else {
			    $urpm->{log}(N("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$_->{hdlist}"));
			    ($_->{start}, $_->{end}) = $urpm->parse_synthesis(
				"$urpm->{statedir}/synthesis.$_->{hdlist}",
				callback => $options{callback},
			    );
			    unless (defined $_->{start} && defined $_->{end}) {
				$urpm->{log}(N("examining hdlist file [%s]", "$urpm->{statedir}/$_->{hdlist}"));
				($_->{start}, $_->{end}) = $urpm->parse_hdlist("$urpm->{statedir}/$_->{hdlist}",
				    packing => 1,
				    callback => $options{callback},
				);
			    }
			}
		    }
		    unless ($_->{ignore}) {
			if (defined $_->{start} && defined $_->{end}) {
			    if ($_->{searchmedia}) {
			        ($urpm->{searchmedia}{start}, $urpm->{searchmedia}{end}) = ($_->{start}, $_->{end});
				$urpm->{log}(N("Search start: %s end: %s",
					$urpm->{searchmedia}{start}, $urpm->{searchmedia}{end}));
				delete $_->{searchmedia};
			    }
			} else {
			    $urpm->{error}(N("problem reading hdlist or synthesis file of medium \"%s\"", $_->{name}));
			    $_->{ignore} = 1;
			}
		    }
		}
	    } while $second_pass && do {
		require URPM::Build;
		$urpm->{log}(N("performing second pass to compute dependencies\n"));
		$urpm->unresolved_provides_clean;
		$second_pass--;
	    };
	}
    }
    #- determine package to withdraw (from skip.list file) only if something should be withdrawn.
    unless ($options{noskipping}) {
	my %uniq;
	$urpm->compute_flags(
	    get_packages_list($urpm->{skiplist}, $options{skip}),
	    skip => 1,
	    callback => sub {
		my ($urpm, $pkg) = @_;
		$pkg->is_arch_compat && ! exists $uniq{$pkg->fullname} or return;
		$uniq{$pkg->fullname} = undef;
		$urpm->{log}(N("skipping package %s", scalar($pkg->fullname)));
	    },
	);
    }
    unless ($options{noinstalling}) {
	my %uniq;
	$urpm->compute_flags(
	    get_packages_list($urpm->{instlist}),
	    disable_obsolete => 1,
	    callback => sub {
		my ($urpm, $pkg) = @_;
		$pkg->is_arch_compat && ! exists $uniq{$pkg->fullname} or return;
		$uniq{$pkg->fullname} = undef;
		$urpm->{log}(N("would install instead of upgrade package %s", scalar($pkg->fullname)));
	    },
	);
    }
    if ($options{bug}) {
	#- and a dump of rpmdb itself as synthesis file.
	my $db = URPM::DB::open($options{root});
	my $sig_handler = sub { undef $db; exit 3 };
	local $SIG{INT} = $sig_handler;
	local $SIG{QUIT} = $sig_handler;

	$db or $urpm->{fatal}(9, N("unable to open rpmdb"));
	open my $rpmdb, "| " . ($ENV{LD_LOADER} || '') . " gzip -9 >'$options{bug}/rpmdb.cz'"
	    or $urpm->syserror("Can't fork", "gzip");
	$db->traverse(sub {
			  my ($p) = @_;
			  #- this is not right but may be enough.
			  my $files = join '@', grep { exists($urpm->{provides}{$_}) } $p->files;
			  $p->pack_header;
			  $p->build_info(fileno $rpmdb, $files);
		      });
	close $rpmdb;
    }
}

#- add a new medium, sync the config file accordingly.
#- returns the new medium's name. (might be different from the requested
#- name if index_name was specified)
sub add_medium {
    my ($urpm, $name, $url, $with_hdlist, %options) = @_;

    #- make sure configuration has been read.
    $urpm->{media} or $urpm->read_config;
    $options{nolock} or $urpm->exlock_urpmi_db;

    #- if a medium with that name has already been found, we have to exit now
    my $medium;
    if (defined $options{index_name}) {
	my $i = $options{index_name};
	do {
	    ++$i;
	    undef $medium;
	    foreach (@{$urpm->{media}}) {
		$_->{name} eq $name . $i and $medium = $_;
	    }
	} while $medium;
	$name .= $i;
    } else {
	foreach (@{$urpm->{media}}) {
	    $_->{name} eq $name and $medium = $_;
	}
    }
    $medium and $urpm->{fatal}(5, N("medium \"%s\" already exists", $medium->{name}));

    $url =~ s,/*$,,; #- clear URLs for trailing /es.

    #- creating the medium info.
    $medium = { name => $name, url => $url, update => $options{update}, modified => 1, ignore => $options{ignore} };
    if ($options{virtual}) {
	$url =~ m!^(?:file:)?/! or $urpm->{fatal}(1, N("virtual medium needs to be local"));
	$medium->{virtual} = 1;
    } else {
	$medium->{hdlist} = "hdlist.$name.cz";
	$medium->{list} = "list.$name";
	#- check if the medium is using a local or a removable medium.
	$url =~ m!^(?:(removable[^:]*|file):/)?(/.*)! and $urpm->probe_removable_device($medium);
    }

    #- local media have priority, other are added at the end.
    if ($url =~ m!^(?:file:)?/!) {
	$medium->{priority} = 0.5;
    } else {
	$medium->{priority} = 1 + @{$urpm->{media}};
    }

    #- check whether a password is visible, if not, set clear_url.
    my $has_password = $url =~ m|([^:]*://[^/:\@]*:)[^/:\@]*(\@.*)|;
    $medium->{clear_url} = $url unless $has_password;

    $with_hdlist and $medium->{with_hdlist} = $with_hdlist;

    #- create an entry in media list.
    push @{$urpm->{media}}, $medium;

    $urpm->{log}(N("added medium %s", $name));

    #- we need to reload the config, since some string substitutions may have occured
    unless ($options{no_reload_config}) {
	$urpm->write_config;
	delete $urpm->{media};
	$urpm->read_config(nocheck_access => 1);
	#- Remember that the database has been modified and base files need to
	#- be updated. This will be done automatically by transferring the
	#- "modified" flag from medium to global.
	$_->{name} eq $name and $_->{modified} = 1 foreach @{$urpm->{media}};
	$urpm->{modified} = 1;
    }
    if ($has_password) {
	foreach (grep { $_->{name} eq $name } @{$urpm->{media}}) {
	    $_->{url} = $url;
	}
    }

    $options{nolock} or $urpm->unlock_urpmi_db;
    $name;
}

#- add distribution media, according to url given.
#- returns the list of names of added media.
#- options :
#- - limit_rate, compress : for downloading files
#- - initial_number : when adding several numbered media, start with this number
#- - probe_with : if eq 'synthesis', use synthesis instead of hdlists
#- - ask_media : callback to know whether each media should be added
#- other options are passed to add_medium()
sub add_distrib_media {
    my ($urpm, $name, $url, %options) = @_;

    #- make sure configuration has been read.
    # (Olivier Thauvin): Is this a workaround ?
    $urpm->{media} or $urpm->read_config;

    my $distribconf = MDV::Distribconf->new($url);

    if (my ($dir) = $url =~ m!^(?:removable[^:]*:/|file:/)?(/.*)!) {

	$urpm->try_mounting($url)
	    or $urpm->{error}(N("unable to access first installation medium")), return ();

    $distribconf->load() or $urpm->{error}(N("this url seems to not contains any distrib")), return ();

    } else {
	unlink "$urpm->{cachedir}/partial/media.cfg";
	# Workaround, settree not implement for now
	# $distribconf->settree('mandriva');
	$distribconf->{infodir} = "media/media_info";
	$distribconf->{mediadir} = "media";

	eval {
	    $urpm->{log}(N("retrieving media.cfg file..."));
	    $urpm->{sync}(
		{
		    dir => "$urpm->{cachedir}/partial",
		    quiet => 1,
		    limit_rate => $options{limit_rate},
		    compress => $options{compress},
		    retry => $urpm->{options}{retry},
		    proxy => get_proxy(),
		},
		reduce_pathname($distribconf->getfullpath(undef, 'infodir') .'/media.cfg'),
	    );
	    $urpm->{log}(N("...retrieving done"));
	};
	$@ and $urpm->{error}(N("...retrieving failed: %s", $@));
	if (-e "$urpm->{cachedir}/partial/media.cfg") {
	    $distribconf->parse_mediacfg("$urpm->{cachedir}/partial/media.cfg")
		or $urpm->{error}(N("unable to parse media.cfg")), return();
	} else {
	    $urpm->{error}(N("unable to access first installation medium (no hdlists file found)"));
	    return ();
	}
    }

    #- cosmetic update of name if it contains spaces.
    $name =~ /\s/ and $name .= ' ';

    my @newnames;
    #- at this point, we have found a media.cfg file, so parse it
    #- and create all necessary media according to it.
    my $medium = $options{initial_number} || 1;
    my @media_list_toadd;

    foreach my $media ($distribconf->listmedia()) {
        my $skip = 0;
	# if one of those values is set, by default, we skip adding the media
	foreach (qw(suppl askmedia noauto)) {
	    $distribconf->getvalue($media, $_) and do {
		$skip = 1;
		last;
	    };
	}
        if ($options{ask_media}) {
            if ($options{ask_media}->(
                $distribconf->getvalue($media, 'name'),
                !$skip,
            )) {
                $skip = 0;
            } else {
                $skip = 1;
            }
        }
        $skip and next;

        my $media_name = $distribconf->getvalue($media, 'name') || '';

        push @newnames, $urpm->add_medium(
            $name ? "$media_name ($name$medium)" : $media_name,
            reduce_pathname($distribconf->getfullpath($media, 'path')),
            offset_pathname(
                $url,
                $distribconf->getpath($media, 'path')
	    ) . '/' . $distribconf->getpath($media,
                ($options{probe_with} eq 'synthesis' ? 'synthesis' : 'hdlist')
            ),
            index_name => $name ? undef : 0,
            no_reload_config => 1, #- no need to reload config each time, since we don't update the media
            %options,
        );
        ++$medium;
    }
	return @newnames;
}

sub select_media {
    my $urpm = shift;
    my $options = {};
    if (ref $_[0]) { $options = shift }
    my %media; @media{@_} = ();

    foreach (@{$urpm->{media}}) {
	if (exists($media{$_->{name}})) {
	    $media{$_->{name}} = 1; #- keep in mind this one has been selected.
	    #- select medium by setting the modified flag, do not check ignore.
	    $_->{modified} = 1;
	}
    }

    #- check if some arguments don't correspond to the medium name.
    #- in such case, try to find the unique medium (or list candidate
    #- media found).
    foreach (keys %media) {
	unless ($media{$_}) {
	    my $q = quotemeta;
	    my (@found, @foundi);
	    my $regex  = $options->{strict_match} ? qr/^$q$/  : qr/$q/;
	    my $regexi = $options->{strict_match} ? qr/^$q$/i : qr/$q/i;
	    foreach my $medium (@{$urpm->{media}}) {
		$medium->{name} =~ $regex  and push @found, $medium;
		$medium->{name} =~ $regexi and push @foundi, $medium;
	    }
	    if (@found == 1) {
		$found[0]{modified} = 1;
	    } elsif (@foundi == 1) {
		$foundi[0]{modified} = 1;
	    } elsif (@found == 0 && @foundi == 0) {
		$urpm->{error}(N("trying to select nonexistent medium \"%s\"", $_));
	    } else { #- several elements in found and/or foundi lists.
		$urpm->{log}(N("selecting multiple media: %s", join(", ", map { qq("$_->{name}") } (@found ? @found : @foundi))));
		#- changed behaviour to select all occurences by default.
		foreach (@found ? @found : @foundi) {
		    $_->{modified} = 1;
		}
	    }
	}
    }
}

sub remove_selected_media {
    my ($urpm) = @_;
    my @result;

    foreach (@{$urpm->{media}}) {
	if ($_->{modified}) {
	    $urpm->{log}(N("removing medium \"%s\"", $_->{name}));

	    #- mark to re-write configuration.
	    $urpm->{modified} = 1;

	    #- remove files associated with this medium.
	    foreach ($_->{hdlist}, $_->{list}, "synthesis.$_->{hdlist}", "descriptions.$_->{name}", "names.$_->{name}",
		     "$_->{name}.cache") {
		$_ and unlink "$urpm->{statedir}/$_";
	    }

	    #- remove proxy settings for this media
	    urpm::download::remove_proxy_media($_->{name});
	} else {
	    push @result, $_; #- not removed so keep it
	}
    }

    #- restore newer media list.
    $urpm->{media} = \@result;
}

#- return list of synthesis or hdlist reference to probe.
sub _probe_with_try_list {
    my ($suffix, $probe_with) = @_;
    my @probe = (
	"media_info/synthesis.hdlist.cz",
	"../media_info/synthesis.hdlist_$suffix.cz",
	"synthesis.hdlist.cz",
    );
    my @probe_hdlist = (
	"media_info/hdlist.cz",
	"../media_info/hdlist_$suffix.cz",
	"hdlist.cz",
    );
    if ($probe_with =~ /synthesis/) {
	push @probe, @probe_hdlist;
    } else {
	unshift @probe, @probe_hdlist;
    }
    @probe;
}

#- read a reconfiguration file for urpmi, and reconfigure media accordingly
#- $rfile is the reconfiguration file (local), $name is the media name
sub reconfig_urpmi {
    my ($urpm, $rfile, $name) = @_;
    my @replacements;
    my @reconfigurable = qw(url with_hdlist clear_url);
    my $reconfigured = 0;
    my $fh = $urpm->open_safe("<", $rfile) or return undef;
    $urpm->{log}(N("reconfiguring urpmi for media \"%s\"", $name));
    #- the first line of reconfig.urpmi must be magic, to be sure it's not an error file
    my $magic = <$fh>;
    $magic =~ /^# this is an urpmi reconfiguration file/ or return undef;
    local $_;
    while (<$fh>) {
	chomp;
	s/^\s*//; s/#.*$//; s/\s*$//;
	$_ or next;
	my ($p, $r, $f) = split /\s+/, $_, 3;
	$f ||= 1;
	push @replacements, [ quotemeta $p, $r, $f ];
    }
  MEDIA:
    foreach my $medium (grep { $_->{name} eq $name } @{$urpm->{media}}) {
        my %orig = map { $_ => $medium->{$_} } @reconfigurable;
      URLS:
	foreach my $k (@reconfigurable) {
	    foreach my $r (@replacements) {
		if ($medium->{$k} =~ s/$r->[0]/$r->[1]/) {
		    $reconfigured = 1;
		    #- Flags stolen from mod_rewrite: L(ast), N(ext)
		    last if $r->[2] =~ /L/;
		    redo URLS if $r->[2] =~ /N/;
		}
	    }
	    #- check that the new url exists before committing changes (local mirrors)
	    if ($medium->{$k} =~ m!^(?:file:/*)?(/[^/].*[^/])/*\Z! && !-e $1) {
		$medium->{$k} = $orig{$k} foreach @reconfigurable;
		$reconfigured = 0;
		$urpm->{log}(N("...reconfiguration failed"));
		last MEDIA;
	    }
	}
    }
    close $fh;
    if ($reconfigured) {
	$urpm->{log}(N("reconfiguration done"));
	$urpm->write_config;
    }
    $reconfigured;
}

sub _guess_hdlist_suffix {
    my ($dir) = @_;
    my ($suffix) = $dir =~ m!\bmedia/(\w+)/*\Z!;
    $suffix;
}

sub _guess_pubkey_name {
    my ($medium) = @_;
    return $medium->{with_hdlist} =~ /hdlist(.*?)(?:\.src)?\.cz2?$/ ? "pubkey$1" : 'pubkey';
}

#- Update the urpmi database w.r.t. the current configuration.
#- Takes care of modifications, and tries some tricks to bypass
#- the recomputation of base files.
#- Recognized options :
#-   all         : all medias are being rebuilt
#-   callback    : UI callback
#-   compress    : use compressed download (for rsync)
#-   forcekey    : force retrieval of pubkey
#-   force       : try to force rebuilding base files (1) or hdlist from rpm files (2)
#-   limit_rate  : download limit rate
#-   noclean     : keep old files in the header cache directory
#-   nolock      : don't lock the urpmi database
#-   nomd5sum    : don't verify MD5SUM of retrieved files
#-   nopubkey    : don't use rpm pubkeys
#-   norebuild   : don't try to rebuild hdlists from rpm headers
#-   probe_with  : probe synthesis or hdlist (or none)
#-   quiet       : download hdlists quietly
#-   ratio       : use this compression ratio (with gzip, default is 4)
sub update_media {
    my ($urpm, %options) = @_;
    my $clean_cache = !$options{noclean};
    my $second_pass;

    $urpm->{media} or return; # verify that configuration has been read

    my $nopubkey = $options{nopubkey} || $urpm->{options}{nopubkey};
    #- get gpg-pubkey signature.
    if (!$nopubkey) {
	$urpm->exlock_rpm_db;
	$urpm->{keys} or $urpm->parse_pubkeys(root => $urpm->{root});
    }
    #- lock database if allowed.
    $options{nolock} or $urpm->exlock_urpmi_db;

    #- examine each medium to see if one of them needs to be updated.
    #- if this is the case and if not forced, try to use a pre-calculated
    #- hdlist file, else build it from rpm files.
    $urpm->clean;

    my %media_redone;
  MEDIA:
    foreach my $medium (@{$urpm->{media}}) {
	$medium->{ignore} and next MEDIA;

	$options{forcekey} and delete $medium->{'key-ids'};

	#- we should create the associated synthesis file if it does not already exist...
	-e "$urpm->{statedir}/synthesis.$medium->{hdlist}" && -s _ > 32
	    or $medium->{modified_synthesis} = 1;

	#- if we're rebuilding all media, mark them as modified (except removable ones)
	$medium->{modified} ||= $options{all} && $medium->{url} !~ m!^removable://!;
	#- don't ever update static media
	$medium->{static} and $medium->{modified} = 0;

	unless ($medium->{modified}) {
	    #- the medium is not modified, but to compute dependencies,
	    #- we still need to read it and all synthesis will be written if
	    #- an unresolved provides is found.
	    #- to speed up the process, we only read the synthesis at the beginning.
	    delete @$medium{qw(start end)};
	    if ($medium->{virtual}) {
		my ($path) = $medium->{url} =~ m!^(?:file:)?/*(/[^/].*[^/])/*\Z!;
		if ($path) {
		    my $with_hdlist_file = "$path/$medium->{with_hdlist}";
		    if ($medium->{synthesis}) {
			$urpm->{log}(N("examining synthesis file [%s]", $with_hdlist_file));
			($medium->{start}, $medium->{end}) = $urpm->parse_synthesis($with_hdlist_file);
		    } else {
			$urpm->{log}(N("examining hdlist file [%s]", $with_hdlist_file));
			($medium->{start}, $medium->{end}) = $urpm->parse_hdlist($with_hdlist_file, packing => 1);
		    }
		} else {
		    $urpm->{error}(N("virtual medium \"%s\" is not local, medium ignored", $medium->{name}));
		    $_->{ignore} = 1;
		}
	    } else {
		$urpm->{log}(N("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$medium->{hdlist}"));
		($medium->{start}, $medium->{end}) = $urpm->parse_synthesis("$urpm->{statedir}/synthesis.$medium->{hdlist}");
		unless (defined $medium->{start} && defined $medium->{end}) {
		    $urpm->{log}(N("examining hdlist file [%s]", "$urpm->{statedir}/$medium->{hdlist}"));
		    ($medium->{start}, $medium->{end}) = $urpm->parse_hdlist("$urpm->{statedir}/$medium->{hdlist}", packing => 1);
		}
	    }
	    unless ($medium->{ignore}) {
		unless (defined $medium->{start} && defined $medium->{end}) {
		    #- this is almost a fatal error, ignore it by default?
		    $urpm->{error}(N("problem reading hdlist or synthesis file of medium \"%s\"", $medium->{name}));
		    $medium->{ignore} = 1;
		}
	    }
	    next;
	}

	#- list of rpm files for this medium, only available for local medium where
	#- the source hdlist is not used (use force).
	my ($prefix, $dir, $error, $retrieved_md5sum, @files);

	#- always delete a remaining list file or pubkey file in cache.
	foreach (qw(list pubkey)) {
	    unlink "$urpm->{cachedir}/partial/$_";
	}

	#- check if the medium is using a local or a removable medium.
	if (($prefix, $dir) = $medium->{url} =~ m!^(?:(removable[^:]*|file):/)?(/.*)!) {
	    $prefix ||= 'file';
	    #- check for a reconfig.urpmi file (if not already reconfigured)
	    if (!$media_redone{$medium->{name}} && !$medium->{noreconfigure}) {
		my $reconfig_urpmi = reduce_pathname("$dir/reconfig.urpmi");
		if (-s $reconfig_urpmi && $urpm->reconfig_urpmi($reconfig_urpmi, $medium->{name})) {
		    $media_redone{$medium->{name}} = 1;
		    redo MEDIA;
		}
	    }

	    #- try to figure a possible hdlist_path (or parent directory of searched directory).
	    #- this is used to probe for a possible hdlist file.
	    my $with_hdlist_dir = reduce_pathname($dir . ($medium->{with_hdlist} ? "/$medium->{with_hdlist}" : "/.."));

	    #- the directory given does not exist and may be accessible
	    #- by mounting some other directory. Try to figure it out and mount
	    #- everything that might be necessary.
	    -d $dir or $urpm->try_mounting(
		$options{force} < 2 && ($options{probe_with} || $medium->{with_hdlist})
		    ? $with_hdlist_dir : $dir,
		#- in case of an iso image, pass its name
		is_iso($medium->{removable}),
	    ) or $urpm->{error}(N("unable to access medium \"%s\",
this could happen if you mounted manually the directory when creating the medium.", $medium->{name})), next;

	    #- try to probe for possible with_hdlist parameter, unless
	    #- it is already defined (and valid).
	    if ($options{probe_with} && (!$medium->{with_hdlist} || ! -e "$dir/$medium->{with_hdlist}")) {
		foreach (_probe_with_try_list(_guess_hdlist_suffix($dir), $options{probe_with})) {
		    if (-e "$dir/$_" && -s _ > 32) {
			$medium->{with_hdlist} = $_;
			last;
		    }
		}
		#- redo...
		$with_hdlist_dir = reduce_pathname($dir . ($medium->{with_hdlist} ? "/$medium->{with_hdlist}" : "/.."));
	    }

	    if ($medium->{virtual}) {
		#- syncing a virtual medium is very simple, just try to read the file in order to
		#- determine its type, once a with_hdlist has been found (but is mandatory).
		if ($medium->{with_hdlist} && -e $with_hdlist_dir) {
		    delete @$medium{qw(start end)};
		    if ($medium->{synthesis}) {
			$urpm->{log}(N("examining synthesis file [%s]", $with_hdlist_dir));
			($medium->{start}, $medium->{end}) = $urpm->parse_synthesis($with_hdlist_dir);
			delete $medium->{modified};
			$medium->{synthesis} = 1;
			$urpm->{modified} = 1;
			unless (defined $medium->{start} && defined $medium->{end}) {
			    $urpm->{log}(N("examining hdlist file [%s]", $with_hdlist_dir));
			    ($medium->{start}, $medium->{end}) = $urpm->parse_hdlist($with_hdlist_dir, packing => 1);
			    delete @$medium{qw(modified synthesis)};
			    $urpm->{modified} = 1;
			}
		    } else {
			$urpm->{log}(N("examining hdlist file [%s]", $with_hdlist_dir));
			($medium->{start}, $medium->{end}) = $urpm->parse_hdlist($with_hdlist_dir, packing => 1);
			delete @$medium{qw(modified synthesis)};
			$urpm->{modified} = 1;
			unless (defined $medium->{start} && defined $medium->{end}) {
			    $urpm->{log}(N("examining synthesis file [%s]", $with_hdlist_dir));
			    ($medium->{start}, $medium->{end}) = $urpm->parse_synthesis($with_hdlist_dir);
			    delete $medium->{modified};
			    $medium->{synthesis} = 1;
			    $urpm->{modified} = 1;
			}
		    }
		    unless (defined $medium->{start} && defined $medium->{end}) {
			$urpm->{error}(N("problem reading hdlist or synthesis file of medium \"%s\"", $medium->{name}));
			$medium->{ignore} = 1;
		    }
		} else {
		    $urpm->{error}(N("virtual medium \"%s\" should have valid source hdlist or synthesis, medium ignored",
				     $medium->{name}));
		    $medium->{ignore} = 1;
		}
	    }
	    #- try to get the description if it has been found.
	    unlink "$urpm->{statedir}/descriptions.$medium->{name}";
	    my $description_file = "$dir/media_info/descriptions"; #- new default location
	    -e $description_file or $description_file = "$dir/../descriptions";
	    if (-e $description_file) {
		$urpm->{log}(N("copying description file of \"%s\"...", $medium->{name}));
		urpm::util::copy($description_file, "$urpm->{statedir}/descriptions.$medium->{name}")
		    ? $urpm->{log}(N("...copying done"))
		    : do { $urpm->{error}(N("...copying failed")); $medium->{ignore} = 1 };
		chown 0, 0, "$urpm->{statedir}/descriptions.$medium->{name}";
	    }

	    #- examine if a distant MD5SUM file is available.
	    #- this will only be done if $with_hdlist is not empty in order to use
	    #- an existing hdlist or synthesis file, and to check if download was good.
	    #- if no MD5SUM is available, do it as before...
	    #- we can assume at this point a basename is existing, but it needs
	    #- to be checked for being valid, nothing can be deduced if no MD5SUM
	    #- file is present.
	    my $basename = urpm::download::basename($with_hdlist_dir);

	    unless ($medium->{virtual}) {
		if ($medium->{with_hdlist}) {
		    if (!$options{nomd5sum} && -s reduce_pathname("$with_hdlist_dir/../MD5SUM") > 32) {
			recompute_local_md5sum($urpm, $medium, $options{force});
			if ($medium->{md5sum}) {
			    $retrieved_md5sum = parse_md5sum($urpm, reduce_pathname("$with_hdlist_dir/../MD5SUM"), $basename);
			    #- If an existing hdlist or synthesis file has the same md5sum, we assume
			    #- the files are the same.
			    #- If the local md5sum is the same as the distant md5sum, this means
			    #- that there is no need to download the hdlist or synthesis file again.
			    if (defined $retrieved_md5sum && $medium->{md5sum} eq $retrieved_md5sum) {
				unlink "$urpm->{cachedir}/partial/$basename";
				#- the medium is now considered not modified.
				$medium->{modified} = 0;
				#- XXX we could link the new hdlist to the old one.
				#- (However links need to be managed. see bug #12391.)
				#- as previously done, just read synthesis file here, this is enough.
				$urpm->{log}(N("examining synthesis file [%s]",
				    "$urpm->{statedir}/synthesis.$medium->{hdlist}"));
				($medium->{start}, $medium->{end}) =
				    $urpm->parse_synthesis("$urpm->{statedir}/synthesis.$medium->{hdlist}");
				unless (defined $medium->{start} && defined $medium->{end}) {
				    $urpm->{log}(N("examining hdlist file [%s]", "$urpm->{statedir}/$medium->{hdlist}"));
				    ($medium->{start}, $medium->{end}) =
					$urpm->parse_hdlist("$urpm->{statedir}/$medium->{hdlist}", packing => 1);
				    unless (defined $medium->{start} && defined $medium->{end}) {
					$urpm->{error}(N("problem reading hdlist or synthesis file of medium \"%s\"",
					    $medium->{name}));
					$medium->{ignore} = 1;
				    }
				}
			    }
			    $medium->{modified} or next MEDIA;
			}
		    }

		    #- if the source hdlist is present and we are not forcing using rpm files
		    if ($options{force} < 2 && -e $with_hdlist_dir) {
			unlink "$urpm->{cachedir}/partial/$medium->{hdlist}";
			$urpm->{log}(N("copying source hdlist (or synthesis) of \"%s\"...", $medium->{name}));
			$options{callback} and $options{callback}('copy', $medium->{name});
			if (urpm::util::copy($with_hdlist_dir, "$urpm->{cachedir}/partial/$medium->{hdlist}")) {
			    $options{callback} and $options{callback}('done', $medium->{name});
			    $urpm->{log}(N("...copying done"));
			    chown 0, 0, "$urpm->{cachedir}/partial/$medium->{hdlist}";
			} else {
			    $options{callback} and $options{callback}('failed', $medium->{name});
			    #- force error, reported afterwards
			    unlink "$urpm->{cachedir}/partial/$medium->{hdlist}";
			}
		    }

		    -e "$urpm->{cachedir}/partial/$medium->{hdlist}" && -s _ > 32 or
		      $error = 1, $urpm->{error}(N("copy of [%s] failed (file is suspiciously small)",
                                             "$urpm->{cachedir}/partial/$medium->{hdlist}"));

		    #- keep checking md5sum of file just copied ! (especially on nfs or removable device).
		    if (!$error && $retrieved_md5sum) {
			$urpm->{log}(N("computing md5sum of copied source hdlist (or synthesis)"));
			md5sum("$urpm->{cachedir}/partial/$medium->{hdlist}") eq $retrieved_md5sum or
			  $error = 1, $urpm->{error}(N("copy of [%s] failed (md5sum mismatch)", $with_hdlist_dir));
		    }

		    #- check if the files are equal... and no force copy...
		    if (!$error && !$options{force} && -e "$urpm->{statedir}/synthesis.$medium->{hdlist}") {
			my @sstat = stat "$urpm->{cachedir}/partial/$medium->{hdlist}";
			my @lstat = stat "$urpm->{statedir}/$medium->{hdlist}";
			if ($sstat[7] == $lstat[7] && $sstat[9] == $lstat[9]) {
			    #- the two files are considered equal here, the medium is so not modified.
			    $medium->{modified} = 0;
			    unlink "$urpm->{cachedir}/partial/$medium->{hdlist}";
			    #- as previously done, just read synthesis file here, this is enough, but only
			    #- if synthesis exists, else it needs to be recomputed.
			    $urpm->{log}(N("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$medium->{hdlist}"));
			    ($medium->{start}, $medium->{end}) =
				$urpm->parse_synthesis("$urpm->{statedir}/synthesis.$medium->{hdlist}");
			    unless (defined $medium->{start} && defined $medium->{end}) {
				$urpm->{log}(N("examining hdlist file [%s]", "$urpm->{statedir}/$medium->{hdlist}"));
				($medium->{start}, $medium->{end}) =
				    $urpm->parse_hdlist("$urpm->{statedir}/$medium->{hdlist}", packing => 1);
				unless (defined $medium->{start} && defined $medium->{end}) {
				    $urpm->{error}(N("problem reading synthesis file of medium \"%s\"", $medium->{name}));
				    $medium->{ignore} = 1;
				}
			    }
			    next MEDIA;
			}
		    }
		} else {
		    if ($urpm->{options}{norebuild}) {
			$urpm->{error}(N("unable to access hdlist file of \"%s\", medium ignored", $medium->{name}));
			$medium->{ignore} = 1;
		    } else {
			$options{force} < 2 and $options{force} = 2;
		    }
		}

		#- if copying hdlist has failed, try to build it directly.
		if ($error) {
		    if ($urpm->{options}{norebuild}) {
			$urpm->{error}(N("unable to access hdlist file of \"%s\", medium ignored", $_->{name}));
			$medium->{ignore} = 1;
		    } else {
			$options{force} < 2 and $options{force} = 2;
			#- clear error state now.
			$error = undef;
		    }
		}

		if ($options{force} < 2) {
		    #- examine if a local list file is available (always probed according to with_hdlist)
		    #- and check hdlist wasn't named very strangely...
		    if ($medium->{hdlist} ne 'list') {
			my $local_list = $medium->{with_hdlist} =~ /hd(list.*)\.cz2?$/ ? $1 : 'list';
			my $path_list = reduce_pathname("$with_hdlist_dir/../$local_list");
			-e $path_list or $path_list = "$dir/list";
			if (-e $path_list) {
			    urpm::util::copy($path_list, "$urpm->{cachedir}/partial/list")
				or do { $urpm->{error}(N("...copying failed")); $error = 1 };
			    chown 0, 0, "$urpm->{cachedir}/partial/list";
			}
		    }
		} else {
		    {
			my %f;
			File::Find::find(
			    {
				wanted => sub { -f $_ && /\.rpm$/ and $f{"$File::Find::dir/$_"} = 1 },
				follow_skip => 2,
				follow_fast => 1,
			    },
			    $dir,
			);
			push @files, keys %f;
		    }

		    #- check files contains something good!
		    if (@files > 0) {
			#- we need to rebuild from rpm files the hdlist.
			eval {
			    $urpm->{log}(N("reading rpm files from [%s]", $dir));
			    my @unresolved_before = grep {
				! defined $urpm->{provides}{$_};
			    } keys %{$urpm->{provides} || {}};
			    $medium->{start} = @{$urpm->{depslist}};
			    $medium->{headers} = [ $urpm->parse_rpms_build_headers(
				dir   => "$urpm->{cachedir}/headers",
				rpms  => \@files,
				clean => $clean_cache,
			    ) ];
			    $medium->{end} = $#{$urpm->{depslist}};
			    if ($medium->{start} > $medium->{end}) {
				#- an error occured (provided there are files in input.)
				delete $medium->{start};
				delete $medium->{end};
				$urpm->{fatal}(9, N("no rpms read"));
			    } else {
				#- make sure the headers will not be removed for another media.
				$clean_cache = 0;
				my @unresolved = grep {
				    ! defined $urpm->{provides}{$_};
				} keys %{$urpm->{provides} || {}};
				@unresolved_before == @unresolved or $second_pass = 1;
			    }
			};
			$@ and $error = 1, $urpm->{error}(N("unable to read rpm files from [%s]: %s", $dir, $@));
			$error and delete $medium->{headers}; #- do not propagate these.
			$error or delete $medium->{synthesis}; #- when building hdlist by ourself, drop synthesis property.
		    } else {
			$error = 1;
			$urpm->{error}(N("no rpm files found from [%s]", $dir));
			$medium->{ignore} = 1;
		    }
		}
	    }

	    #- examine if a local pubkey file is available.
	    if (!$nopubkey && $medium->{hdlist} ne 'pubkey' && !$medium->{'key-ids'}) {
		my $path_pubkey = reduce_pathname("$with_hdlist_dir/../" . _guess_pubkey_name($medium));
		-e $path_pubkey or $path_pubkey = "$dir/pubkey";
		if ($path_pubkey) {
		    urpm::util::copy($path_pubkey, "$urpm->{cachedir}/partial/pubkey")
			or do { $urpm->{error}(N("...copying failed")) };
		}
		chown 0, 0, "$urpm->{cachedir}/partial/pubkey";
	    }
	} else {
	    #- check for a reconfig.urpmi file (if not already reconfigured)
	    if (!$media_redone{$medium->{name}} && !$medium->{noreconfigure}) {
		my $reconfig_urpmi_url = "$medium->{url}/reconfig.urpmi";
		unlink(my $reconfig_urpmi = "$urpm->{cachedir}/partial/reconfig.urpmi");
		eval {
		    $urpm->{sync}(
			{
			    dir => "$urpm->{cachedir}/partial",
			    quiet => 1,
			    limit_rate => $options{limit_rate},
			    compress => $options{compress},
			    proxy => get_proxy($medium->{name}),
			    media => $medium->{name},
			    retry => $urpm->{options}{retry},
			},
			reduce_pathname("$medium->{url}/reconfig.urpmi"),
		    );
		};
		if (-s $reconfig_urpmi && $urpm->reconfig_urpmi($reconfig_urpmi, $medium->{name})) {
		    $media_redone{$medium->{name}} = 1, redo MEDIA unless $media_redone{$medium->{name}};
		}
		unlink $reconfig_urpmi;
	    }

	    my $basename;

	    #- try to get the description if it has been found.
	    unlink "$urpm->{cachedir}/partial/descriptions";
	    if (-e "$urpm->{statedir}/descriptions.$medium->{name}") {
		urpm::util::move("$urpm->{statedir}/descriptions.$medium->{name}", "$urpm->{cachedir}/partial/descriptions");
	    }
	    my $syncopts = {
		dir => "$urpm->{cachedir}/partial",
		quiet => 1,
		limit_rate => $options{limit_rate},
		compress => $options{compress},
		proxy => get_proxy($medium->{name}),
		retry => $urpm->{options}{retry},
		media => $medium->{name},
	    };
	    eval { $urpm->{sync}($syncopts, reduce_pathname("$medium->{url}/media_info/descriptions")) };
	    #- It is possible that the original fetch of the descriptions
	    #- failed, but the file still remains in partial/ because it was
	    #- moved from $urpm->{statedir} earlier. So we need to check if
	    #- the previous download failed.
	    if ($@ || (! -e "$urpm->{cachedir}/partial/descriptions")) {
		eval {
		    #- try older location
		    $urpm->{sync}($syncopts, reduce_pathname("$medium->{url}/../descriptions"));
		};
	    }
	    if (-e "$urpm->{cachedir}/partial/descriptions") {
		urpm::util::move("$urpm->{cachedir}/partial/descriptions", "$urpm->{statedir}/descriptions.$medium->{name}");
	    }

	    #- examine if a distant MD5SUM file is available.
	    #- this will only be done if $with_hdlist is not empty in order to use
	    #- an existing hdlist or synthesis file, and to check if download was good.
	    #- if no MD5SUM is available, do it as before...
	    if ($medium->{with_hdlist}) {
		#- we can assume at this point a basename is existing, but it needs
		#- to be checked for being valid, nothing can be deduced if no MD5SUM
		#- file is present.
		$basename = urpm::download::basename($medium->{with_hdlist});

		unlink "$urpm->{cachedir}/partial/MD5SUM";
		eval {
		    if (!$options{nomd5sum}) {
			$urpm->{sync}(
			    {
				dir => "$urpm->{cachedir}/partial",
				quiet => 1,
				limit_rate => $options{limit_rate},
				compress => $options{compress},
				proxy => get_proxy($medium->{name}),
				media => $medium->{name},
				retry => $urpm->{options}{retry},
			    },
			    reduce_pathname("$medium->{url}/$medium->{with_hdlist}/../MD5SUM"),
			);
		    }
		};
		if (!$@ && -e "$urpm->{cachedir}/partial/MD5SUM" && -s _ > 32) {
		    recompute_local_md5sum($urpm, $medium, $options{force} >= 2);
		    if ($medium->{md5sum}) {
			$retrieved_md5sum = parse_md5sum($urpm, "$urpm->{cachedir}/partial/MD5SUM", $basename);
			#- if an existing hdlist or synthesis file has the same md5sum, we assume the
			#- files are the same.
			#- if local md5sum is the same as distant md5sum, this means there is no need to
			#- download hdlist or synthesis file again.
			if (defined $retrieved_md5sum && $medium->{md5sum} eq $retrieved_md5sum) {
			    unlink "$urpm->{cachedir}/partial/$basename";
			    #- the medium is now considered not modified.
			    $medium->{modified} = 0;
			    #- XXX we could link the new hdlist to the old one.
			    #- (However links need to be managed. see bug #12391.)
			    #- as previously done, just read synthesis file here, this is enough.
			    $urpm->{log}(N("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$medium->{hdlist}"));
			    ($medium->{start}, $medium->{end}) =
				$urpm->parse_synthesis("$urpm->{statedir}/synthesis.$medium->{hdlist}");
			    unless (defined $medium->{start} && defined $medium->{end}) {
				$urpm->{log}(N("examining hdlist file [%s]", "$urpm->{statedir}/$medium->{hdlist}"));
				($medium->{start}, $medium->{end}) =
				    $urpm->parse_hdlist("$urpm->{statedir}/$medium->{hdlist}", packing => 1);
				unless (defined $medium->{start} && defined $medium->{end}) {
				    $urpm->{error}(N("problem reading synthesis file of medium \"%s\"", $medium->{name}));
				    $medium->{ignore} = 1;
				}
			    }
			}
			$medium->{modified} or next MEDIA;
		    }
		} else {
		    #- at this point, we don't if a basename exists and is valid, let probe it later.
		    $basename = undef;
		}
	    }

	    #- try to probe for possible with_hdlist parameter, unless
	    #- it is already defined (and valid).
	    $urpm->{log}(N("retrieving source hdlist (or synthesis) of \"%s\"...", $medium->{name}));
	    $options{callback} and $options{callback}('retrieve', $medium->{name});
	    if ($options{probe_with}) {
		my @probe_list = (
		    $medium->{with_hdlist}
		    ? $medium->{with_hdlist}
		    : _probe_with_try_list(_guess_hdlist_suffix($dir), $options{probe_with})
		);
		foreach my $with_hdlist (@probe_list) {
		    $basename = urpm::download::basename($with_hdlist) or next;
		    $options{force} and unlink "$urpm->{cachedir}/partial/$basename";
		    eval {
			$urpm->{sync}(
			    {
				dir => "$urpm->{cachedir}/partial",
				quiet => $options{quiet},
				limit_rate => $options{limit_rate},
				compress => $options{compress},
				callback => $options{callback},
				proxy => get_proxy($medium->{name}),
				media => $medium->{name},
				retry => $urpm->{options}{retry},
			    },
			    reduce_pathname("$medium->{url}/$with_hdlist"),
			);
		    };
		    if (!$@ && -e "$urpm->{cachedir}/partial/$basename" && -s _ > 32) {
			$medium->{with_hdlist} = $with_hdlist;
			$urpm->{log}(N("found probed hdlist (or synthesis) as %s", $medium->{with_hdlist}));
			last; #- found a suitable with_hdlist in the list above.
		    }
		}
	    } else {
		$basename = urpm::download::basename($medium->{with_hdlist});

		#- try to sync (copy if needed) local copy after restored the previous one.
		$options{force} and unlink "$urpm->{cachedir}/partial/$basename";
		unless ($options{force}) {
		    if ($medium->{synthesis}) {
			if (-e "$urpm->{statedir}/synthesis.$medium->{hdlist}") {
			    urpm::util::copy(
				"$urpm->{statedir}/synthesis.$medium->{hdlist}",
				"$urpm->{cachedir}/partial/$basename",
			    ) or $urpm->{error}(N("...copying failed")), $error = 1;
			}
		    } else {
			if (-e "$urpm->{statedir}/$medium->{hdlist}") {
			    urpm::util::copy(
				"$urpm->{statedir}/$medium->{hdlist}",
				"$urpm->{cachedir}/partial/$basename",
			    ) or $urpm->{error}(N("...copying failed")), $error = 1;
			}
		    }
		    chown 0, 0, "$urpm->{cachedir}/partial/$basename";
		}
		eval {
		    $urpm->{sync}(
			{
			    dir => "$urpm->{cachedir}/partial",
			    quiet => $options{quiet},
			    limit_rate => $options{limit_rate},
			    compress => $options{compress},
			    callback => $options{callback},
			    proxy => get_proxy($medium->{name}),
			    media => $medium->{name},
			    retry => $urpm->{options}{retry},
			},
			reduce_pathname("$medium->{url}/$medium->{with_hdlist}"),
		    );
		};
		if ($@) {
		    $urpm->{error}(N("...retrieving failed: %s", $@));
		    unlink "$urpm->{cachedir}/partial/$basename";
		}
	    }

	    #- check downloaded file has right signature.
	    if (-e "$urpm->{cachedir}/partial/$basename" && -s _ > 32 && $retrieved_md5sum) {
		$urpm->{log}(N("computing md5sum of retrieved source hdlist (or synthesis)"));
		unless (md5sum("$urpm->{cachedir}/partial/$basename") eq $retrieved_md5sum) {
		    $urpm->{error}(N("...retrieving failed: md5sum mismatch"));
		    unlink "$urpm->{cachedir}/partial/$basename";
		}
	    }

	    if (-e "$urpm->{cachedir}/partial/$basename" && -s _ > 32) {
		$options{callback} and $options{callback}('done', $medium->{name});
		$urpm->{log}(N("...retrieving done"));

		unless ($options{force}) {
		    my @sstat = stat "$urpm->{cachedir}/partial/$basename";
		    my @lstat = stat "$urpm->{statedir}/$medium->{hdlist}";
		    if ($sstat[7] == $lstat[7] && $sstat[9] == $lstat[9]) {
			#- the two files are considered equal here, the medium is so not modified.
			$medium->{modified} = 0;
			unlink "$urpm->{cachedir}/partial/$basename";
			#- as previously done, just read synthesis file here, this is enough.
			$urpm->{log}(N("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$medium->{hdlist}"));
			($medium->{start}, $medium->{end}) =
			    $urpm->parse_synthesis("$urpm->{statedir}/synthesis.$medium->{hdlist}");
			unless (defined $medium->{start} && defined $medium->{end}) {
			    $urpm->{log}(N("examining hdlist file [%s]", "$urpm->{statedir}/$medium->{hdlist}"));
			    ($medium->{start}, $medium->{end}) =
				$urpm->parse_hdlist("$urpm->{statedir}/$medium->{hdlist}", packing => 1);
			    unless (defined $medium->{start} && defined $medium->{end}) {
				$urpm->{error}(N("problem reading hdlist or synthesis file of medium \"%s\"", $medium->{name}));
				$medium->{ignore} = 1;
			    }
			}
			next MEDIA;
		    }
		}

		#- the files are different, update local copy.
		rename("$urpm->{cachedir}/partial/$basename", "$urpm->{cachedir}/partial/$medium->{hdlist}");

		#- retrieval of hdlist or synthesis has been successful,
		#- check whether a list file is available.
		#- and check hdlist wasn't named very strangely...
		if ($medium->{hdlist} ne 'list') {
		    my $local_list = $medium->{with_hdlist} =~ /hd(list.*)\.cz2?$/ ? $1 : 'list';
		    foreach (reduce_pathname("$medium->{url}/$medium->{with_hdlist}/../$local_list"),
			     reduce_pathname("$medium->{url}/list"),
			    ) {
			eval {
			    $urpm->{sync}(
				{
				    dir => "$urpm->{cachedir}/partial",
				    quiet => 1,
				    limit_rate => $options{limit_rate},
				    compress => $options{compress},
				    proxy => get_proxy($medium->{name}),
				    media => $medium->{name},
				    retry => $urpm->{options}{retry},
				},
				$_
			    );
			    $local_list ne 'list' && -e "$urpm->{cachedir}/partial/$local_list" && -s _
				and rename(
				    "$urpm->{cachedir}/partial/$local_list",
				    "$urpm->{cachedir}/partial/list");
			};
			$@ and unlink "$urpm->{cachedir}/partial/list";
			-s "$urpm->{cachedir}/partial/list" and last;
		    }
		}

		#- retrieve pubkey file.
		if (!$nopubkey && $medium->{hdlist} ne 'pubkey' && !$medium->{'key-ids'}) {
		    my $local_pubkey = _guess_pubkey_name($medium);
		    foreach (reduce_pathname("$medium->{url}/$medium->{with_hdlist}/../$local_pubkey"),
			     reduce_pathname("$medium->{url}/pubkey"),
			    ) {
			eval {
			    $urpm->{sync}(
				{
				    dir => "$urpm->{cachedir}/partial",
				    quiet => 1,
				    limit_rate => $options{limit_rate},
				    compress => $options{compress},
				    proxy => get_proxy($medium->{name}),
				    media => $medium->{name},
				    retry => $urpm->{options}{retry},
				},
				$_,
			    );
			    $local_pubkey ne 'pubkey' && -e "$urpm->{cachedir}/partial/$local_pubkey" && -s _
				and rename(
				    "$urpm->{cachedir}/partial/$local_pubkey",
				    "$urpm->{cachedir}/partial/pubkey");
			};
			$@ and unlink "$urpm->{cachedir}/partial/pubkey";
			-s "$urpm->{cachedir}/partial/pubkey" and last;
		    }
		}
	    } else {
		$error = 1;
		$options{callback} and $options{callback}('failed', $medium->{name});
		$urpm->{error}(N("retrieval of source hdlist (or synthesis) failed"));
	    }
	}

	#- build list file according to hdlist.
	unless ($medium->{headers} || -e "$urpm->{cachedir}/partial/$medium->{hdlist}" && -s _ > 32) {
	    $error = 1;
	    $urpm->{error}(N("no hdlist file found for medium \"%s\"", $medium->{name}));
	}

	unless ($error || $medium->{virtual}) {
	    #- sort list file contents according to id.
	    my %list;
	    if ($medium->{headers}) {
		#- rpm files have already been read (first pass), there is just a need to
		#- build list hash.
		foreach (@files) {
		    m|/([^/]*\.rpm)$| or next;
		    $list{$1} and $urpm->{error}(N("file [%s] already used in the same medium \"%s\"", $1, $medium->{name})), next;
		    $list{$1} = "$prefix:/$_\n";
		}
	    } else {
		#- read first pass hdlist or synthesis, try to open as synthesis, if file
		#- is larger than 1MB, this is probably an hdlist else a synthesis.
		#- anyway, if one tries fails, try another mode.
		$options{callback} and $options{callback}('parse', $medium->{name});
		my @unresolved_before = grep { ! defined $urpm->{provides}{$_} } keys %{$urpm->{provides} || {}};
		if (!$medium->{synthesis}
		    || -e "$urpm->{cachedir}/partial/$medium->{hdlist}" && -s _ > 262144)
		{
		    $urpm->{log}(N("examining hdlist file [%s]", "$urpm->{cachedir}/partial/$medium->{hdlist}"));
		    ($medium->{start}, $medium->{end}) =
			     $urpm->parse_hdlist("$urpm->{cachedir}/partial/$medium->{hdlist}", 1);
		    if (defined $medium->{start} && defined $medium->{end}) {
			delete $medium->{synthesis};
		    } else {
			$urpm->{log}(N("examining synthesis file [%s]", "$urpm->{cachedir}/partial/$medium->{hdlist}"));
			($medium->{start}, $medium->{end}) =
				 $urpm->parse_synthesis("$urpm->{cachedir}/partial/$medium->{hdlist}");
			defined $medium->{start} && defined $medium->{end} and $medium->{synthesis} = 1;
		    }
		} else {
		    $urpm->{log}(N("examining synthesis file [%s]", "$urpm->{cachedir}/partial/$medium->{hdlist}"));
		    ($medium->{start}, $medium->{end}) =
			     $urpm->parse_synthesis("$urpm->{cachedir}/partial/$medium->{hdlist}");
		    if (defined $medium->{start} && defined $medium->{end}) {
			$medium->{synthesis} = 1;
		    } else {
			$urpm->{log}(N("examining hdlist file [%s]", "$urpm->{cachedir}/partial/$medium->{hdlist}"));
			($medium->{start}, $medium->{end}) =
				 $urpm->parse_hdlist("$urpm->{cachedir}/partial/$medium->{hdlist}", 1);
			defined $medium->{start} && defined $medium->{end} and delete $medium->{synthesis};
		    }
		}
		if (defined $medium->{start} && defined $medium->{end}) {
		    $options{callback} && $options{callback}('done', $medium->{name});
		} else {
		    $error = 1;
		    $urpm->{error}(N("unable to parse hdlist file of \"%s\"", $medium->{name}));
		    $options{callback} && $options{callback}('failed', $medium->{name});
		    #- we will have to read back the current synthesis file unmodified.
		}

		unless ($error) {
		    my @unresolved_after = grep { ! defined $urpm->{provides}{$_} } keys %{$urpm->{provides} || {}};
		    @unresolved_before == @unresolved_after or $second_pass = 1;

		    if ($medium->{hdlist} ne 'list' && -s "$urpm->{cachedir}/partial/list") {
			if (open my $fh, "$urpm->{cachedir}/partial/list") {
			    local $_;
			    while (<$fh>) {
				m|/([^/]*\.rpm)$| or next;
				$list{$1} and $urpm->{error}(N("file [%s] already used in the same medium \"%s\"", $1, $medium->{name})), next;
				$list{$1} = "$medium->{url}/$_";
			    }
			    close $fh;
			}
		    } else {
			#- if url is clear and no relative list file has been downloaded,
			#- there is no need for a list file.
			if ($medium->{url} ne $medium->{clear_url}) {
			    foreach ($medium->{start} .. $medium->{end}) {
				my $filename = $urpm->{depslist}[$_]->filename;
				$list{$filename} = "$medium->{url}/$filename\n";
			    }
			}
		    }
		}
	    }

	    unless ($error) {
		if (keys %list) {
		    #- write list file.
		    #- make sure group and other do not have any access to this file, used to hide passwords.
		    if ($medium->{list}) {
			my $mask = umask 077;
			open my $listfh, ">$urpm->{cachedir}/partial/$medium->{list}"
			    or $error = 1, $urpm->{error}(N("unable to write list file of \"%s\"", $medium->{name}));
			umask $mask;
			print $listfh values %list;
			close $listfh;
		    }

		    #- check if at least something has been written into list file.
		    if ($medium->{list} && -s "$urpm->{cachedir}/partial/$medium->{list}") {
			$urpm->{log}(N("writing list file for medium \"%s\"", $medium->{name}));
		    } else {
			$error = 1, $urpm->{error}(N("nothing written in list file for \"%s\"", $medium->{name}));
		    }
		} else {
		    #- the flag is no longer necessary.
		    if ($medium->{list}) {
			unlink "$urpm->{statedir}/$medium->{list}";
			delete $medium->{list};
		    }
		}
	    }
	}

	unless ($error) {
	    #- now... on pubkey
	    if (-s "$urpm->{cachedir}/partial/pubkey") {
		$urpm->{log}(N("examining pubkey file of \"%s\"...", $medium->{name}));
		my %key_ids;
		$urpm->import_needed_pubkeys([ $urpm->parse_armored_file("$urpm->{cachedir}/partial/pubkey") ],
					     root => $urpm->{root}, callback => sub {
						 my (undef, undef, $k, $id, $imported) = @_;
						 if ($id) {
						     $key_ids{$id} = undef;
						     $imported and $urpm->{log}(N("...imported key %s from pubkey file of \"%s\"",
										  $id, $medium->{name}));
						 } else {
						     $urpm->{error}(N("unable to import pubkey file of \"%s\"", $medium->{name}));
						 }
					     });
		keys(%key_ids) and $medium->{'key-ids'} = join ',', keys %key_ids;
	    }
	}

	unless ($medium->{virtual}) {
	    if ($error) {
		#- an error has occured for updating the medium, we have to remove temporary files.
		unlink "$urpm->{cachedir}/partial/$medium->{hdlist}";
		$medium->{list} and unlink "$urpm->{cachedir}/partial/$medium->{list}";
		#- read default synthesis (we have to make sure nothing get out of depslist).
		$urpm->{log}(N("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$medium->{hdlist}"));
		($medium->{start}, $medium->{end}) = $urpm->parse_synthesis("$urpm->{statedir}/synthesis.$medium->{hdlist}");
		unless (defined $medium->{start} && defined $medium->{end}) {
		    $urpm->{error}(N("problem reading synthesis file of medium \"%s\"", $medium->{name}));
		    $medium->{ignore} = 1;
		}
	    } else {
		#- make sure to rebuild base files and clear medium modified state.
		$medium->{modified} = 0;
		$urpm->{modified} = 1;

		#- but use newly created file.
		unlink "$urpm->{statedir}/$medium->{hdlist}";
		$medium->{synthesis} and unlink "$urpm->{statedir}/synthesis.$medium->{hdlist}";
		$medium->{list} and unlink "$urpm->{statedir}/$medium->{list}";
		unless ($medium->{headers}) {
		    unlink "$urpm->{statedir}/synthesis.$medium->{hdlist}";
		    unlink "$urpm->{statedir}/$medium->{hdlist}";
		    urpm::util::move("$urpm->{cachedir}/partial/$medium->{hdlist}",
			$medium->{synthesis}
			    ? "$urpm->{statedir}/synthesis.$medium->{hdlist}"
			    : "$urpm->{statedir}/$medium->{hdlist}"
		    );
		}
		if ($medium->{list}) {
		    urpm::util::move("$urpm->{cachedir}/partial/$medium->{list}", "$urpm->{statedir}/$medium->{list}");
		}
		$medium->{md5sum} = $retrieved_md5sum; #- anyway, keep it, the previous one is no longer useful.

		#- and create synthesis file associated.
		$medium->{modified_synthesis} = !$medium->{synthesis};
	    }
	}
    }

    #- some unresolved provides may force to rebuild all synthesis,
    #- a second pass will be necessary.
    if ($second_pass) {
	$urpm->{log}(N("performing second pass to compute dependencies\n"));
	$urpm->unresolved_provides_clean;
    }

    #- second pass consists in reading again synthesis or hdlists.
    foreach my $medium (@{$urpm->{media}}) {
	#- take care of modified medium only, or all if all have to be recomputed.
	$medium->{ignore} and next;

	$options{callback} and $options{callback}('parse', $medium->{name});
	#- a modified medium is an invalid medium, we have to read back the previous hdlist
	#- or synthesis which has not been modified by first pass above.
	if ($medium->{headers} && !$medium->{modified}) {
	    if ($second_pass) {
		$urpm->{log}(N("reading headers from medium \"%s\"", $medium->{name}));
		($medium->{start}, $medium->{end}) = $urpm->parse_headers(dir     => "$urpm->{cachedir}/headers",
									  headers => $medium->{headers},
									 );
	    }
	    $urpm->{log}(N("building hdlist [%s]", "$urpm->{statedir}/$medium->{hdlist}"));
	    #- finish building operation of hdlist.
	    $urpm->build_hdlist(start  => $medium->{start},
				end    => $medium->{end},
				dir    => "$urpm->{cachedir}/headers",
				hdlist => "$urpm->{statedir}/$medium->{hdlist}",
			       );
	    #- synthesis needs to be created, since the medium has been built from rpm files.
	    eval { $urpm->build_synthesis(
	        start     => $medium->{start},
	        end       => $medium->{end},
	        synthesis => "$urpm->{statedir}/synthesis.$medium->{hdlist}",
	    ) };
	    if ($@) {
		#- XXX this happens when building a synthesis for a local media from RPMs... why ?
		$urpm->{error}(N("Unable to build synthesis file for medium \"%s\". Your hdlist file may be corrupted.", $medium->{name}));
		$urpm->{error}($@);
		unlink "$urpm->{statedir}/synthesis.$medium->{hdlist}";
	    } else {
		$urpm->{log}(N("built hdlist synthesis file for medium \"%s\"", $medium->{name}));
	    }
	    #- keep in mind we have a modified database, sure at this point.
	    $urpm->{modified} = 1;
	} elsif ($medium->{synthesis}) {
	    if ($second_pass) {
		if ($medium->{virtual}) {
		    my ($path) = $medium->{url} =~ m!^(?:file:/*)?(/[^/].*[^/])/*\Z!;
		    my $with_hdlist_file = "$path/$medium->{with_hdlist}";
		    if ($path) {
			$urpm->{log}(N("examining synthesis file [%s]", $with_hdlist_file));
			($medium->{start}, $medium->{end}) = $urpm->parse_synthesis($with_hdlist_file);
		    }
		} else {
		    $urpm->{log}(N("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$medium->{hdlist}"));
		    ($medium->{start}, $medium->{end}) = $urpm->parse_synthesis("$urpm->{statedir}/synthesis.$medium->{hdlist}");
		}
	    }
	} else {
	    if ($second_pass) {
		$urpm->{log}(N("examining hdlist file [%s]", "$urpm->{statedir}/$medium->{hdlist}"));
		($medium->{start}, $medium->{end}) = $urpm->parse_hdlist("$urpm->{statedir}/$medium->{hdlist}", 1);
	    }
	    #- check if the synthesis file can be built.
	    if (($second_pass || $medium->{modified_synthesis}) && !$medium->{modified}) {
		unless ($medium->{virtual}) {
		    eval { $urpm->build_synthesis(
			start     => $medium->{start},
			end       => $medium->{end},
			synthesis => "$urpm->{statedir}/synthesis.$medium->{hdlist}",
		    ) };
		    if ($@) {
			$urpm->{error}(N("Unable to build synthesis file for medium \"%s\". Your hdlist file may be corrupted.", $medium->{name}));
			$urpm->{error}($@);
			unlink "$urpm->{statedir}/synthesis.$medium->{hdlist}";
		    } else {
			$urpm->{log}(N("built hdlist synthesis file for medium \"%s\"", $medium->{name}));
		    }
		}
		#- keep in mind we have modified database, sure at this point.
		$urpm->{modified} = 1;
	    }
	}
	$options{callback} && $options{callback}('done', $medium->{name});
    }

    #- clean headers cache directory to remove everything that is no longer
    #- useful according to the depslist.
    if ($urpm->{modified}) {
	if ($options{noclean}) {
	    local $_;
	    my %headers;
	    my $dh = $urpm->opendir_safe("$urpm->{cachedir}/headers");
	    if ($dh) {
		while (defined($_ = readdir $dh)) {
		    m|^([^/]*-[^-]*-[^-]*\.[^\.]*)(?::\S*)?$| and $headers{$1} = $_;
		}
		closedir $dh;
	    }
	    $urpm->{log}(N("found %d headers in cache", scalar(keys %headers)));
	    foreach (@{$urpm->{depslist}}) {
		delete $headers{$_->fullname};
	    }
	    $urpm->{log}(N("removing %d obsolete headers in cache", scalar(keys %headers)));
	    foreach (values %headers) {
		unlink "$urpm->{cachedir}/headers/$_";
	    }
	}

	#- write config files in any case
	$urpm->write_config;
	dump_proxy_config();
    }

    #- make sure names files are regenerated.
    foreach (@{$urpm->{media}}) {
	unlink "$urpm->{statedir}/names.$_->{name}";
	if (defined $_->{start} && defined $_->{end}) {
	    my $fh = $urpm->open_safe(">", "$urpm->{statedir}/names.$_->{name}");
	    if ($fh) {
		foreach ($_->{start} .. $_->{end}) {
		    if (defined $urpm->{depslist}[$_]) {
			print $fh $urpm->{depslist}[$_]->name . "\n";
		    } else {
			$urpm->{error}(N("Error generating names file: dependency %d not found", $_));
		    }
		}
		close $fh;
	    } else {
		$urpm->{error}(N("Error generating names file: Can't write to file (%s)", $!));
	    }
	}
    }

    $options{nolock} or $urpm->unlock_urpmi_db;
    $nopubkey or $urpm->unlock_rpm_db;
}

#- clean params and depslist computation zone.
sub clean {
    my ($urpm) = @_;

    $urpm->{depslist} = [];
    $urpm->{provides} = {};

    foreach (@{$urpm->{media} || []}) {
	delete $_->{start};
	delete $_->{end};
    }
}

sub try_mounting {
    my ($urpm, $dir, $removable) = @_;
    my %infos;

    my $is_iso = is_iso($removable);
    my @mntpoints = $is_iso
	#- note: for isos, we don't parse the fstab because it might not be declared in it.
	#- so we try to remove suffixes from the dir name until the dir exists
	? ($dir = urpm::sys::trim_until_d($dir))
	: urpm::sys::find_mntpoints($dir = reduce_pathname($dir), \%infos);
    foreach (grep {
	    ! $infos{$_}{mounted} && $infos{$_}{fs} ne 'supermount';
	} @mntpoints)
    {
	$urpm->{log}(N("mounting %s", $_));
	if ($is_iso) {
	    #- to mount an iso image, grab the first loop device
	    my $loopdev = urpm::sys::first_free_loopdev();
	    sys_log("mount iso $_ on $removable");
	    $loopdev and system("mount '$removable' '$_' -t iso9660 -o loop=$loopdev");
	} else {
	    sys_log("mount $_");
	    system("mount '$_' 2>/dev/null");
	}
	$removable && $infos{$_}{fs} ne 'supermount' and $urpm->{removable_mounted}{$_} = undef;
    }
    -e $dir;
}

sub try_umounting {
    my ($urpm, $dir) = @_;
    my %infos;

    $dir = reduce_pathname($dir);
    foreach (reverse grep {
	    $infos{$_}{mounted} && $infos{$_}{fs} ne 'supermount';
	} urpm::sys::find_mntpoints($dir, \%infos))
    {
	$urpm->{log}(N("unmounting %s", $_));
	sys_log("umount $_");
	system("umount '$_' 2>/dev/null");
	delete $urpm->{removable_mounted}{$_};
    }
    ! -e $dir;
}

sub try_umounting_removables {
    my ($urpm) = @_;
    foreach (keys %{$urpm->{removable_mounted}}) {
	$urpm->try_umounting($_);
    }
    delete $urpm->{removable_mounted};
}

#- register local packages for being installed, keep track of source.
sub register_rpms {
    my ($urpm, @files) = @_;
    my ($start, $id, $error, %requested);

    #- examine each rpm and build the depslist for them using current
    #- depslist and provides environment.
    $start = @{$urpm->{depslist}};
    foreach (@files) {
	/\.(?:rpm|spec)$/ or $error = 1, $urpm->{error}(N("invalid rpm file name [%s]", $_)), next;

	#- if that's an URL, download.
	if (my ($basename) = m{^[^:]*:/.*/([^/]*\.(?:rpm|spec))\z}) {
	    unlink "$urpm->{cachedir}/partial/$basename";
	    eval {
		$urpm->{log}(N("retrieving rpm file [%s] ...", $_));
		$urpm->{sync}(
		    {
			dir => "$urpm->{cachedir}/partial",
			quiet => 1,
			proxy => get_proxy(),
		    },
		    $_,
		);
		$urpm->{log}(N("...retrieving done"));
		$_ = "$urpm->{cachedir}/partial/$basename";
	    };
	    if ($@) {
		$urpm->{error}(N("...retrieving failed: %s", $@));
		unlink "$urpm->{cachedir}/partial/$basename";
		next;
	    }
	} else {
	    -r $_ or $error = 1, $urpm->{error}(N("unable to access rpm file [%s]", $_)), next;
	}

	if (/\.spec$/) {
	    my $pkg = URPM::spec2srcheader($_)
		or $error = 1, $urpm->{error}(N("unable to parse spec file %s [%s]", $_, $!)), next;
	    $id = @{$urpm->{depslist}};
	    $urpm->{depslist}[$id] = $pkg;
	    #- It happens that URPM sets an internal id to the depslist id.
	    #- We need to set it by hand here.
	    $pkg->set_id($id);
	    $urpm->{source}{$id} = $_;
	} else {
	    ($id) = $urpm->parse_rpm($_);
	    my $pkg = defined $id && $urpm->{depslist}[$id];
	    $pkg or $error = 1, $urpm->{error}(N("unable to register rpm file")), next;
	    $pkg->arch eq 'src' || $pkg->is_arch_compat()
		or $error = 1, $urpm->{error}(N("Incompatible architecture for rpm [%s]", $_)), next;
	    $urpm->{source}{$id} = $_;
	}
    }
    $error and $urpm->{fatal}(2, N("error registering local packages"));
    defined $id && $start <= $id and @requested{($start .. $id)} = (1) x ($id-$start+1);

    #- distribute local packages to distant nodes directly in cache of each machine.
    @files && $urpm->{parallel_handler} and $urpm->{parallel_handler}->parallel_register_rpms(@_);

    %requested;
}

sub _findindeps {
    my ($urpm, $found, $v, %options) = @_;
    my @list = grep { defined $_ } map {
	my $pkg = $urpm->{depslist}[$_];
	$pkg
	&& ($options{src} ? $pkg->arch eq 'src' : $pkg->arch ne 'src')
	? $pkg->id : undef;
    } keys %{$urpm->{provides}{$_} || {}};
    @list > 0 and push @{$found->{$v}}, join '|', @list;
}

#- search packages registered by their names by storing their ids into the $packages hash.
sub search_packages {
    my ($urpm, $packages, $names, %options) = @_;
    my (%exact, %exact_a, %exact_ra, %found, %foundi);
    foreach my $v (@$names) {
	my $qv = quotemeta $v;
	$qv = '(?i)' . $qv if $options{caseinsensitive};

	unless ($options{fuzzy}) {
	    #- try to search through provides.
	    if (my @l = map {
		    $_
		    && ($options{src} ? $_->arch eq 'src' : $_->is_arch_compat)
		    && ($options{use_provides} || $_->name eq $v)
		    && defined($_->id)
		    && (!defined $urpm->{searchmedia} || (
			    $urpm->{searchmedia}{start} <= $_->id
		    	    && $urpm->{searchmedia}{end} >= $_->id))
		    ? $_ : @{[]};
		} map {
		    $urpm->{depslist}[$_];
		} keys %{$urpm->{provides}{$v} || {}})
	    {
		#- we assume that if there is at least one package providing
		#- the resource exactly, this should be the best one; but we
		#- first check if one of the packages has the same name as searched.
		if ((my @l2) = grep { $_->name eq $v } @l) {
		    $exact{$v} = join '|', map { $_->id } @l2;
		} else {
		    $exact{$v} = join '|', map { $_->id } @l;
		}
		next;
	    }
	}

	if ($options{use_provides} && $options{fuzzy}) {
	    foreach (keys %{$urpm->{provides}}) {
		#- search through provides to find if a provide matches this one;
		#- but manage choices correctly (as a provides may be virtual or
		#- defined several times).
		if (/$qv/ || (!$options{caseinsensitive} && /$qv/i)) {
		    $urpm->_findindeps(\%found, $v, %options);
		}
	    }
	}

	foreach my $id (defined $urpm->{searchmedia} ?
	    ($urpm->{searchmedia}{start} .. $urpm->{searchmedia}{end}) :
	    (0 .. $#{$urpm->{depslist}})
	) {
	    my $pkg = $urpm->{depslist}[$id];
	    ($options{src} ? $pkg->arch eq 'src' : $pkg->is_arch_compat) or next;
	    my $pack_name = $pkg->name;
	    my $pack_ra = $pack_name . '-' . $pkg->version;
	    my $pack_a = "$pack_ra-" . $pkg->release;
	    my $pack = "$pack_a." . $pkg->arch;
	    unless ($options{fuzzy}) {
		if ($pack eq $v) {
		    $exact{$v} = $id;
		    next;
		} elsif ($pack_a eq $v) {
		    push @{$exact_a{$v}}, $id;
		    next;
		} elsif ($pack_ra eq $v || $options{src} && $pack_name eq $v) {
		    push @{$exact_ra{$v}}, $id;
		    next;
		}
	    }
	    $pack =~ /$qv/ and push @{$found{$v}}, $id;
	    $pack =~ /$qv/i and push @{$foundi{$v}}, $id unless $options{caseinsensitive};
	}
    }

    my $result = 1;
    foreach (@$names) {
	if (defined $exact{$_}) {
	    $packages->{$exact{$_}} = 1;
	    foreach (split /\|/, $exact{$_}) {
		my $pkg = $urpm->{depslist}[$_] or next;
		$pkg->set_flag_skip(0); #- reset skip flag as manually selected.
	    }
	} else {
	    #- at this level, we need to search the best package given for a given name,
	    #- always prefer already found package.
	    my %l;
	    foreach (@{$exact_a{$_} || $exact_ra{$_} || $found{$_} || $foundi{$_} || []}) {
		my $pkg = $urpm->{depslist}[$_];
		push @{$l{$pkg->name}}, $pkg;
	    }
	    if (values(%l) == 0 || values(%l) > 1 && !$options{all}) {
		$urpm->{error}(N("no package named %s", $_));
		values(%l) != 0 and $urpm->{error}(
		    N("The following packages contain %s: %s",
			$_, "\n" . join("\n", sort { $a cmp $b } keys %l))
		);
		$result = 0;
	    } else {
		foreach (values %l) {
		    my $best;
		    foreach (@$_) {
			if ($best && $best != $_) {
			    $_->compare_pkg($best) > 0 and $best = $_;
			} else {
			    $best = $_;
			}
		    }
		    $packages->{$best->id} = 1;
		    $best->set_flag_skip(0); #- reset skip flag as manually selected.
		}
	    }
	}
    }

    #- return true if no error has been encountered, else false.
    $result;
}

#- Resolves dependencies between requested packages (and auto selection if any).
#- handles parallel option if any.
#- The return value is true if program should be restarted (in order to take
#- care of important packages being upgraded (priority upgrades)
#- %options :
#-	rpmdb
#-	auto_select
#-	callback_choices
#-	install_src
#-	keep
#-	nodeps
#-	priority_upgrade
sub resolve_dependencies {
    #- $state->{selected} will contain the selection of packages to be
    #- installed or upgraded
    my ($urpm, $state, $requested, %options) = @_;
    my $need_restart;

    if ($options{install_src}) {
	#- only src will be installed, so only update $state->{selected} according
	#- to src status of files.
	foreach (keys %$requested) {
	    my $pkg = $urpm->{depslist}[$_] or next;
	    $pkg->arch eq 'src' or next;
	    $state->{selected}{$_} = undef;
	}
    }
    if ($urpm->{parallel_handler}) {
	#- build the global synthesis file first.
	my $file = "$urpm->{cachedir}/partial/parallel.cz";
	unlink $file;
	foreach (@{$urpm->{media}}) {
	    defined $_->{start} && defined $_->{end} or next;
	    system "cat '$urpm->{statedir}/synthesis.$_->{hdlist}' >> '$file'";
	}
	#- let each node determine what is requested, according to handler given.
	$urpm->{parallel_handler}->parallel_resolve_dependencies($file, @_);
    } else {
	my $db;

	if ($options{rpmdb}) {
	    $db = new URPM;
	    $db->parse_synthesis($options{rpmdb});
	} else {
	    $db = URPM::DB::open($urpm->{root});
	    $db or $urpm->{fatal}(9, N("unable to open rpmdb"));
	}

	my $sig_handler = sub { undef $db; exit 3 };
	local $SIG{INT} = $sig_handler;
	local $SIG{QUIT} = $sig_handler;

	#- auto select package for upgrading the distribution.
	if ($options{auto_select}) {
	    $urpm->request_packages_to_upgrade($db, $state, $requested, requested => undef,
    		start => $urpm->{searchmedia}{start}, end => $urpm->{searchmedia}{end});
	}

	#- resolve dependencies which will be examined for packages that need to
	#- have urpmi restarted when they're updated.
	$urpm->resolve_requested($db, $state, $requested, %options);

	if ($options{priority_upgrade} && !$options{rpmdb}) {
	    my (%priority_upgrade, %priority_requested);
	    @priority_upgrade{split /,/, $options{priority_upgrade}} = ();

	    #- check if a priority upgrade should be tried
	    foreach (keys %{$state->{selected}}) {
		my $pkg = $urpm->{depslist}[$_] or next;
		exists $priority_upgrade{$pkg->name} or next;
		$priority_requested{$pkg->id} = undef;
	    }

	    if (%priority_requested) {
		my %priority_state;

		$urpm->resolve_requested($db, \%priority_state, \%priority_requested, %options);
		if (grep { ! exists $priority_state{selected}{$_} } keys %priority_requested) {
		    #- some packages which were selected previously have not been selected, strange!
		    $need_restart = 0;
		} elsif (grep { ! exists $priority_state{selected}{$_} } keys %{$state->{selected}}) {
		    #- there are other packages to install after this priority transaction.
		    %$state = %priority_state;
		    $need_restart = 1;
		}
	    }
	}
    }
    $need_restart;
}

sub create_transaction {
    my ($urpm, $state, %options) = @_;

    if ($urpm->{parallel_handler} || !$options{split_length} ||
	keys %{$state->{selected}} < $options{split_level}) {
	#- build simplest transaction (no split).
	$urpm->build_transaction_set(undef, $state, split_length => 0);
    } else {
	my $db;

	if ($options{rpmdb}) {
	    $db = new URPM;
	    $db->parse_synthesis($options{rpmdb});
	} else {
	    $db = URPM::DB::open($urpm->{root});
	    $db or $urpm->{fatal}(9, N("unable to open rpmdb"));
	}

	my $sig_handler = sub { undef $db; exit 3 };
	local $SIG{INT} = $sig_handler;
	local $SIG{QUIT} = $sig_handler;

	#- build transaction set...
	$urpm->build_transaction_set($db, $state, split_length => $options{split_length});
    }
}

#- get the list of packages that should not be upgraded or installed,
#- typically from the inst.list or skip.list files.
sub get_packages_list {
    my ($file, $extra) = @_;
    my $val = [];
    open my $f, $file or return [];
    foreach (<$f>, split /,/, $extra || '') {
	chomp; s/#.*$//; s/^\s*//; s/\s*$//;
	next if $_ eq '';
	push @$val, $_;
    }
    close $f;
    $val;
}

#- select sources for selected packages,
#- according to keys of the packages hash.
#- returns a list of lists containing the source description for each rpm,
#- matching the exact number of registered media; ignored media being
#- associated to a null list.
sub get_source_packages {
    my ($urpm, $packages, %options) = @_;
    my ($id, $error, @list_error, %protected_files, %local_sources, @list, %fullname2id, %file2fullnames, %examined);
    local $_;

    #- build association hash to retrieve id and examine all list files.
    foreach (keys %$packages) {
	foreach (split /\|/, $_) {
	    if ($urpm->{source}{$_}) {
		$protected_files{$local_sources{$_} = $urpm->{source}{$_}} = undef;
	    } else {
		$fullname2id{$urpm->{depslist}[$_]->fullname} = $_ . '';
	    }
	}
    }

    #- examine each medium to search for packages.
    #- now get rpm file name in hdlist to match list file.
    foreach my $pkg (@{$urpm->{depslist} || []}) {
	$file2fullnames{$pkg->filename}{$pkg->fullname} = undef;
    }

    #- examine the local repository, which is trusted (no gpg or pgp signature check but md5 is now done).
    my $dh = $urpm->opendir_safe("$urpm->{cachedir}/rpms");
    if ($dh) {
	while (defined(my $filename = readdir $dh)) {
	    my $filepath = "$urpm->{cachedir}/rpms/$filename";
	    next if -d $filepath;
	    if (!$options{clean_all} && -s _) {
		if (keys(%{$file2fullnames{$filename} || {}}) > 1) {
		    $urpm->{error}(N("there are multiple packages with the same rpm filename \"%s\"", $filename));
		    next;
		} elsif (keys(%{$file2fullnames{$filename} || {}}) == 1) {
		    my ($fullname) = keys(%{$file2fullnames{$filename} || {}});
		    if (defined($id = delete $fullname2id{$fullname})) {
			$local_sources{$id} = $filepath;
		    } else {
			$options{clean_other} && ! exists $protected_files{$filepath} and unlink $filepath;
		    }
		} else {
		    $options{clean_other} && ! exists $protected_files{$filepath} and unlink $filepath;
		}
	    } else {
		unlink $filepath; #- this file should be removed or is already empty.
	    }
	}
	closedir $dh;
    }

    #- clean download directory, do it here even if this is not the best moment.
    if ($options{clean_all}) {
	require File::Path;
	File::Path::rmtree(["$urpm->{cachedir}/partial"]);
	mkdir "$urpm->{cachedir}/partial", 0755;
    }

    foreach my $medium (@{$urpm->{media} || []}) {
	my (%sources, %list_examined, $list_warning);

	if (defined $medium->{start} && defined $medium->{end} && !$medium->{ignore}) {
	    #- always prefer a list file if available.
	    my $listfile = $medium->{list} ? "$urpm->{statedir}/$medium->{list}" : '';
	    if (!$listfile && $medium->{virtual}) {
		my ($dir) = $medium->{url} =~ m!^(?:removable[^:]*:/|file:/)?(/.*)!;
		my $with_hdlist_dir = reduce_pathname($dir . ($medium->{with_hdlist} ? "/$medium->{with_hdlist}" : "/.."));
		my $local_list = $medium->{with_hdlist} =~ /hd(list.*)\.cz2?$/ ? $1 : 'list';
		$listfile = reduce_pathname("$with_hdlist_dir/../$local_list");
		-s $listfile or $listfile = "$dir/list";
	    }
	    if ($listfile && -r $listfile) {
		my $fh = $urpm->open_safe('<', $listfile);
		if ($fh) {
		    local $_;
		    while (<$fh>) {
			chomp;
			if (my ($filename) = m|/([^/]*\.rpm)$|) {
			    if (keys(%{$file2fullnames{$filename} || {}}) > 1) {
				$urpm->{error}(N("there are multiple packages with the same rpm filename \"%s\"", $filename));
				next;
			    } elsif (keys(%{$file2fullnames{$filename} || {}}) == 1) {
				my ($fullname) = keys(%{$file2fullnames{$filename} || {}});
				if (defined($id = $fullname2id{$fullname})) {
				    if (!/\.delta\.rpm$/ || $urpm->is_delta_installable($urpm->{depslist}[$id], $options{root})) {
					$sources{$id} = $medium->{virtual} ? "$medium->{url}/$_" : $_;
				    }
				}
				$list_examined{$fullname} = $examined{$fullname} = undef;
			    }
			} else {
			    chomp;
			    $error = 1;
			    $urpm->{error}(N("unable to correctly parse [%s] on value \"%s\"", $listfile, $_));
			    last;
			}
		    }
		    close $fh;
		}
	    } elsif ($listfile && -e $listfile) {
		# list file exists but isn't readable
		# report error only if no result found, list files are only readable by root
		push @list_error, N("unable to access list file of \"%s\", medium ignored", $medium->{name});
		$< and push @list_error, "    " . N("(retry as root?)");
		next;
	    }
	    if (defined $medium->{url}) {
		foreach ($medium->{start} .. $medium->{end}) {
		    my $pkg = $urpm->{depslist}[$_];
		    my $fi = $pkg->filename;
		    if (keys(%{$file2fullnames{$fi} || {}}) > 1) {
			$urpm->{error}(N("there are multiple packages with the same rpm filename \"%s\"", $fi));
			next;
		    } elsif (keys(%{$file2fullnames{$fi} || {}}) == 1) {
			my ($fullname) = keys(%{$file2fullnames{$fi} || {}});
			unless (exists($list_examined{$fullname})) {
			    ++$list_warning;
			    if (defined($id = $fullname2id{$fullname})) {
				if ($fi !~ /\.delta\.rpm$/ || $urpm->is_delta_installable($urpm->{depslist}[$id], $options{root})) {
				    $sources{$id} = "$medium->{url}/" . $fi;
				}
			    }
			    $examined{$fullname} = undef;
			}
		    }
		}
		$list_warning && $medium->{list} && -r "$urpm->{statedir}/$medium->{list}" && -f _
		    and $urpm->{error}(N("medium \"%s\" uses an invalid list file:
  mirror is probably not up-to-date, trying to use alternate method", $medium->{name}));
	    } elsif (!%list_examined) {
		$error = 1;
		$urpm->{error}(N("medium \"%s\" does not define any location for rpm files", $medium->{name}));
	    }
	}
	push @list, \%sources;
    }

    #- examine package list to see if a package has not been found.
    foreach (grep { ! exists($examined{$_}) } keys %fullname2id) {
	# print list errors only once if any
	@list_error and map { $urpm->{error}($_) } @list_error;
	@list_error = ();
	$error = 1;
	$urpm->{error}(N("package %s is not found.", $_));
    }

    $error ? @{[]} : (\%local_sources, \@list);
}

#- checks whether the delta RPM represented by $pkg is installable wrt the
#- RPM DB on $root. For this, it extracts the rpm version to which the
#- delta applies from the delta rpm filename itself. So naming conventions
#- do matter :)
sub is_delta_installable {
    my ($urpm, $pkg, $root) = @_;
    $pkg->flag_installed or return 0;
    my $f = $pkg->filename;
    my $n = $pkg->name;
    my ($v_match) = $f =~ /^\Q$n\E-(.*)_.+\.delta\.rpm$/;
    my $db = URPM::DB::open($root)
	or $urpm->{fatal}(9, N("unable to open rpmdb"));
    my $v_installed;
    $db->traverse(sub {
	my ($p) = @_;
	$p->name eq $n and $v_installed = $p->version . '-' . $p->release;
    });
    $v_match eq $v_installed;
}

#- Obsolescent method.
sub download_source_packages {
    my ($urpm, $local_sources, $list, %options) = @_;
    my %sources = %$local_sources;
    my %error_sources;

    $urpm->exlock_urpmi_db unless $options{nolock};
    $urpm->copy_packages_of_removable_media($list, \%sources, %options) or return;
    $urpm->download_packages_of_distant_media($list, \%sources, \%error_sources, %options);
    $urpm->unlock_urpmi_db unless $options{nolock};

    %sources, %error_sources;
}

#- lock policy concerning chroot :
#  - lock rpm db in chroot
#  - lock urpmi db in /

#- safety rpm db locking mechanism
sub exlock_rpm_db {
    my ($urpm) = @_;
    #- avoid putting a require on Fcntl ':flock' (which is perl and not perl-base).
    my ($LOCK_EX, $LOCK_NB) = (2, 4);
    #- lock urpmi database, but keep lock to wait for an urpmi.update to finish.
    open RPMLOCK_FILE, ">$urpm->{root}/$urpm->{statedir}/.RPMLOCK";
    flock RPMLOCK_FILE, $LOCK_EX|$LOCK_NB or $urpm->{fatal}(7, N("urpmi database locked"));
}

sub shlock_rpm_db {
    my ($urpm) = @_;
    #- avoid putting a require on Fcntl ':flock' (which is perl and not perl-base).
    my ($LOCK_SH, $LOCK_NB) = (1, 4);
    #- create the .LOCK file if needed (and if possible)
    unless (-e "$urpm->{root}/$urpm->{statedir}/.RPMLOCK") {
	open RPMLOCK_FILE, ">$urpm->{root}/$urpm->{statedir}/.RPMLOCK";
	close RPMLOCK_FILE;
    }
    #- lock urpmi database, if the LOCK file doesn't exists no share lock.
    open RPMLOCK_FILE, "$urpm->{root}/$urpm->{statedir}/.RPMLOCK" or return;
    flock RPMLOCK_FILE, $LOCK_SH|$LOCK_NB or $urpm->{fatal}(7, N("urpmi database locked"));
}

sub unlock_rpm_db {
    my ($urpm) = @_;
    #- avoid putting a require on Fcntl ':flock' (which is perl and not perl-base).
    my $LOCK_UN = 8;
    #- now everything is finished.
    #- release lock on database.
    flock RPMLOCK_FILE, $LOCK_UN;
    close RPMLOCK_FILE;
}

sub exlock_urpmi_db {
    my ($urpm) = @_;
    #- avoid putting a require on Fcntl ':flock' (which is perl and not perl-base).
    my ($LOCK_EX, $LOCK_NB) = (2, 4);
    #- lock urpmi database, but keep lock to wait for an urpmi.update to finish.
    open LOCK_FILE, ">$urpm->{statedir}/.LOCK";
    flock LOCK_FILE, $LOCK_EX|$LOCK_NB or $urpm->{fatal}(7, N("urpmi database locked"));
}

sub shlock_urpmi_db {
    my ($urpm) = @_;
    #- avoid putting a require on Fcntl ':flock' (which is perl and not perl-base).
    my ($LOCK_SH, $LOCK_NB) = (1, 4);
    #- create the .LOCK file if needed (and if possible)
    unless (-e "$urpm->{statedir}/.LOCK") {
	open LOCK_FILE, ">$urpm->{statedir}/.LOCK";
	close LOCK_FILE;
    }
    #- lock urpmi database, if the LOCK file doesn't exists no share lock.
    open LOCK_FILE, "$urpm->{statedir}/.LOCK" or return;
    flock LOCK_FILE, $LOCK_SH|$LOCK_NB or $urpm->{fatal}(7, N("urpmi database locked"));
}

sub unlock_urpmi_db {
    my ($urpm) = @_;
    #- avoid putting a require on Fcntl ':flock' (which is perl and not perl-base).
    my $LOCK_UN = 8;
    #- now everything is finished.
    #- release lock on database.
    flock LOCK_FILE, $LOCK_UN;
    close LOCK_FILE;
}

sub copy_packages_of_removable_media {
    my ($urpm, $list, $sources, %options) = @_;
    my %removables;

    #- make sure everything is correct on input...
    $urpm->{media} or return;
    @{$urpm->{media}} == @$list or return;

    #- examine if given medium is already inside a removable device.
    my $check_notfound = sub {
	my ($id, $dir, $removable) = @_;
	$dir and $urpm->try_mounting($dir, $removable);
	if (!$dir || -e $dir) {
	    foreach (values %{$list->[$id]}) {
		chomp;
		m!^(removable[^:]*:/|file:/)?(/.*/([^/]*)$)! or next;
		unless ($dir) {
		    $dir = $2;
		    $urpm->try_mounting($dir, $removable);
		}
		-r $2 or return 1;
	    }
	} else {
	    return 2;
	}
	return 0;
    };
    #- removable media have to be examined to keep mounted the one that has
    #- more packages than others.
    my $examine_removable_medium = sub {
	my ($id, $device) = @_;
	my $medium = $urpm->{media}[$id];
	if (my ($dir) = $medium->{url} =~ m!^(?:(?:removable[^:]*|file):/)?(/.*)!) {
	    #- the directory given does not exist and may be accessible
	    #- by mounting some other directory. Try to figure it out and mount
	    #- everything that might be necessary.
	    while ($check_notfound->($id, $dir, is_iso($medium->{removable}) || 'removable')) {
		is_iso($medium->{removable}) || $options{ask_for_medium}
		    or $urpm->{fatal}(4, N("medium \"%s\" is not selected", $medium->{name}));
		$urpm->try_umounting($dir);
		system("/usr/bin/eject '$device' 2>/dev/null");
		is_iso($medium->{removable})
		    || $options{ask_for_medium}(remove_internal_name($medium->{name}), $medium->{removable})
		    or $urpm->{fatal}(4, N("medium \"%s\" is not selected", $medium->{name}));
	    }
	    if (-e $dir) {
		while (my ($i, $url) = each %{$list->[$id]}) {
		    chomp $url;
		    my ($filepath, $filename) = $url =~ m!^(?:removable[^:]*:/|file:/)?(/.*/([^/]*))! or next;
		    if (-r $filepath) {
			#- we should assume a possibly buggy removable device...
			#- First, copy in partial cache, and if the package is still good,
			#- transfer it to the rpms cache.
			unlink "$urpm->{cachedir}/partial/$filename";
			if (urpm::util::copy($filepath, "$urpm->{cachedir}/partial") &&
			    URPM::verify_rpm("$urpm->{cachedir}/partial/$filename", nosignatures => 1))
			{
			    #- now we can consider the file to be fine.
			    unlink "$urpm->{cachedir}/rpms/$filename";
			    urpm::util::move("$urpm->{cachedir}/partial/$filename", "$urpm->{cachedir}/rpms/$filename");
			    -r "$urpm->{cachedir}/rpms/$filename" and $sources->{$i} = "$urpm->{cachedir}/rpms/$filename";
			}
		    }
		    unless ($sources->{$i}) {
			#- fallback to use other method for retrieving the file later.
			$urpm->{error}(N("unable to read rpm file [%s] from medium \"%s\"", $filepath, $medium->{name}));
		    }
		}
	    } else {
		$urpm->{error}(N("medium \"%s\" is not selected", $medium->{name}));
	    }
	} else {
	    #- we have a removable device that is not removable, well...
	    $urpm->{error}(N("inconsistent medium \"%s\" marked removable but not really", $medium->{name}));
	}
    };

    foreach (0..$#$list) {
	values %{$list->[$_]} or next;
	my $medium = $urpm->{media}[$_];
	#- examine non removable device but that may be mounted.
	if ($medium->{removable}) {
	    push @{$removables{$medium->{removable}} ||= []}, $_;
	} elsif (my ($dir) = $medium->{url} =~ m!^(?:removable[^:]*:/|file:/)?(/.*)!) {
	    -e $dir || $urpm->try_mounting($dir) or
	      $urpm->{error}(N("unable to access medium \"%s\"", $medium->{name})), next;
	}
    }
    foreach my $device (keys %removables) {
	next if $device =~ m![^a-zA-Z0-9_./-]!; #- bad path
	#- Here we have only removable devices.
	#- If more than one media uses this device, we have to sort
	#- needed packages to copy the needed rpm files.
	if (@{$removables{$device}} > 1) {
	    my @sorted_media = sort { values %{$list->[$a]} <=> values %{$list->[$b]} } @{$removables{$device}};

	    #- check if a removable device is already mounted (and files present).
	    if (my ($already_mounted_medium) = grep { !$check_notfound->($_) } @sorted_media) {
		@sorted_media = grep { $_ ne $already_mounted_medium } @sorted_media;
		unshift @sorted_media, $already_mounted_medium;
	    }

	    #- mount all except the biggest one.
	    foreach (@sorted_media[0 .. $#sorted_media-1]) {
		$examine_removable_medium->($_, $device);
	    }
	    #- now mount the last one...
	    $removables{$device} = [ $sorted_media[-1] ];
	}

	$examine_removable_medium->($removables{$device}[0], $device);
    }

    1;
}

# TODO verify that files are downloaded from the right corresponding media
sub download_packages_of_distant_media {
    my ($urpm, $list, $sources, $error_sources, %options) = @_;

    #- get back all ftp and http accessible rpm files into the local cache
    foreach my $n (0..$#$list) {
	my %distant_sources;

	#- ignore media that contain nothing for the current set of files
	values %{$list->[$n]} or next;

	#- examine all files to know what can be indexed on multiple media.
	while (my ($i, $url) = each %{$list->[$n]}) {
	    #- the given URL is trusted, so the file can safely be ignored.
	    defined $sources->{$i} and next;
	    if ($url =~ m!^(removable[^:]*:/|file:/)?(/.*\.rpm)\Z!) {
		if (-r $2) {
		    $sources->{$i} = $2;
		} else {
		    $error_sources->{$i} = $2;
		}
	    } elsif ($url =~ m!^([^:]*):/(.*/([^/]*\.rpm))\Z!) {
		$distant_sources{$i} = "$1:/$2"; #- will download now
	    } else {
		$urpm->{error}(N("malformed URL: [%s]", $url));
	    }
	}

	#- download files from the current medium.
	if (%distant_sources) {
	    eval {
		$urpm->{log}(N("retrieving rpm files from medium \"%s\"...", $urpm->{media}[$n]{name}));
		$urpm->{sync}(
		    {
			dir => "$urpm->{cachedir}/partial",
			quiet => $options{quiet},
			limit_rate => $options{limit_rate},
			resume => $options{resume},
			compress => $options{compress},
			callback => $options{callback},
			proxy => get_proxy($urpm->{media}[$n]{name}),
			media => $urpm->{media}[$n]{name},
			retry => $urpm->{options}{retry},
		    },
		    values %distant_sources,
		);
		$urpm->{log}(N("...retrieving done"));
	    };
	    $@ and $urpm->{error}(N("...retrieving failed: %s", $@));
	    #- clean files that have not been downloaded, but keep in mind
	    #- there have been problems downloading them at least once, this
	    #- is necessary to keep track of failing downloads in order to
	    #- present the error to the user.
	    foreach my $i (keys %distant_sources) {
		my ($filename) = $distant_sources{$i} =~ m|/([^/]*\.rpm)$|;
		if ($filename && -s "$urpm->{cachedir}/partial/$filename" &&
		    URPM::verify_rpm("$urpm->{cachedir}/partial/$filename", nosignatures => 1))
		{
		    #- it seems the the file has been downloaded correctly and has been checked to be valid.
		    unlink "$urpm->{cachedir}/rpms/$filename";
		    urpm::util::move("$urpm->{cachedir}/partial/$filename", "$urpm->{cachedir}/rpms/$filename");
		    -r "$urpm->{cachedir}/rpms/$filename" and $sources->{$i} = "$urpm->{cachedir}/rpms/$filename";
		}
		unless ($sources->{$i}) {
		    $error_sources->{$i} = $distant_sources{$i};
		}
	    }
	}
    }

    #- clean failed download which have succeeded.
    delete @$error_sources{keys %$sources};

    1;
}

#- prepare transaction.
sub prepare_transaction {
    my ($urpm, $set, $list, $sources, $transaction_list, $transaction_sources) = @_;

    foreach my $id (@{$set->{upgrade}}) {
	my $pkg = $urpm->{depslist}[$id];
	foreach (0..$#$list) {
	    exists $list->[$_]{$id} and $transaction_list->[$_]{$id} = $list->[$_]{$id};
	}
	exists $sources->{$id} and $transaction_sources->{$id} = $sources->{$id};
    }
}

#- extract package that should be installed instead of upgraded,
#- sources is a hash of id -> source rpm filename.
sub extract_packages_to_install {
    my ($urpm, $sources, $state) = @_;
    my %inst;
    my $rej = ref $state ? $state->{rejected} || {} : {};

    foreach (keys %$sources) {
	my $pkg = $urpm->{depslist}[$_] or next;
	$pkg->flag_disable_obsolete || !$pkg->flag_installed
	    and !grep { exists $rej->{$_}{closure}{$pkg->fullname} } keys %$rej
	    and $inst{$pkg->id} = delete $sources->{$pkg->id};
    }

    \%inst;
}

my $progress_size = 45;
eval {
    require Term::ReadKey;
    ($progress_size) = Term::ReadKey::GetTerminalSize();
    $progress_size -= 35;
    $progress_size < 5 and $progress_size = 5;
};

#- install logger (a la rpm)
sub install_logger {
    my ($urpm, $type, $id, $subtype, $amount, $total) = @_;
    my $pkg = defined $id && $urpm->{depslist}[$id];
    my $total_pkg = $urpm->{nb_install};

    if ($subtype eq 'start') {
	$urpm->{logger_progress} = 0;
	if ($type eq 'trans') {
	    $urpm->{logger_id} ||= 0;
	    $urpm->{logger_count} ||= 0;
	    printf("%-33s", N("Preparing..."));
	} else {
	    ++$urpm->{logger_id};
	    my $pname = $pkg ? $pkg->name : '';
	    ++$urpm->{logger_count} if $pname;
	    my $cnt = $pname ? $urpm->{logger_count} : '-';
	    $pname ||= N("[repackaging]");
	    printf "%9s: %-22s", $cnt . "/" . $total_pkg, $pname;
	}
    } elsif ($subtype eq 'stop') {
	if ($urpm->{logger_progress} < $progress_size) {
	    print '#' x ($progress_size - $urpm->{logger_progress});
	    print "\n";
	}
    } elsif ($subtype eq 'progress') {
	my $new_progress = $total > 0 ? int($progress_size * $amount / $total) : $progress_size;
	if ($new_progress > $urpm->{logger_progress}) {
	    print '#' x ($new_progress - $urpm->{logger_progress});
	    $urpm->{logger_progress} = $new_progress;
	    $urpm->{logger_progress} == $progress_size and print "\n";
	}
    }
}

#- install packages according to each hash (remove, install or upgrade).
sub install {
    my ($urpm, $remove, $install, $upgrade, %options) = @_;
    my %readmes;

    #- allow process to be forked now.
    my $pid;
    local (*CHILD_RETURNS, *ERROR_OUTPUT, $_);
    if ($options{fork}) {
	pipe(CHILD_RETURNS, ERROR_OUTPUT);
	defined($pid = fork()) or die "Can't fork: $!\n";
	if ($pid) {
	    # parent process
	    close ERROR_OUTPUT;

	    $urpm->{log}(N("using process %d for executing transaction", $pid));
	    #- now get all errors from the child and return them directly.
	    my @l;
	    while (<CHILD_RETURNS>) {
		chomp;
		if (/^::logger_id:(\d+)(?::(\d+))?/) {
		    $urpm->{logger_id} = $1;
		    $2 and $urpm->{logger_count} = $2;
		} else {
		    push @l, $_;
		}
	    }

	    close CHILD_RETURNS;
	    waitpid($pid, 0);
	    #- take care of return code from transaction, an error should be returned directly.
	    $? >> 8 and exit $? >> 8;

	    return @l;
	} else {
	    # child process
	    close CHILD_RETURNS;
	}
    }
    #- beware this can be a child process or the main process now...

    my $db = URPM::DB::open($urpm->{root}, !$options{test}); #- open in read/write mode unless testing installation.

    $db or $urpm->{fatal}(9, N("unable to open rpmdb"));

    my $trans = $db->create_transaction($urpm->{root});
    if ($trans) {
	sys_log("transaction on %s (remove=%d, install=%d, upgrade=%d)", $urpm->{root} || '/', scalar(@{$remove || []}), scalar(values %$install), scalar(values %$upgrade));
	$urpm->{log}(N("created transaction for installing on %s (remove=%d, install=%d, upgrade=%d)", $urpm->{root} || '/',
		       scalar(@{$remove || []}), scalar(values %$install), scalar(values %$upgrade)));
    } else {
	return N("unable to create transaction");
    }