Since apt is a front end for dpkg, I wonder if using dpkg itself might work better.
I have started the remastering process working off the 5.3.1 DVD release. I know the packages I want to remove and have compiled them into a text file.
I thought I would just make a simple bash script to remove them, but it always aborts after a few minutes with no real info as to why.
Here is what I have:
#!/bin/bash
apt-get --force-yes --purge remove packagename
If I run each command it works, but not in the script
I have also tried:
cat filewithnames.txt | xargs apt-get --force-yes --purge remove
This ends with the following: "Do you want to continue? Y/n Abort"
Same issue.
For the record, there are approx. 2500 packages that I want to remove. Is there a hard limit?
Since apt is a front end for dpkg, I wonder if using dpkg itself might work better.
If I script like so:
#!/bin/bash
dpkg -r packname
and so on
It just throws bad interpeter errors
When you run the script
#!/bin/bash
apt-get --force-yes --purge remove packagename
What exactly is the message that you get? I don't remember whether apt-get requires confirmation in this syntax. If it does you may have to redirect standard input to the script itself for each invocation and provide the yes/no response there.
cmd << text
The contents of the shell script up to a line identical to text become the standard input for cmd.

Intel i7-8700 Coffee Lake 3.2GHz 6-Core Max Turbo 4.6GHz Processor
$69.99
Intel Core i7-9700 3.00 GHz LGA 1151 Desktop CPU Processor SRG13
$79.99
Corsair RM750e 750W Fully Modular 80 Plus Gold ATX 3.1 PSU Certified Refurbished
$44.99
COMBO: ASUS Prime H370M-PLUS MOTHERBOARD + i5-9400F CPU /w Heatsink + 16GB DDR4
$169.95
Intel Core i9-9900 | SRG18 | 3.10 GHz | 8 Cores | LOT OF 10
$1505.77
Intel Core i7-7700T 2.9GHz 8MB Socket LGA1151 Quad Core Processor SR339
$39.99
Intel Core i7-9700K Octa-Core 3.6 GHz Desktop CPU
$99.99
Intel 4th Gen Core i7-4790 SR1QF 3.60GHz (Turbo 4.00GHz) 8M 4-Core LGA-1150 CPU
$39.99
Intel Core i5-11500 2.70 GHz LGA 1200 Desktop CPU Processor SRKNY
$94.99
PS5 Over Heating Problem Solver 1.5 Grams Liquid metal thermal paste CPU, GPU
$15.99