What's the best way to auto clean distfiles after using make/portupgrade in FreeBSD?

1,084

Solution 1

There's more than one way to do it:

  • set DISTDIR in make.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/*
Share:
1,084

Related videos on Youtube

ThomasWest
Author by

ThomasWest

Updated on September 18, 2022

Comments

  • ThomasWest
    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 with test_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
      chux - Reinstate Monica over 7 years
      Look at memcmp().
    • ThomasWest
      ThomasWest over 7 years
      @chux it didn't work. I tried it and it didn't stop at test_5. I intentionally fill test_5 exactly the same with test_1.
    • chux - Reinstate Monica
      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
      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
      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
      MayurK over 7 years
      @ThomasWest: It is nothing to do with memcmp(). Looks like your logic is wrong somewhere. Share your code.
    • ThomasWest
      ThomasWest over 7 years
      @MayurK sure, there you go.
    • MayurK
      MayurK over 7 years
      Not memcpy() . You should use memcmp().
  • D_Bye
    D_Bye almost 12 years
    Bear 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
    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
    D_Bye almost 12 years
    Yes, 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
    ThomasWest over 7 years
    Can you elaborate more? Btw, test_1[0] contains "2e" and test_1[1] contains "g7"
  • ThomasWest
    ThomasWest over 7 years
    Sorry. It was a bad example. My code showed like "2e a1 3e". My examples were too random.
  • Matthieu
    Matthieu over 7 years
    Hope you understand how to use the 2D arrays, I think that's the main thing you are missing...
  • Junho Cha
    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/>