Patch: Cache setup.ini for a day before redownloading

24 views
Skip to first unread message

eddieparker

unread,
Aug 23, 2010, 6:31:32 PM8/23/10
to apt-cyg-discuss
Hello:

Love your work on apt-cyg, but thought I'd submit a patch.

I've set it up locally so that apt-cyg only downloads setup.ini once
per day, instead of every time it's invoked - helps a lot in things
like 'apt-cyg find' or base installs. Hopefully this is integration
worthy.

Here it is in all it's glory:

--- /home/edparker/src/apt-cyg 2010-08-23 15:21:44.450176300 -0700
+++ /bin/apt-cyg 2010-08-23 15:27:28.624094300 -0700
@@ -1,4 +1,3 @@
-
#!/bin/bash

# apt-cyg: install tool for cygwin similar to debian apt-get
@@ -91,24 +90,26 @@

function getsetup()
{
- if test "$noscripts" == "0" -a "$noupdate" == "0"
- then
- touch setup.ini
- mv setup.ini setup.ini-save
- wget -N $mirror/setup.bz2
- if test -e setup.bz2 && test $? -eq 0
- then
- bunzip2 setup.bz2
- mv setup setup.ini
- echo Updated setup.ini
- else
- wget -N $mirror/setup.ini
- if test -e setup.ini && test $? -eq 0
+ if [ ! -f setup.ini -o $(( $(date +%s -r setup.ini) + 86400 )) -lt $
(date +%s) ]; then
+ if test "$noscripts" == "0" -a "$noupdate" == "0"
+ then
+ touch setup.ini
+ mv setup.ini setup.ini-save
+ wget -N $mirror/setup.bz2
+ if test -e setup.bz2 && test $? -eq 0
then
+ bunzip2 setup.bz2
+ mv setup setup.ini
echo Updated setup.ini
else
- mv setup.ini-save setup.ini
- echo Error updating setup.ini, reverting
+ wget -N $mirror/setup.ini
+ if test -e setup.ini && test $? -eq 0
+ then
+ echo Updated setup.ini
+ else
+ mv setup.ini-save setup.ini
+ echo Error updating setup.ini, reverting
+ fi
fi
fi
fi
@@ -469,3 +470,4 @@

esac

+


I'm hoping that one day I'll get around to my next patch, but in case
someone's interested, I'd love to see apt-cyg install in order from
lowest dependency all the way to the top. I've had a couple of
installs get interrupted and then I have to uninstall and reinstall
the topmost package. Would be nice if I didn't have to worry. :)

Cheers!

-e-
Reply all
Reply to author
Forward
0 new messages