Merge lp:~salgado/linaro-image-tools/fix-duplicate-apt-source-detection into lp:linaro-image-tools/11.11

Proposed by Guilherme Salgado
Status: Merged
Approved by: James Westby
Approved revision: 94
Merged at revision: 94
Proposed branch: lp:~salgado/linaro-image-tools/fix-duplicate-apt-source-detection
Merge into: lp:linaro-image-tools/11.11
Diff against target: 29 lines (+11/-6)
1 file modified
linaro-hwpack-install (+11/-6)
To merge this branch: bzr merge lp:~salgado/linaro-image-tools/fix-duplicate-apt-source-detection
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+35676@code.launchpad.net

Description of the change

Make sure we don't add duplicate apt sources when installing a hardware pack

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Looks good.

Thanks,

James

review: Approve
Revision history for this message
Loïc Minier (lool) wrote :

Consider passing -F to grep to not interpret lines as regexps but as fixed strings.

I suspect this matches commented-out lines too.

Revision history for this message
Guilherme Salgado (salgado) wrote :

On Fri, 2010-09-17 at 20:14 +0000, Loïc Minier wrote:
> Consider passing -F to grep to not interpret lines as regexps but as fixed strings.
>
> I suspect this matches commented-out lines too.

Good catches. I've done both changes, thanks!

95. By Guilherme Salgado

Ignore empty/commented lines when comparing a hwpack's apt sources with the system ones

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'linaro-hwpack-install'
2--- linaro-hwpack-install 2010-09-14 17:50:19 +0000
3+++ linaro-hwpack-install 2010-09-20 16:11:04 +0000
4@@ -83,14 +83,19 @@
5 # Install the apt sources that contain the packages we need.
6 for filename in $(ls "${HWPACK_DIR}"/sources.list.d/); do
7 file="${HWPACK_DIR}"/sources.list.d/$filename
8+ should_install=0
9+ stripped_file=${TEMP_DIR}/$filename
10+ grep -v "\(^#\|^\s*$\)" $file > $stripped_file
11 while read line; do
12- # Skip any files that contain lines that are already present in the apt
13- # configuration.
14- grep -q "$line" /etc/apt/sources.list.d/* && continue
15- grep -q "$line" /etc/apt/sources.list && continue
16- done < $file
17+ # Only install files that have at least one line not present in the
18+ # existing sources lists.
19+ grep -qF "$line" /etc/apt/sources.list.d/* /etc/apt/sources.list \
20+ || should_install=1
21+ done < $stripped_file
22
23- sudo cp $file /etc/apt/sources.list.d/hwpack.$filename
24+ if [ $should_install -eq 1 ]; then
25+ sudo cp $file /etc/apt/sources.list.d/hwpack.$filename
26+ fi
27 done
28
29 # Import the OpenPGP keys for the files installed above.

Subscribers

People subscribed via source and target branches