Hold/release packages using dpgk (Solved)

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
viking777

Hold/release packages using dpgk (Solved)

Post by viking777 »

I suppose that most of you that use the command line for updates will probably also use the following format to hold/release packages:

Code: Select all

echo libenchant1c2a hold | dpkg --set-selections

echo  libenchant1c2a install | dpkg --set-selections
What I want to know is, is there a way to alter the status of several packages at once?

I tried it with brace expansion eg:

Code: Select all

echo  {libenchant1c2a, xserver-xorg-core, xserver-common, xnest} install | dpkg --set-selections
But all I got was errors, which presumably means that is not the way to do it. (and btw. since I am not sure which is correct, I have tried commas without spaces, spaces without commas and spaces with commas inside the curly brackets, and none of them work).

So is there a way to achieve this? (and I don't mean using synaptic or aptitude or dselect or anything like that, I mean using dpkg).
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: Hold/release packages using dpgk

Post by xenopeek »

The { } expansion isn't doing anything. You could do this with a for loop:

Code: Select all

for p in libenchant1c2a xserver-xorg-core xserver-common xnest; do echo $p install | dpkg --set-selections; done
Image
viking777

Re: Hold/release packages using dpgk

Post by viking777 »

Wow! That is heavy! I don't know how long it is going to take me to work out what that means, but I am sure going to try.

Thanks very much Vincent. :D
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: Hold/release packages using dpgk

Post by xenopeek »

Okay, well broken down to more readable, perhaps that helps :wink:

Code: Select all

for package_name in libenchant1c2a xserver-xorg-core xserver-common xnest
do
	echo $package_name install | dpkg --set-selections
done
Image
viking777

Re: Hold/release packages using dpgk

Post by viking777 »

xenopeek wrote:Okay, well broken down to more readable, perhaps that helps :wink:

Code: Select all

for package_name in libenchant1c2a xserver-xorg-core xserver-common xnest
do
	echo $package_name install | dpkg --set-selections
done
Ah I see! it was the 'p' that got me before. I thought that 'for' was a command and 'p' was an argument. That might explain why my search for 'man for' brought no results.

As you perhaps can see I was brought up entirely on the gui and although I see a lot of good stuff in the cli I still have difficulties with it - the most significant of which is remembering it all, so I will dutifully write down your excellent command there and then my only difficulty then will be remembering where I wrote it :lol:
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: Hold/release packages using dpgk

Post by xenopeek »

:lol: Well, I keep a "cheat sheet" of useful pieces of BASH code around :wink:

A useful guide is the Bash Guide for Beginners. Linking directly to the for loop: http://tldp.org/LDP/Bash-Beginners-Guid ... sect_09_01. From time to time this guide has really helped me with some useful examples.
Image
viking777

Re: Hold/release packages using dpgk

Post by viking777 »

Well, I keep a "cheat sheet" of useful pieces of BASH code around
Oh me to. Trouble is it is getting so large now it is a bit difficult to find anything in it - even the electronic version with a search facility! (and it certainly didn't include the piece of code you gave me in this thread - but it does now).

Time to mark this solved I think.
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: Hold/release packages using dpgk (Solved)

Post by xenopeek »

Alright, sudo apt-get mark solved . . . wait, that isn't a command? Yeah, there is too much even with a cheat sheet :wink:
Image
Locked

Return to “Scripts & Bash”