What ports are dependant upon this port?

An interesting discussion started earlier this week: upstream dependents.

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

make -V BUILD_DEPENDS -V RUN_DEPENDS -V LIB_DEPENDS

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 thoughts on “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,
             port_id_dependent_upon,
             dependency_type,
             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. 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
    
  4. 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
    devel/binutils

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

  5. 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 $$
      DECLARE
        p_PortName              ALIAS FOR $1;
        p_PortNameDependentUpon ALIAS FOR $2;
        p_DependencyType        ALIAS FOR $3;
    
        l_PortID           int;
        l_PortIDDependency int;
        OID                int8;
    
      BEGIN
        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;
        else
          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;
      END;
    $$  LANGUAGE 'plpgsql';
    

Leave a Comment

Scroll to Top