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: 143 lines (+46/-35)
3 files modified
debian/changelog (+8/-0)
debian/control (+1/-1)
ppa-purge (+37/-34)
To merge this branch: bzr merge lp:~eugenesan/ppa-purge/trunk
Reviewer Review Type Date Requested Status
ppa-purge Pending
Review via email: mp+46672@code.launchpad.net

This proposal supersedes a proposal from 2011-01-18.

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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.
>

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

Hi,

I followed Tormod Volden's great suggestion and used lesspipe, now everything is working.

Also I've added "err" function, since till now we used "warn" also for fatal errors.

lp:~eugenesan/ppa-purge/trunk updated
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:17:54 +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:17:54 +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:17:54 +0000
33@@ -20,7 +20,12 @@
34 }
35
36 warn() {
37- write_msg "Warning: $*" 1>&2
38+ write_msg "Warning: $*" 1>&2
39+}
40+
41+err() {
42+ write_msg "Error: $*" 1>&2
43+ exit 1
44 }
45
46 usage() {
47@@ -61,7 +66,7 @@
48 s ) PPAHOST="$OPTARG" ;;
49 d ) DIST="$OPTARG" ;;
50 y ) FORCEINSTALL="true" ;;
51- i ) APTALT="true" ;;
52+ i ) APTALT="true" ;;
53 h ) usage 0; ;;
54 \?) usage 1; ;;
55 * ) warn "Unknown option '$opt'"; usage 1; ;;
56@@ -73,12 +78,12 @@
57 APTARG=""
58 if [ ! -z "$APTALT" ]; then
59 if [ ! -z "$FORCEINSTALL" ]; then
60- APTARG="-y"
61+ APTARG="-y"
62 fi
63 APT=aptitude; APTALT=apt-get
64 else
65 if [ ! -z "$FORCEINSTALL" ]; then
66- APTARG="-y --force-yes"
67+ APTARG="-y --force-yes"
68 fi
69 APT=apt-get; APTALT=aptitude
70 fi
71@@ -109,36 +114,34 @@
72 msg "PPA to be removed: $PPAOWNER $PPANAME"
73
74 # Make list of all packages in PPA
75-PPA_LIST=/var/lib/apt/lists/${PPAHOST}_${PPAOWNER}_${PPANAME}_*_Packages
76-for LIST in $PPA_LIST; do
77- if [ -e $LIST ]; then
78- grep "^Package: " $LIST | cut -d " " -f2 | sort >> $PPA_PKGS
79- fi
80-done
81+for LIST in /var/lib/apt/lists/${PPAHOST}_${PPAOWNER}_${PPANAME}_*_Packages* ; do
82+ lesspipe ${LIST} | grep "^Package: " | cut -d " " -f2 | sort >> $PPA_PKGS
83+done 2> /dev/null > /dev/null
84+
85+[ -z "$LIST" ] && err "Could not find packages list for PPA: $PPAOWNER $PPANAME"
86
87 if [ ! -s $PPA_PKGS ]; then
88- warn "Could not find package list for PPA: $PPAOWNER $PPANAME"
89- exit 1
90-fi
91-
92-# Ignore the ppa-purge package
93-if grep -q "ppa-purge" $PPA_PKGS; then
94- sed -i '/ppa-purge/d' $PPA_PKGS
95- msg "Note: Not removing ppa-purge package"
96-fi
97-
98-dpkg --get-selections | awk '/install$/{print $1}' |
99- sort | comm -12 - $PPA_PKGS > $REVERTS
100-
101-# Create apt argument list for reverting packages
102-REINSTALL=""
103-for PACKAGE in $(cat $REVERTS); do
104- REINSTALL="$REINSTALL $PACKAGE/$DIST"
105-done
106-
107-msg "Package revert list generated:"
108-msg "$REINSTALL"
109-echo
110+ warn "PPA: $PPAOWNER $PPANAME is empty, skipping packages treatment."
111+else
112+ # Ignore the ppa-purge package
113+ if grep -q "ppa-purge" $PPA_PKGS; then
114+ sed -i '/ppa-purge/d' $PPA_PKGS
115+ msg "Note: Not removing ppa-purge package"
116+ fi
117+
118+ dpkg --get-selections | awk '/install$/{print $1}' |
119+ sort | comm -12 - $PPA_PKGS > $REVERTS
120+
121+ # Create apt argument list for reverting packages
122+ REINSTALL=""
123+ for PACKAGE in $(cat $REVERTS); do
124+ REINSTALL="$REINSTALL $PACKAGE/$DIST"
125+ done
126+
127+ msg "Package revert list generated:"
128+ msg "$REINSTALL"
129+ echo
130+fi
131
132 # Disable PPA from sources.list files
133 for LIST in $(find /etc/apt/ -name "*.list" -exec readlink -f '{}' \;); do
134@@ -161,7 +164,7 @@
135 elif $APTALT $APTARG install $REINSTALL; then
136 msg "PPA purged successfully using $APTALT fallback"
137 else
138- warn "Something went wrong, packages may not have been reverted"
139- exit 1
140+ err "Something went wrong, packages may not have been reverted"
141 fi
142+
143 exit 0

Subscribers

People subscribed via source and target branches

to all changes: