What's the best way to auto clean distfiles after using make/portupgrade in FreeBSD?
Solution 1
There's more than one way to do it:
- set
DISTDIR
inmake.conf
to/tmp/distfiles
, or symlink/usr/ports/distfiles
to/tmp/distfiles
./tmp
will be cleared on the next reboot. - add this job to /etc/crontab:
@reboot root rm -rf /usr/ports/distfiles/*
Solution 2
Sequentially:
portmaster --check-depends
portmaster --check-port-dbdir
portmaster -s
portmaster -y --clean-distfiles
Solution 3
How can I configure FreeBSD to clean distfiles after installing a port (using make, portupgrade, etc)?
If "after installing a port", just use the distclean target:
make install distclean
This will clean the work directory and the distfile after installing.
If you want to clean distfiles separately from installation, just run
rm -rf /usr/ports/distfiles/*
Related videos on Youtube
![ThomasWest](https://i.stack.imgur.com/R19gy.jpg?s=256&g=1)
ThomasWest
Updated on September 18, 2022Comments
-
ThomasWest almost 2 years
I have 2 character arrays:
unsigned char test_1[2] and unsigned char test_2[2]
Both of them have hex value in it. So if I do for loop like:
for (i=0; i<sizeof(test_1); i++) printf("%02x\n", test_1[i]) and for (i=0; i<sizeof(test_2); i++) printf("%02x\n", test_2[i])
It will print something like:
2e 50 and a1 3e
My question is, how do I compare these two char arrays? I have numerous character arrays like
test_3, test_4, ...., test_n
to be compared withtest_1
.I used
strcmp()
and it failed because they are not a string.****** update *******
code logic:
while(memcmp(test_1, test_n,2) != 0){ // grab the next test_n char array (test_2, test_3, ....) // set test_n to have same value as the next test_n } printf("Stop the search, I found it!"\n);
-
chux - Reinstate Monica over 7 yearsLook at
memcmp()
. -
ThomasWest over 7 years@chux it didn't work. I tried it and it didn't stop at
test_5
. I intentionally filltest_5
exactly the same withtest_1
. -
chux - Reinstate Monica over 7 years"it didn't work" is not a clear explanation of what was tried nor of the result versus expected results.
-
ThomasWest over 7 years@chux
test_1[0] and test_1[1]
values are 2e and g7. This is also the same as test_5[0] and test_5[1] because I want my loop to say 'Hey stop! I found the one'. However, what just happened was it keep comparing with test_6, test_7, .... -
MayurK over 7 years@ThomasWest: memcmp() should work if your intention is just comparision. Check if you are correctly using memcmp() - tutorialspoint.com/c_standard_library/c_function_memcmp.htm
-
MayurK over 7 years@ThomasWest: It is nothing to do with memcmp(). Looks like your logic is wrong somewhere. Share your code.
-
ThomasWest over 7 years@MayurK sure, there you go.
-
MayurK over 7 yearsNot memcpy() . You should use memcmp().
-
-
D_Bye almost 12 yearsBear in mind that /tmp is often a small file system, and some distfiles can be quite big, so don't be surprised if a port build fails with a "file system full" error during the fetch stage, if you adopt this approach. If you want the distfiles to be deleted automatically, you can script one of the other suggested approaches. An @boot system cronjob, for example, could be set up to carry out the steps in one of the other answers at startup.
-
Eugene Yarmash almost 12 years@D_Bye: I guess you meant @reboot. As for the separate
/tmp
partition, I doubt it is needed for my vm at all. -
D_Bye almost 12 yearsYes, I meant @reboot - sorry about the typo. If you're not using a separate
/tmp
, then my comment doesn't really apply. It's still something to be aware of, I think. I haven't done a fresh install of FreeBSD for a while (I do source upgrades in-place) so I don't know what the default layout is like these days, so it could well be a single partition, in which case this point is moot. -
ThomasWest over 7 yearsCan you elaborate more? Btw, test_1[0] contains "2e" and test_1[1] contains "g7"
-
ThomasWest over 7 yearsSorry. It was a bad example. My code showed like "2e a1 3e". My examples were too random.
-
Matthieu over 7 yearsHope you understand how to use the 2D arrays, I think that's the main thing you are missing...
-
Junho Cha over 7 years"2e" or "g7" seems like two characters but if using wide_char(wchar_t), "2e" seems a single character. <br/>What I say is 'using wide character sliding comapring". <br/>