Hi,
I created a local mirror for testing distro using apt-mirror.
the /var/clean.sh
The problem is when I ran it again, the old packages are still there,
the /var/clean.sh didn't clean the old version !!!???
so I wrote a script to clean it, I attach my script.
I am not satisfied by my script. I sorted the package in descending order
and kept the first and deleted others. this seemed correct, unfortunately
some packages are not in the good order when the word beta is used, so it dropped the good and kept the bad.
especially when there is something like +b1_i386.deb
in
audacious-plugins_3.4.3-2+b1_i386.deb.
When there is no special character like + and extra b1, no problem, just with that name, which is I think , a temporary name.
please if anyone has a better script or idea, here are my script, I sort with python3, cause shell didn't do the task well ?? the second with awk/
## sort.py sort file in decrease order
### filename is read from the keyboard
aa=input("Give the filename to sort : ")
ff=aa.split()
for j in ff:
print (j)
for j in ff:
o=open(j, "r");
a=o.readlines()
b=sorted(a, reverse=True)
out=j+"T"
f=open(out, "w");
for i in b:
f.write(i)
f.close()
o.close()
#!/usr/bin/gawk -f
### this script keps just the first
### and deletes the others
# when the first field is the same
### the name ends by the "_"
BEGIN {
FS="_"
t1="zzzzz"
### we initialise the t1 to arbitary word not in the packages
### the file is suposed sorted in decreasing order
# see the script sort.py
}
{
if ( $1 == t1) {
print " I delete the file " $0
system("rm " $0)
}
t1=$1
}
any idea is welcome, thank a lot
best regards