LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-05-2011, 02:03 AM   #1
spidernik84
LQ Newbie
 
Registered: Mar 2004
Distribution: Archlinux
Posts: 18

Rep: Reputation: 0
Force apt-get to redownload and reinstall dependencies as well


Hello everybody,
I'm working on a script called "populator". This script will be run on a linux box with the single purpose to download a set of packages (i.e. "ubuntu-desktop" metapackage) to trigger the caching by a deb-proxy.
The reason is to pre-cache the proxy in advance, thus reducing the amount of time to install the first production Linux box, not necessarily going to be installed immediately after deb-proxy deployment.

As for now, the script is extremely rough and simple:
1. clean the apt-get cache
2. run apt-get install with specified parameters to force reinstall, download only, output urls
3. pass the url list to wget and throw everything in /dev/null

with the specified parameters the script does the job. The only problem regards dependency handling: they are downloaded just the first time, even after apt-cache clean. I need apt-get to re-download dependencies as well. THIS is the real need.

Script follows:

Code:
#!/bin/bash
#
# Script to pre-populate apt-get proxy for faster later downloads.
# It uses apt-get and wget to pull all the specified packages.
#

# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
   echo "You're not root, are you?" 1>&2
   exit 1
fi

PKGLIST="exaile" # specify needed packages

apt-get clean -qq 	# cache should be cleaned first to force package download even if already installed, else they will be ignored
apt-get update -qq	# apt-get update should be run first for up-to-date cache and thus packages
apt-get install --reinstall -d --print-uris --yes  $PKGLIST | grep ^\' | cut -d \' -f2 > output.txt # force apt-get to reinstall (and thus redownload) selected packages and send readable urls to temp file for later processing
wget --quiet -i output.txt --directory-prefix /dev/null	# download debs from url list and send files to bit-bucket (we don't need them)

rm output.txt	# spring cleanings
Thank you!
 
Old 04-06-2011, 10:57 AM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
I would do it like that:
1. Save the list of installed packages:
Code:
dpkg --get-selections > packages
2. Clear all selected packages:
Code:
dpkg --clear-selections
3. Now do your downloading of your packages.
4. Restore the list of installed packages:
Code:
dpkg --set-selections < packages
5. Do your clean up stuff.
 
1 members found this post helpful.
Old 04-06-2011, 11:23 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
... Also : There is at least one "reinstall command" :

apt-get install --force-reinstall true <package> <package> <package> <package> <package>
 
Old 04-06-2011, 01:22 PM   #4
spidernik84
LQ Newbie
 
Registered: Mar 2004
Distribution: Archlinux
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by TobiSGD View Post
I would do it like that:
1. Save the list of installed packages:
Code:
dpkg --get-selections > packages
2. Clear all selected packages:
Code:
dpkg --clear-selections
3. Now do your downloading of your packages.
4. Restore the list of installed packages:
Code:
dpkg --set-selections < packages
5. Do your clean up stuff.
Hi, thanks for the answer.

I tried doing what you suggested, like this:

1. dpkg --get-selections > packages
2. dpkg --clear-selections
3. apt-get clean
4. apt-get install --reinstall -d --print-uris --yes pidgin

At this point, apt-get should re-download and reinstall pidgin AND all its dependencies. It does not, it redownloads pidgin .deb only! Where am I wrong?

@knudfl: the force reinstall does not re-download the dependencies
 
Old 04-07-2011, 09:09 AM   #5
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Sorry, my failure, this will not work the way you want with --clear-selections, I had confused that. If you issue an
Code:
apt-get deselect-upgrade
after the dpkg --clear-selections, all non-essential packages will be uninstalled. If you now continue with the --set-selections part and also issue
Code:
apt-get deselect-upgrade
, all packages that were previously installed will be reinstalled.
May be that helps you, a better solution doesn't come to my mind currently.
 
  


Reply

Tags
apt-get, wget



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
apt-get has unmet dependencies, but apt-get -f install doesn't solve problem sophanox Linux - Software 1 02-23-2011 10:07 AM
Howabout apt-get update ; apt-get upgrade -f -y --force-yes in the crontab every week frenchn00b Debian 1 04-05-2008 07:47 AM
reinstall to fix dependencies? ekdya Debian 1 10-17-2005 08:50 AM
Force RPM reinstall stefaandk Linux - Newbie 2 06-20-2005 10:30 PM
urpmi force reinstall/overwrite ryedunn Mandriva 1 01-28-2005 01:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration