特殊:Badtitle/NS100:DowngradeHowto:修订间差异
小无编辑摘要 |
小无编辑摘要 |
||
第1行: | 第1行: | ||
{{From|https://help.ubuntu.com/community/DowngradeHowto}} | {{From|https://help.ubuntu.com/community/DowngradeHowto}} | ||
{{Languages|UbuntuHelp:DowngradeHowto}} | {{Languages|UbuntuHelp:DowngradeHowto}} | ||
== Downgrade == | == Downgrade == | ||
So, for one reason or another, you've upgraded Ubuntu to a new version. Now, you're not liking the new version (or it's a development version and too unstable for your taste). Downgrading is a little-covered topic, but let's change that! | So, for one reason or another, you've upgraded Ubuntu to a new version. Now, you're not liking the new version (or it's a development version and too unstable for your taste). Downgrading is a little-covered topic, but let's change that! | ||
=== DISCLAIMER === | === DISCLAIMER === | ||
This document is still under development | The first method below worked fine for me downgrading from hardy+backports+proposed back to hardy-backports-proposed. However, a previous wikizen has stated, with regards the second method: | ||
=== | DO NOT DO THIS. YOU CANNOT DOWNGRADE PYTHON ACROSS PACKAGES FROM HARDY TO GUTSY. | ||
For this guide, we'll use the example of downgrading Ubuntu Breezy to Ubuntu Hoary. This guide can be adapted to downgrade any combination of releases. | I tried this to downgrade from intrepid to hardy again. It worked almost fine, until the ati-drivers came into place! You must remove all Third-party-packages before and downgrade without any X loaded. Then it might work. | ||
This document is still under development, and likely will be until some user-friendly option is added to apt-get. Please pursue at your own risk. | |||
=== The first method === | |||
The problem with downgrading is that apt will not do it automatically. That's not a bug: apt is intelligent enough to assume that it doesn't know everything about your system; dpkg, by design, can install different packages and versions entirely separate from the apt fetching mechanism. | |||
But between apt and dpkg, all of the required information for downgrading is present on your system, you just have to use it properly. What this method does is ensure no version higher than the canonical versions in /var/lib/apt/lists/*_Packages is installed. | |||
==== Setting up sources ==== | |||
The first step is to get apt into proper shape. Set up your sources.list file with your favorite method, and run <code><nowiki>sudo apt-get update</nowiki></code>. | |||
==== Collating apt sources with dpkg records ==== | |||
In theory, the next step would be to browse through the file /var/lib/dpkg/status, find all the version numbers, and then try and find the highest version in the various /var/lib/apt/lists/*_Packages files. If the version in status is not the highest version in *_Packages, install the version in *_Packages instead. Note that in the unusual case there was an upgrade in *_Packages, that would be performed as well as the downgrades. | |||
But this is tedious, and we have computers to do this for you. | |||
==== The script ==== | |||
I wrote a simple perl script that does the above. It is slightly buggy with the version numbers (NOTE: in case someone wants to help improve this script, a better way to deal with comparing version numbers might be to launch a command similar to 'dpkg --compare-versions 1 lt 2 && echo true') and hasn't been extensively tested, but it should get the job done. | |||
<pre><nowiki> | |||
#!/usr/bin/perl | |||
use strict; | |||
use Data::Dumper; | |||
my $status = {}; | |||
my $available = {}; | |||
open(STATUS, "/var/lib/dpkg/status"); | |||
parse_dpkg(*STATUS{IO}, $status); | |||
close(STATUS); | |||
my @files = split(/\s+/, `ls /var/lib/apt/lists/*_Packages`); | |||
my $file; | |||
foreach $file (@files) { | |||
open(AVAILABLE, $file); | |||
parse_dpkg(*AVAILABLE{IO}, $available); | |||
close AVAILABLE; | |||
} | |||
my @args = ("apt-get", "install"); | |||
my $key; | |||
foreach $key (sort(keys %$status)) { | |||
if($available->{$key} | |||
and $status->{$key}->{"Version"} | |||
and $status->{$key}->{"Version"} ne $available->{$key}->{"Version"}) { | |||
push(@args, "$key=" . $available->{$key}->{"Version"} ); | |||
} | |||
} | |||
print Dumper(\@args); | |||
unshift(@args, "install"); | |||
unshift(@args, "apt-get"); | |||
# system(@args); | |||
sub parse_dpkg { | |||
my $fh = shift; | |||
my $hash = shift; | |||
my $curhash = {}; | |||
my $line = ""; | |||
my $go = 1; | |||
while($go) { | |||
($_ = <$fh>) or $go = 0; | |||
/^\s*$/ and do { | |||
$line =~ /([^:]*):\s*(.*?)\s*$/s; | |||
$curhash->{$1} = $2; | |||
$line = ""; | |||
if(!defined($hash->{$curhash->{"Package"}}) | |||
or compare_version($hash->{$curhash->{"Package"}}->{"Version"}, | |||
$curhash->{"Version"}) < 0) { | |||
$hash->{$curhash->{"Package"}} = $curhash; | |||
} | |||
$curhash = {}; | |||
next; | |||
}; | |||
/^(\s+.*)$/ and do { | |||
$line .= $1; | |||
next; | |||
}; | |||
if($line) { | |||
$line =~ /([^:]*):\s*(.*?)\s*$/s; | |||
$curhash->{$1} = $2; | |||
$line = ""; | |||
} | |||
$line = $_; | |||
} | |||
} | |||
sub compare_version { | |||
my $ver1 = shift; | |||
my $ver2 = shift; | |||
my $dbg = shift; | |||
my $ver1_epoch = 0; | |||
my $ver2_epoch = 0; | |||
my $ver1_uvers = ''; | |||
my $ver2_uvers = ''; | |||
$ver1 =~ s/^([^:]*):// and $ver1_epoch = $1; | |||
$ver2 =~ s/^([^:]*):// and $ver2_epoch = $1; | |||
$ver1 =~ s/-([^-]*)$// and $ver1_uvers = $1; | |||
$ver2 =~ s/-([^-]*)$// and $ver2_uvers = $1; | |||
if($ver1_epoch != $ver2_epoch) { | |||
if($dbg) { | |||
print "Difference of epochs: " . $ver1_epoch . " vs. " . $ver2_epoch . "\n"; | |||
print "returning " . ($ver1_epoch <=> $ver2_epoch); | |||
} | |||
return $ver1_epoch <=> $ver2_epoch; | |||
} | |||
if($ver1 eq $ver2) { | |||
if($dbg) { | |||
print "Identical versions: " . $ver1 . " vs. " . $ver2 . "\n"; | |||
} | |||
$ver1 = $ver1_uvers; | |||
$ver2 = $ver2_uvers; | |||
} | |||
if($ver1 eq $ver2) { | |||
if($dbg) { | |||
print "Identical uversions: " . $ver1 . " vs. " . $ver2 . "\n"; | |||
print "Returning 0"; | |||
} | |||
return 0; | |||
} | |||
my $digit = 0; | |||
while($ver1 or $ver2) { | |||
if($digit) { | |||
my $n1 = 0; | |||
my $n2 = 0; | |||
$ver1 =~ s/^([0-9]+)// and $n1 = $1; | |||
$ver2 =~ s/^([0-9]+)// and $n2 = $1; | |||
if($dbg) { | |||
print "Comparing $n1 with $n2...\n"; | |||
} | |||
if($n1 != $n2) { | |||
if($dbg) { | |||
print "returning " . ($n1 <=> $n2) . "\n"; | |||
} | |||
return $n1 <=> $n2; | |||
} | |||
$digit = 0; | |||
$ver1 =~ s/^\.(?=[0-9]+)// and $digit = 1; | |||
$ver2 =~ s/^\.(?=[0-9]+)// and $digit = 1; | |||
} else { | |||
my $s1 = ""; | |||
my $s2 = ""; | |||
$ver1 =~ s/^([^0-9]+)// and $s1 = $1; | |||
$ver2 =~ s/^([^0-9]+)// and $s2 = $1; | |||
if($dbg) { | |||
print "Comparing $s1 with $s2...\n"; | |||
} | |||
for(my $i = 0; $i < length($s1) or $i < length($s2); $i++) { | |||
my $c1 = ""; | |||
my $c2 = ""; | |||
$i < length($s1) and $c1 = substr($s1, $i, 1); | |||
$i < length($s2) and $c2 = substr($s2, $i, 1); | |||
if($c1 eq $c2) { | |||
next; | |||
} | |||
if($c1 eq "~") { | |||
if($dbg) { | |||
print "returning 1\n"; | |||
} | |||
return 1; | |||
} | |||
if($c2 eq "~") { | |||
if($dbg) { | |||
print "returning -1\n"; | |||
} | |||
return -1; | |||
} | |||
if($c1 eq "") { | |||
if($dbg) { | |||
print "returning -1\n"; | |||
} | |||
return -1; | |||
} | |||
if($c2 eq "") { | |||
if($dbg) { | |||
print "returning 1\n"; | |||
} | |||
return 1; | |||
} | |||
if($c1 =~ /^[a-zA-Z]$/) { | |||
if($c2 !~ /^[a-zA-Z]$/) { | |||
if($dbg) { | |||
print "returning 1\n"; | |||
} | |||
return 1; | |||
} | |||
} elsif($c2 =~ /^[a-zA-Z]$/) { | |||
return -1; | |||
if($dbg) { | |||
print "returning -1\n"; | |||
} | |||
} | |||
return $c1 cmp $c2; | |||
} | |||
$digit = 1; | |||
} | |||
} | |||
} | |||
</nowiki></pre> | |||
==== Using the script ==== | |||
The above script will spit out a list of packages to downgrade, and the version numbers to downgrade to. If everything looks ok, hold your breath, do a little good luck dance and uncomment the relevant line. Run it again, and presto! your system is downgraded. | |||
==== Cleaning up ==== | |||
Hopefully the above script doesn't downgrade anything accidentally, but if it does, the solution is simple: just run a package management tool and upgrade. It should upgrade whatever has been accidentally downgraded and leave the rest alone. | |||
=== The second method === | |||
The second method uses an apt mechanism called "pinning". That might seem more native, but the mechanism wasn't really designed for downgrading. It can only be used to downgrade major versions, not for incremental downgrades like +proposed to -proposed. For this guide, we'll use the example of downgrading Ubuntu Breezy to Ubuntu Hoary. This guide can be adapted to downgrade any combination of releases. | |||
==== Setting up sources ==== | ==== Setting up sources ==== | ||
You'll need sources.list entries for both releases for the procedure to work properly. It's important to remove all other lines for now! Example sources.list: | You'll need sources.list entries for both releases for the procedure to work properly. It's important to remove all other lines for now! Example sources.list: | ||
第36行: | 第269行: | ||
==== Cleaning up after the storm ==== | ==== Cleaning up after the storm ==== | ||
The last step probably will end up a catastrophic mess of incompletely installed packages. We need to fix that now. | The last step probably will end up a catastrophic mess of incompletely installed packages. We need to fix that now. | ||
=== Sources === | ==== Sources ==== | ||
http://linuxmafia.com/faq/Debian/downgrade.html | http://linuxmafia.com/faq/Debian/downgrade.html | ||
---- | ---- | ||
[[category:UbuntuHelp]] | [[category:UbuntuHelp]] |
2009年5月12日 (二) 16:30的版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/DowngradeHowto }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/af | • {{#if: UbuntuHelp:DowngradeHowto|Afrikaans| [[::DowngradeHowto/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/ar | • {{#if: UbuntuHelp:DowngradeHowto|العربية| [[::DowngradeHowto/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/az | • {{#if: UbuntuHelp:DowngradeHowto|azərbaycanca| [[::DowngradeHowto/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/bcc | • {{#if: UbuntuHelp:DowngradeHowto|جهلسری بلوچی| [[::DowngradeHowto/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/bg | • {{#if: UbuntuHelp:DowngradeHowto|български| [[::DowngradeHowto/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/br | • {{#if: UbuntuHelp:DowngradeHowto|brezhoneg| [[::DowngradeHowto/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/ca | • {{#if: UbuntuHelp:DowngradeHowto|català| [[::DowngradeHowto/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/cs | • {{#if: UbuntuHelp:DowngradeHowto|čeština| [[::DowngradeHowto/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/de | • {{#if: UbuntuHelp:DowngradeHowto|Deutsch| [[::DowngradeHowto/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/el | • {{#if: UbuntuHelp:DowngradeHowto|Ελληνικά| [[::DowngradeHowto/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/es | • {{#if: UbuntuHelp:DowngradeHowto|español| [[::DowngradeHowto/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/fa | • {{#if: UbuntuHelp:DowngradeHowto|فارسی| [[::DowngradeHowto/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/fi | • {{#if: UbuntuHelp:DowngradeHowto|suomi| [[::DowngradeHowto/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/fr | • {{#if: UbuntuHelp:DowngradeHowto|français| [[::DowngradeHowto/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/gu | • {{#if: UbuntuHelp:DowngradeHowto|ગુજરાતી| [[::DowngradeHowto/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/he | • {{#if: UbuntuHelp:DowngradeHowto|עברית| [[::DowngradeHowto/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/hu | • {{#if: UbuntuHelp:DowngradeHowto|magyar| [[::DowngradeHowto/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/id | • {{#if: UbuntuHelp:DowngradeHowto|Bahasa Indonesia| [[::DowngradeHowto/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/it | • {{#if: UbuntuHelp:DowngradeHowto|italiano| [[::DowngradeHowto/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/ja | • {{#if: UbuntuHelp:DowngradeHowto|日本語| [[::DowngradeHowto/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/ko | • {{#if: UbuntuHelp:DowngradeHowto|한국어| [[::DowngradeHowto/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/ksh | • {{#if: UbuntuHelp:DowngradeHowto|Ripoarisch| [[::DowngradeHowto/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/mr | • {{#if: UbuntuHelp:DowngradeHowto|मराठी| [[::DowngradeHowto/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/ms | • {{#if: UbuntuHelp:DowngradeHowto|Bahasa Melayu| [[::DowngradeHowto/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/nl | • {{#if: UbuntuHelp:DowngradeHowto|Nederlands| [[::DowngradeHowto/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/no | • {{#if: UbuntuHelp:DowngradeHowto|norsk| [[::DowngradeHowto/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/oc | • {{#if: UbuntuHelp:DowngradeHowto|occitan| [[::DowngradeHowto/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/pl | • {{#if: UbuntuHelp:DowngradeHowto|polski| [[::DowngradeHowto/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/pt | • {{#if: UbuntuHelp:DowngradeHowto|português| [[::DowngradeHowto/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/ro | • {{#if: UbuntuHelp:DowngradeHowto|română| [[::DowngradeHowto/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/ru | • {{#if: UbuntuHelp:DowngradeHowto|русский| [[::DowngradeHowto/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/si | • {{#if: UbuntuHelp:DowngradeHowto|සිංහල| [[::DowngradeHowto/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/sq | • {{#if: UbuntuHelp:DowngradeHowto|shqip| [[::DowngradeHowto/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/sr | • {{#if: UbuntuHelp:DowngradeHowto|српски / srpski| [[::DowngradeHowto/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/sv | • {{#if: UbuntuHelp:DowngradeHowto|svenska| [[::DowngradeHowto/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/th | • {{#if: UbuntuHelp:DowngradeHowto|ไทย| [[::DowngradeHowto/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/tr | • {{#if: UbuntuHelp:DowngradeHowto|Türkçe| [[::DowngradeHowto/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/vi | • {{#if: UbuntuHelp:DowngradeHowto|Tiếng Việt| [[::DowngradeHowto/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/yue | • {{#if: UbuntuHelp:DowngradeHowto|粵語| [[::DowngradeHowto/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/zh | • {{#if: UbuntuHelp:DowngradeHowto|中文| [[::DowngradeHowto/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/zh-hans | • {{#if: UbuntuHelp:DowngradeHowto|中文(简体)| [[::DowngradeHowto/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:DowngradeHowto | UbuntuHelp:DowngradeHowto | {{#if: | :}}DowngradeHowto}}/zh-hant | • {{#if: UbuntuHelp:DowngradeHowto|中文(繁體)| [[::DowngradeHowto/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:DowngradeHowto|:DowngradeHowto|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :DowngradeHowto/zh | | {{#ifexist: DowngradeHowto/zh | | {{#ifeq: {{#titleparts:DowngradeHowto|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:DowngradeHowto|1|-1|}} | zh | | }}
Downgrade
So, for one reason or another, you've upgraded Ubuntu to a new version. Now, you're not liking the new version (or it's a development version and too unstable for your taste). Downgrading is a little-covered topic, but let's change that!
DISCLAIMER
The first method below worked fine for me downgrading from hardy+backports+proposed back to hardy-backports-proposed. However, a previous wikizen has stated, with regards the second method: DO NOT DO THIS. YOU CANNOT DOWNGRADE PYTHON ACROSS PACKAGES FROM HARDY TO GUTSY. I tried this to downgrade from intrepid to hardy again. It worked almost fine, until the ati-drivers came into place! You must remove all Third-party-packages before and downgrade without any X loaded. Then it might work. This document is still under development, and likely will be until some user-friendly option is added to apt-get. Please pursue at your own risk.
The first method
The problem with downgrading is that apt will not do it automatically. That's not a bug: apt is intelligent enough to assume that it doesn't know everything about your system; dpkg, by design, can install different packages and versions entirely separate from the apt fetching mechanism. But between apt and dpkg, all of the required information for downgrading is present on your system, you just have to use it properly. What this method does is ensure no version higher than the canonical versions in /var/lib/apt/lists/*_Packages is installed.
Setting up sources
The first step is to get apt into proper shape. Set up your sources.list file with your favorite method, and run sudo apt-get update
.
Collating apt sources with dpkg records
In theory, the next step would be to browse through the file /var/lib/dpkg/status, find all the version numbers, and then try and find the highest version in the various /var/lib/apt/lists/*_Packages files. If the version in status is not the highest version in *_Packages, install the version in *_Packages instead. Note that in the unusual case there was an upgrade in *_Packages, that would be performed as well as the downgrades. But this is tedious, and we have computers to do this for you.
The script
I wrote a simple perl script that does the above. It is slightly buggy with the version numbers (NOTE: in case someone wants to help improve this script, a better way to deal with comparing version numbers might be to launch a command similar to 'dpkg --compare-versions 1 lt 2 && echo true') and hasn't been extensively tested, but it should get the job done.
#!/usr/bin/perl use strict; use Data::Dumper; my $status = {}; my $available = {}; open(STATUS, "/var/lib/dpkg/status"); parse_dpkg(*STATUS{IO}, $status); close(STATUS); my @files = split(/\s+/, `ls /var/lib/apt/lists/*_Packages`); my $file; foreach $file (@files) { open(AVAILABLE, $file); parse_dpkg(*AVAILABLE{IO}, $available); close AVAILABLE; } my @args = ("apt-get", "install"); my $key; foreach $key (sort(keys %$status)) { if($available->{$key} and $status->{$key}->{"Version"} and $status->{$key}->{"Version"} ne $available->{$key}->{"Version"}) { push(@args, "$key=" . $available->{$key}->{"Version"} ); } } print Dumper(\@args); unshift(@args, "install"); unshift(@args, "apt-get"); # system(@args); sub parse_dpkg { my $fh = shift; my $hash = shift; my $curhash = {}; my $line = ""; my $go = 1; while($go) { ($_ = <$fh>) or $go = 0; /^\s*$/ and do { $line =~ /([^:]*):\s*(.*?)\s*$/s; $curhash->{$1} = $2; $line = ""; if(!defined($hash->{$curhash->{"Package"}}) or compare_version($hash->{$curhash->{"Package"}}->{"Version"}, $curhash->{"Version"}) < 0) { $hash->{$curhash->{"Package"}} = $curhash; } $curhash = {}; next; }; /^(\s+.*)$/ and do { $line .= $1; next; }; if($line) { $line =~ /([^:]*):\s*(.*?)\s*$/s; $curhash->{$1} = $2; $line = ""; } $line = $_; } } sub compare_version { my $ver1 = shift; my $ver2 = shift; my $dbg = shift; my $ver1_epoch = 0; my $ver2_epoch = 0; my $ver1_uvers = ''; my $ver2_uvers = ''; $ver1 =~ s/^([^:]*):// and $ver1_epoch = $1; $ver2 =~ s/^([^:]*):// and $ver2_epoch = $1; $ver1 =~ s/-([^-]*)$// and $ver1_uvers = $1; $ver2 =~ s/-([^-]*)$// and $ver2_uvers = $1; if($ver1_epoch != $ver2_epoch) { if($dbg) { print "Difference of epochs: " . $ver1_epoch . " vs. " . $ver2_epoch . "\n"; print "returning " . ($ver1_epoch <=> $ver2_epoch); } return $ver1_epoch <=> $ver2_epoch; } if($ver1 eq $ver2) { if($dbg) { print "Identical versions: " . $ver1 . " vs. " . $ver2 . "\n"; } $ver1 = $ver1_uvers; $ver2 = $ver2_uvers; } if($ver1 eq $ver2) { if($dbg) { print "Identical uversions: " . $ver1 . " vs. " . $ver2 . "\n"; print "Returning 0"; } return 0; } my $digit = 0; while($ver1 or $ver2) { if($digit) { my $n1 = 0; my $n2 = 0; $ver1 =~ s/^([0-9]+)// and $n1 = $1; $ver2 =~ s/^([0-9]+)// and $n2 = $1; if($dbg) { print "Comparing $n1 with $n2...\n"; } if($n1 != $n2) { if($dbg) { print "returning " . ($n1 <=> $n2) . "\n"; } return $n1 <=> $n2; } $digit = 0; $ver1 =~ s/^\.(?=[0-9]+)// and $digit = 1; $ver2 =~ s/^\.(?=[0-9]+)// and $digit = 1; } else { my $s1 = ""; my $s2 = ""; $ver1 =~ s/^([^0-9]+)// and $s1 = $1; $ver2 =~ s/^([^0-9]+)// and $s2 = $1; if($dbg) { print "Comparing $s1 with $s2...\n"; } for(my $i = 0; $i < length($s1) or $i < length($s2); $i++) { my $c1 = ""; my $c2 = ""; $i < length($s1) and $c1 = substr($s1, $i, 1); $i < length($s2) and $c2 = substr($s2, $i, 1); if($c1 eq $c2) { next; } if($c1 eq "~") { if($dbg) { print "returning 1\n"; } return 1; } if($c2 eq "~") { if($dbg) { print "returning -1\n"; } return -1; } if($c1 eq "") { if($dbg) { print "returning -1\n"; } return -1; } if($c2 eq "") { if($dbg) { print "returning 1\n"; } return 1; } if($c1 =~ /^[a-zA-Z]$/) { if($c2 !~ /^[a-zA-Z]$/) { if($dbg) { print "returning 1\n"; } return 1; } } elsif($c2 =~ /^[a-zA-Z]$/) { return -1; if($dbg) { print "returning -1\n"; } } return $c1 cmp $c2; } $digit = 1; } } }
Using the script
The above script will spit out a list of packages to downgrade, and the version numbers to downgrade to. If everything looks ok, hold your breath, do a little good luck dance and uncomment the relevant line. Run it again, and presto! your system is downgraded.
Cleaning up
Hopefully the above script doesn't downgrade anything accidentally, but if it does, the solution is simple: just run a package management tool and upgrade. It should upgrade whatever has been accidentally downgraded and leave the rest alone.
The second method
The second method uses an apt mechanism called "pinning". That might seem more native, but the mechanism wasn't really designed for downgrading. It can only be used to downgrade major versions, not for incremental downgrades like +proposed to -proposed. For this guide, we'll use the example of downgrading Ubuntu Breezy to Ubuntu Hoary. This guide can be adapted to downgrade any combination of releases.
Setting up sources
You'll need sources.list entries for both releases for the procedure to work properly. It's important to remove all other lines for now! Example sources.list:
deb http://archive.ubuntu.com/ubuntu hoary main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu breezy main restricted universe multiverse
Setting up pinning
Open up /etc/apt/preferences with your favorite editor (such as gksudo gedit /etc/apt/preferences
)
Add the following lines to the file (remove any existing entries):
Package: * Pin: release a=hoary Pin-Priority: 1001 Package: * Pin: release a=breezy Pin-Priority: 60
Doing the downgrade
If you're ready to continue, we're going to continue:
First, we need to update APT's information:
sudo apt-get update
Next, we'll downgrade:
sudo apt-get dist-upgrade
Cleaning up after the storm
The last step probably will end up a catastrophic mess of incompletely installed packages. We need to fix that now.
Sources
http://linuxmafia.com/faq/Debian/downgrade.html