Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Gentoo Question
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Newbie
Guest





PostPosted: Tue Jul 09, 2002 12:11 am    Post subject: Gentoo Question Reply with quote

What is that .keep file that shows up everywhere?
Back to top
delta407
Bodhisattva
Bodhisattva


Joined: 23 Apr 2002
Posts: 2876
Location: Chicago, IL

PostPosted: Tue Jul 09, 2002 12:13 am    Post subject: Reply with quote

It's a zero-byte file that forces tar to make an otherwise empty directory. If a directory is empty, tar will ignore it, and it won't get created; hence, .keep.

You can delete them if you like.
_________________
I don't believe in witty sigs.
Back to top
View user's profile Send private message
xorbe
n00b
n00b


Joined: 19 Jul 2002
Posts: 46
Location: near San Jose, CA

PostPosted: Sat Jul 20, 2002 4:33 pm    Post subject: Reply with quote

delta407 wrote:
It's a zero-byte file that forces tar to make an otherwise empty directory. If a directory is empty, tar will ignore it, and it won't get created; hence, .keep.

You can delete them if you like.


I just made a bunch of empty folders, and tar cvf and tar xvf saved and restored them just fine...
so the .keep files don't really help here. Try it. Your explanation of tar just doesn't hold!
Back to top
View user's profile Send private message
fghellar
Bodhisattva
Bodhisattva


Joined: 10 Apr 2002
Posts: 856
Location: Porto Alegre, BR

PostPosted: Sat Jul 20, 2002 5:14 pm    Post subject: Reply with quote

The .keep files are there to prevent portage from deleting important directories when you unmerge something that would cause those directories to be empty.
_________________
| www.gentoo.org | www.tldp.org | www.google.com |
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 16106
Location: Colorado

PostPosted: Thu Apr 10, 2003 4:39 am    Post subject: Reply with quote

Some answers from other threads:
rac wrote:
They prevent emerge's autoclean option (which is enabled by default) from removing certain directories, even if they are empty. They are created by /usr/lib/portage/bin/ebuild.sh, which is part of portage, when a "keepdir" directive is included in an ebuild.

jukka wrote:
if you remove a software package from your system (emerge -C ...), it's possible that you remove all files from a directory. in such a situation that directory is removed.
to prevent directories from beeing removed there are those "hidden" .keep files (hidden because they don't match e.g. a 'rm -f *'). they were created when you installed your system. additionally, some ebuild create such files.

_________________
lolgov. 'cause where we're going, you don't have civil liberties.

In Loving Memory
1787 - 2008
Back to top
View user's profile Send private message
dwyrm
n00b
n00b


Joined: 13 Dec 2003
Posts: 19

PostPosted: Sun Dec 28, 2003 9:16 am    Post subject: "empty" .keep files Reply with quote

Are they supposed to be empty? I stumbled across one that actually contained some data.
Back to top
View user's profile Send private message
orionrobots
Apprentice
Apprentice


Joined: 07 Oct 2003
Posts: 289
Location: London, Uk

PostPosted: Tue Dec 30, 2003 1:56 pm    Post subject: Re: "empty" .keep files Reply with quote

I suspect that the .keep file will be present with keepdirs even when there are non-empty folders. Simply because unmerging the one package may remove an empty folder, which although now empty is still needed by another installed package.

dwyrm wrote:
Are they supposed to be empty? I stumbled across one that actually contained some data.
Back to top
View user's profile Send private message
dwyrm
n00b
n00b


Joined: 13 Dec 2003
Posts: 19

PostPosted: Tue Dec 30, 2003 5:28 pm    Post subject: communication error Reply with quote

I meant that the .keep file itself had some data in it. Looked like random binary garbage, but since I don't know quite how it got there, I left it.
Back to top
View user's profile Send private message
tomk
Administrator
Administrator


Joined: 23 Sep 2003
Posts: 7219
Location: Sat in front of my computer

PostPosted: Wed Dec 31, 2003 2:16 am    Post subject: Reply with quote

All the .keep files I've seen have been empty, but I guess it doesn't matter as either way the file exists.
_________________
Search | Read | Answer | Report | Strip
Back to top
View user's profile Send private message
dwyrm
n00b
n00b


Joined: 13 Dec 2003
Posts: 19

PostPosted: Wed Dec 31, 2003 4:28 am    Post subject: it bugs me anyway Reply with quote

tomk wrote:
...it doesn't matter as either way the file exists.

True, the .keep file will fill its function whether it's empty or it contains the entire works of Shakespere in the original Klingon. I just want to know whether something is using the .keep file in question for, perhaps, metadata, or if it's just some random fluke. I obviously don't care enough to troubleshoot it, but still...
Back to top
View user's profile Send private message
orionrobots
Apprentice
Apprentice


Joined: 07 Oct 2003
Posts: 289
Location: London, Uk

PostPosted: Wed Dec 31, 2003 4:37 pm    Post subject: Re: it bugs me anyway Reply with quote

You could always try and use a sacrificial installation of some package to find out- and let us know what happened.. Do something sensible like hide the original .keep under temp, with its full path as underscores or something... Then add a new zero length .keep file in its place... Then try do an emerge -u or something that would definately affect some files in the given folder...

And before I forget - post the results here...

dwyrm wrote:
I just want to know whether something is using the .keep file in question for, perhaps, metadata, or if it's just some random fluke. I obviously don't care enough to troubleshoot it, but still...
Back to top
View user's profile Send private message
linux_girl
Apprentice
Apprentice


Joined: 12 Sep 2003
Posts: 283

PostPosted: Thu Jan 01, 2004 5:30 pm    Post subject: Reply with quote

.keep seem to be kernel stuff for fs . or to marke deadenddirs or sometin

or maybe its a tar trick to be able to creat dirs even empty one

eg:
/boot/.keep
_________________
:D :D


Last edited by linux_girl on Tue Jun 29, 2004 11:42 pm; edited 1 time in total
Back to top
View user's profile Send private message
kezzla
Apprentice
Apprentice


Joined: 21 Aug 2003
Posts: 253
Location: Austin, TX

PostPosted: Wed May 05, 2004 12:45 am    Post subject: Reply with quote

.keep = tehsuX

# cat /usr/local/bin/rmkeep
#!/bin/bash
for i in `find / -name .keep`; do rm $i; done
Back to top
View user's profile Send private message
linux_girl
Apprentice
Apprentice


Joined: 12 Sep 2003
Posts: 283

PostPosted: Wed May 05, 2004 12:51 am    Post subject: Reply with quote

kezzla wrote:
.keep = tehsuX

# cat /usr/local/bin/rmkeep
#!/bin/bash
for i in `find / -name .keep`; do rm $i; done


i think it was in portage setup tarball to make sure tar extract some empty dir. not sure how tar handle empty dir
_________________
:D :D
Back to top
View user's profile Send private message
teknomage1
Veteran
Veteran


Joined: 05 Aug 2003
Posts: 1239
Location: Los Angeles, CA

PostPosted: Wed May 05, 2004 12:51 am    Post subject: Reply with quote

What's the point of nuking a 0 byte file?
Back to top
View user's profile Send private message
kezzla
Apprentice
Apprentice


Joined: 21 Aug 2003
Posts: 253
Location: Austin, TX

PostPosted: Wed May 05, 2004 1:29 am    Post subject: Reply with quote

So I don't have to see junk files all over my filesystem !
:twisted:
Back to top
View user's profile Send private message
sn4ip3r
Guru
Guru


Joined: 14 Dec 2002
Posts: 325
Location: Tallinn, Estonia

PostPosted: Wed May 05, 2004 1:46 am    Post subject: Reply with quote

kezzla wrote:
So I don't have to see junk files all over my filesystem !
:twisted:


Removing .keep files will make "qpkg -c" report them as missing, thus removing junk from the filesystem will create more junk in other places:P
Back to top
View user's profile Send private message
teknomage1
Veteran
Veteran


Joined: 05 Aug 2003
Posts: 1239
Location: Los Angeles, CA

PostPosted: Wed May 05, 2004 2:03 am    Post subject: Reply with quote

don't use ls -a and they won't show up
Back to top
View user's profile Send private message
kezzla
Apprentice
Apprentice


Joined: 21 Aug 2003
Posts: 253
Location: Austin, TX

PostPosted: Wed May 05, 2004 4:18 am    Post subject: Reply with quote

Weird...I've been removing them for almost a year now via cron job that runs nightly...never had any problems ? ;-)
Back to top
View user's profile Send private message
dabicho
n00b
n00b


Joined: 28 Mar 2004
Posts: 22
Location: México

PostPosted: Wed Oct 20, 2004 4:35 pm    Post subject: Reply with quote

teknomage1 wrote:
What's the point of nuking a 0 byte file?


A 0 bytes file takes an entry in the inodes table of your file system, and also is asigned one block, whose size demends on what you set it when you created the filesystem.

i.e. my reiserfs has a blocksize of 4kb, so each .keep file takes 4kb plus an entry in the inode table.

fortunatelly enough there are not as many .keep files to worry me

locate .keep|wc -l
tells me I have 186 .keep files (might be actually more or less though, but its a fast aproximation)

So in all, its taking up less than a mb off of my ~20gb partition.

So there is not much to worry about, space wise. But if there were too many...
Back to top
View user's profile Send private message
kezzla
Apprentice
Apprentice


Joined: 21 Aug 2003
Posts: 253
Location: Austin, TX

PostPosted: Thu Oct 21, 2004 6:37 am    Post subject: Reply with quote

wow nice .. that was ridiculously thorough dabicho...thanks for the info :-)
Back to top
View user's profile Send private message
ttuttle
Tux's lil' helper
Tux's lil' helper


Joined: 03 Oct 2004
Posts: 131

PostPosted: Tue Dec 14, 2004 8:34 pm    Post subject: Reply with quote

dabicho wrote:
i.e. my reiserfs has a blocksize of 4kb, so each .keep file takes 4kb plus an entry in the inode table.


Um... unless you use "notail" in your fstab, reiserfs will pack multiple small files into one block and put tiny files in the slack space of the last block of larger files. Blocks become simply an addressing system rather than the way space is partitioned.
Back to top
View user's profile Send private message
skill
n00b
n00b


Joined: 15 Apr 2004
Posts: 9

PostPosted: Tue Dec 28, 2004 12:41 am    Post subject: Reply with quote

kezzla wrote:
Weird...I've been removing them for almost a year now via cron job that runs nightly...never had any problems ? ;-)


For those who'd like to have one of those cronjobs and do not know how, here's a simple bash script you can add to your crontab.

Code:
cd /tmp; updatedb;locate .keep > tmp_loc_file;rm `cat tmp_loc_file`;rm tmp_loc_file;


However, as said above, this is just for the ones that find these files annoying, the rest should just sit back and enjoy their coffee
Back to top
View user's profile Send private message
chemmett
n00b
n00b


Joined: 26 Dec 2004
Posts: 40
Location: Maryville, TN, USA

PostPosted: Tue Dec 28, 2004 5:28 am    Post subject: Reply with quote

FWIW, I think those are a result of the gentoo developers using CVS. Unlike tar, CVS won't save and create empty directories.
Back to top
View user's profile Send private message
dbrodie
n00b
n00b


Joined: 29 Dec 2004
Posts: 3

PostPosted: Sun Jan 02, 2005 1:11 pm    Post subject: Reply with quote

If you really want to keep them and are worried about the space, you could always hard- or soft- link all of them to a single .keep file...
Shouldn't be too difficult to do it with a simple script.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum