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. :)

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

  1. Dan Langille Says:

    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. Dan Langille Says:

    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. Dan Langille Says:

    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. Dan Langille Says:

    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. Dan Langille Says:

    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

  6. Dan Langille Says:

    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';
    
  7. Dan Langille Says:

    Last night, I realized the website already has this functionality. Here are all the ports which depend upon archivers/zip:

    http://www.freshports.org/search.php?stype=depends_all&method=match&query=archivers%2Fzip&num=100&orderby=category&orderbyupdown=asc&search=Search

  8. Dan Langille Says:

    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. Dan Langille Says:

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

  10. Dan Langille Says:

    We also have: PATCH_DEPENDS FETCH_DEPENDS and EXTRACT_DEPENDS.

    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. Dan Langille Says:

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

Leave a Reply

Bot-Check