Merge lp:~eugenesan/ppa-purge/trunk into lp:ppa-purge

Proposed by Eugene San
Status: Superseded
Proposed branch: lp:~eugenesan/ppa-purge/trunk
Merge into: lp:ppa-purge
Diff against target: 149 lines (+47/-36)
3 files modified
debian/changelog (+8/-0)
debian/control (+1/-1)
ppa-purge (+38/-35)
To merge this branch: bzr merge lp:~eugenesan/ppa-purge/trunk
Reviewer Review Type Date Requested Status
ppa-purge Pending
Review via email: mp+46570@code.launchpad.net

This proposal has been superseded by a proposal from 2011-01-18.

Description of the change

Adding support for compressed and empty packages lists

To post a comment you must log in.
Revision history for this message
Tormod Volden (tormodvolden) wrote :

Hi, thanks for the code. This could also have been three commits though: 1) whitespace clean-up, 2) adding support for compressed package lists, 3) add support for empty package lists.

Anyway, does it really work? $LIST is always an existing file (as long as the * in PPA_LIST successfully expands, otherwise it is useless, that was what the original -e checked for), so 1) the elif's can not be reached and 2) $LIST.gz can not exist at the same time as $LIST, right? I don't have any compressed lists on my machine so I can not verify this case :)

Basically, 1) the PPA_LIST does not match anything ending in .gz etc, and 2) if it would, $LIST.gz would not exist since the .gz would already be included in $LIST.

I can suggest instead adding * to the end of the PPA_LIST so that any filename suffix gets expanded, then use lesspipe to decompress $LIST whatever its file type is (kind of a hack).

Revision history for this message
Eugene San (eugenesan) wrote :

Hi, thanks for prompt review.

Sorry for combining all changes together, wasn't sure they deserve separate
commits.
After reading your points I realized that the shouldn't work, but some how
it does!
I probably was still sleeping while committing :-)
I am going to review the code one more time later.

Just in case you willing to play with it, this is how you enable compressed
lists:
echo "
Acquire::GzipIndexes "true";
Acquire::CompressionTypes::Order:: "gz";
" >> /etc/apt/apt.conf

And for empty repository:
add-apt-repository unity/ppa

On Tue, Jan 18, 2011 at 11:25, Tormod Volden <email address hidden>wrote:

> Hi, thanks for the code. This could also have been three commits though: 1)
> whitespace clean-up, 2) adding support for compressed package lists, 3) add
> support for empty package lists.
>
> Anyway, does it really work? $LIST is always an existing file (as long as
> the * in PPA_LIST successfully expands, otherwise it is useless, that was
> what the original -e checked for), so 1) the elif's can not be reached and
> 2) $LIST.gz can not exist at the same time as $LIST, right? I don't have any
> compressed lists on my machine so I can not verify this case :)
>
> Basically, 1) the PPA_LIST does not match anything ending in .gz etc, and
> 2) if it would, $LIST.gz would not exist since the .gz would already be
> included in $LIST.
>
> I can suggest instead adding * to the end of the PPA_LIST so that any
> filename suffix gets expanded, then use lesspipe to decompress $LIST
> whatever its file type is (kind of a hack).
> --
> https://code.launchpad.net/~eugenesan/ppa-purge/trunk/+merge/46570<https://code.launchpad.net/%7Eeugenesan/ppa-purge/trunk/+merge/46570>
> You are the owner of lp:~eugenesan/ppa-purge/trunk.
>

lp:~eugenesan/ppa-purge/trunk updated
58. By Eugene San

Finalizing support for compressed and empty apt lists

59. By Eugene San

Fixing nonblocking typos

60. By Eugene San

Fixng failed empty list detection

61. By Eugene San

Update debian/changelog

Unmerged revisions

61. By Eugene San

Update debian/changelog

60. By Eugene San

Fixng failed empty list detection

59. By Eugene San

Fixing nonblocking typos

58. By Eugene San

Finalizing support for compressed and empty apt lists

57. By Eugene San

Merged main branch

56. By Eugene San

Adding support for compressed and empty packages lists

55. By eugenesan <eugenesan@portsan>

Fixing typo in changelog

54. By eugenesan <eugenesan@portsan>

Fixing typo causing permanent aptitude usage

53. By eugenesan <eugenesan@portsan>

Few changes for upcoming 0.2.8

52. By eugenesan <eugenesan@portsan>

Adding reverse order of apt tool usage and support for symlinked lists

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2010-11-10 20:13:14 +0000
3+++ debian/changelog 2011-01-18 20:05:43 +0000
4@@ -1,3 +1,11 @@
5+ppa-purge (0.2.8+bzr57) natty; urgency=low
6+
7+ [ Eugene San (eugenesan) ]
8+ * Added support for compressed and empty apt lists
9+ * Few cosmetic changes
10+
11+ -- Lorenzo De Liso <blackz@ubuntu.com> Wed, 10 Nov 2010 21:12:13 +0100
12+
13 ppa-purge (0.2.8+bzr56) natty; urgency=low
14
15 * Really implement the "-y" option.
16
17=== modified file 'debian/control'
18--- debian/control 2010-10-15 21:22:59 +0000
19+++ debian/control 2011-01-18 20:05:43 +0000
20@@ -8,7 +8,7 @@
21
22 Package: ppa-purge
23 Architecture: all
24-Depends: ${misc:Depends}, aptitude
25+Depends: ${misc:Depends}, aptitude, less
26 Description: disables a PPA and reverts to official packages
27 This program disables a PPA from your Software Sources and reverts your
28 system back to the official Ubuntu packages. You can use this to return your
29
30=== modified file 'ppa-purge'
31--- ppa-purge 2010-11-10 20:13:14 +0000
32+++ ppa-purge 2011-01-18 20:05:43 +0000
33@@ -1,4 +1,4 @@
34-#!/bin/bash
35+#!/bin/bash -x
36 # A script to remove all packages in a PPA and revert back to the normal
37 # distribution ones.
38 #
39@@ -20,7 +20,12 @@
40 }
41
42 warn() {
43- write_msg "Warning: $*" 1>&2
44+ write_msg "Warning: $*" 1>&2
45+}
46+
47+err() {
48+ write_msg "Error: $*" 1>&2
49+ exit 1
50 }
51
52 usage() {
53@@ -61,7 +66,7 @@
54 s ) PPAHOST="$OPTARG" ;;
55 d ) DIST="$OPTARG" ;;
56 y ) FORCEINSTALL="true" ;;
57- i ) APTALT="true" ;;
58+ i ) APTALT="true" ;;
59 h ) usage 0; ;;
60 \?) usage 1; ;;
61 * ) warn "Unknown option '$opt'"; usage 1; ;;
62@@ -73,12 +78,12 @@
63 APTARG=""
64 if [ ! -z "$APTALT" ]; then
65 if [ ! -z "$FORCEINSTALL" ]; then
66- APTARG="-y"
67+ APTARG="-y"
68 fi
69 APT=aptitude; APTALT=apt-get
70 else
71 if [ ! -z "$FORCEINSTALL" ]; then
72- APTARG="-y --force-yes"
73+ APTARG="-y --force-yes"
74 fi
75 APT=apt-get; APTALT=aptitude
76 fi
77@@ -109,36 +114,34 @@
78 msg "PPA to be removed: $PPAOWNER $PPANAME"
79
80 # Make list of all packages in PPA
81-PPA_LIST=/var/lib/apt/lists/${PPAHOST}_${PPAOWNER}_${PPANAME}_*_Packages
82-for LIST in $PPA_LIST; do
83- if [ -e $LIST ]; then
84- grep "^Package: " $LIST | cut -d " " -f2 | sort >> $PPA_PKGS
85- fi
86-done
87+for LIST in /var/lib/apt/lists/${PPAHOST}_${PPAOWNER}_${PPANAME}_*_Packages* ; do
88+ lesspipe ${LIST} | grep "^Package: " | cut -d " " -f2 | sort >> $PPA_PKGS
89+done 2> /dev/null > /dev/null
90+
91+[ -z "$LIST" ] && err "Could not find packages list for PPA: $PPAOWNER $PPANAME" exit 1
92
93 if [ ! -s $PPA_PKGS ]; then
94- warn "Could not find package list for PPA: $PPAOWNER $PPANAME"
95- exit 1
96-fi
97-
98-# Ignore the ppa-purge package
99-if grep -q "ppa-purge" $PPA_PKGS; then
100- sed -i '/ppa-purge/d' $PPA_PKGS
101- msg "Note: Not removing ppa-purge package"
102-fi
103-
104-dpkg --get-selections | awk '/install$/{print $1}' |
105- sort | comm -12 - $PPA_PKGS > $REVERTS
106-
107-# Create apt argument list for reverting packages
108-REINSTALL=""
109-for PACKAGE in $(cat $REVERTS); do
110- REINSTALL="$REINSTALL $PACKAGE/$DIST"
111-done
112-
113-msg "Package revert list generated:"
114-msg "$REINSTALL"
115-echo
116+ warn "PPA: $PPAOWNER $PPANAME is empty, skipping packages treatment."
117+else
118+ # Ignore the ppa-purge package
119+ if grep -q "ppa-purge" $PPA_PKGS; then
120+ sed -i '/ppa-purge/d' $PPA_PKGS
121+ msg "Note: Not removing ppa-purge package"
122+ fi
123+
124+ dpkg --get-selections | awk '/install$/{print $1}' |
125+ sort | comm -12 - $PPA_PKGS > $REVERTS
126+
127+ # Create apt argument list for reverting packages
128+ REINSTALL=""
129+ for PACKAGE in $(cat $REVERTS); do
130+ REINSTALL="$REINSTALL $PACKAGE/$DIST"
131+ done
132+
133+ msg "Package revert list generated:"
134+ msg "$REINSTALL"
135+ echo
136+fi
137
138 # Disable PPA from sources.list files
139 for LIST in $(find /etc/apt/ -name "*.list" -exec readlink -f '{}' \;); do
140@@ -161,7 +164,7 @@
141 elif $APTALT $APTARG install $REINSTALL; then
142 msg "PPA purged successfully using $APTALT fallback"
143 else
144- warn "Something went wrong, packages may not have been reverted"
145- exit 1
146+ err "Something went wrong, packages may not have been reverted"
147 fi
148+
149 exit 0

Subscribers

People subscribed via source and target branches

to all changes: