Feb 052011

An interesting discussion started earlier this week: upstream dependents.

At present, FreshPorts captures and displays the information output from:


For a given port, this tells up what that port depends upon for building, running, and libraries.

The request is for this same information, but in the reverse ordering; what ports depend upon this port.

So far, I think we have a simple solution. A new table:

create table port_dependencies
    port_id                    integer               not null,
    port_id_dependent_upon     integer               not null,
    dependency_type            char(1)               not null,
    primary key (port_id, port_id_dependent_upon, dependency_type)

alter table port_dependencies
    add foreign key  (port_id)
       references ports (id) on update cascade on delete cascade;

alter table port_dependencies
    add foreign key  (port_id_dependent_upon)
       references ports (id) on update cascade on delete cascade;

It’s still early in the day, and I’ve not had breakfast. Thus, I think it’s a good idea for you to provide feedback on this. :)

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

  11 Responses to “What ports are dependant upon this port?”

  1. I’ve decided to start with a populated table and go from from there.

    Here we have ports and their ID

    22514 libwps

    482 libtool

    2763 doxygen

    And some output:

    INSERT INTO port_dependencies (port_id, port_id_dependent_upon, dependency_type)
    VALUES (22514, 482, ‘B’);

    INSERT INTO port_dependencies (port_id, port_id_dependent_upon, dependency_type)
    VALUES (22514, 2763, ‘B’);

    And we’ll go from there. My first goal will be writing the code to display this information on the webpages.

  2. This is the query I’ll need for displaying details on the webpage:

      SELECT port_id,
             categories.name    as category,
             element.name       as port
        FROM port_dependencies
             LEFT OUTER JOIN ports      ON ports.id         = port_dependencies.port_id_dependent_upon
             LEFT OUTER JOIN categories ON categories.id    = ports.category_id
             LEFT OUTER JOIN element    ON ports.element_id = element.id
       WHERE port_id = 22514
  3. We now have proof of concept at http://dev.freshports.org/textproc/libwps/

    Now for the big work: populating and maintaining the new table.

  4. This may be useful when I come to process the depends:

    <aDe> my @shizzle = map { s/^.*\/usr\/ports\///;$_ } split(/ /, $string);
    <aDe> print join(' - ', @shizzle) . "\n";
    <aDe> [ade@lab:~] 179% ./x
    <aDe> security/fpc-hash - archivers/fpc-paszlib - devel/fpc-pthread
  5. Initial testing with Ade’s code on a recent lang/gcc45/ commit.

    The B depends are
    archivers/zip – devel/gmake – devel/binutils – devel/bison – lang/perl5.8

    The R depends are

    The L depends are
    math/gmp – math/mpfr – math/mpc – converters/libiconv

  6. We now have a great little stored procedure:

    SELECT PortsDependenciesAdd (‘lang/gcc45’, ‘lang/perl5.8’, ‘B’);

    Which looks like this:

    CREATE OR REPLACE FUNCTION PortsDependenciesAdd (text, text, text) returns
    int AS $$
        p_PortName              ALIAS FOR $1;
        p_PortNameDependentUpon ALIAS FOR $2;
        p_DependencyType        ALIAS FOR $3;
        l_PortID           int;
        l_PortIDDependency int;
        OID                int8;
        select GetPort(p_PortName)
          INTO l_PortID;
        select GetPort(p_PortNameDependentUpon)
          INTO l_PortIDDependency;
        if l_PortID IS NOT NULL AND l_PortIDDependency IS NOT NULL then
          INSERT INTO port_dependencies (port_id, port_id_dependent_upon, dependency_type)
                VALUES (l_PortID, l_PortIDDependency, p_DependencyType);
          RETURN 1;
          if l_PortID IS NULL then
            RAISE EXCEPTION 'cannot find this port: %', p_PortName;
          end if;
          if l_PortIDDependency IS NULL then
            RAISE EXCEPTION 'cannot find this port: %', p_PortNameDependentUpon;
          end if;
        end if;
        RETURN 0;
    $$  LANGUAGE 'plpgsql';
  7. Last night, I realized the website already has this functionality. Here are all the ports which depend upon archivers/zip:


  8. I am now running the upgrade script on http://beta.freshports.org… then I’ll let that site run for a while with the new code before moving over to production.

  9. It appears we have created some monsters. Look at the size of this page:


    Thanks for bf for pointing this out. I shall leave this for another weekend. It should be trivial to add in. It’s just code. No database changes.

  11. dougb just mentioned: make run-depends-list and make build-depends-lis