that old INDEX file

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

that old INDEX file

Marc Espie-2
Now might be the time to retire it, specifically
because it's almost always outdated.

The idea is that sqlports can generate something
very close, not quite identical because of some
insanity, but I have some sqlite3 script that does
the trick.

So, probably store the result in the portslist
subpackage, so that you don't need any sqlite parts
to use it, and have the actual generating script
(along with some other scripts) in sqlports (or
sqlports-compact) proper.

Right now I have some shell that creates
almost the same thing..

e.g.,

#! /bin/sh
{
echo 'select fullpkgname,fullpkgpath,'
echo '(case prefix when "/usr/local" THEN "" else prefix end),'
echo 'comment,descr,maintainer,categories,'
echo 'lib_depends,build_depends,run_depends,'
echo '(case 1 when fullpkgpath in (select fullpkgpath from onlyforarch) then only_for_archs else (case 1 when fullpkgpath in (select fullpkgpath from notforarch) then "!"||not_for_archs else "any" end) end),'
echo '(case lower(PERMIT_PACKAGE_CDROM) when "yes" then "y" else "n" end),'
echo '(case lower(PERMIT_PACKAGE_FTP) when "yes" then "y" else "n" end),'
echo '(case lower(PERMIT_DISTFILES_FTP) when "yes" then "y" else "n" end)'
echo ' from ports where fullpkgpath in (select distinct canonical from paths) order by fullpkgpath'; } \
|sqlite3 /usr/local/share/sqlports

main differences:
- full set of pkgpaths from the ports tree, not just what's in subdir
- depends are not sorted and not stripped of :patch/:configure

apart from that it's pretty close...


(this is a proof of concept, it probably ought to be based on sqlports-compact
but it's not that difficult to adjust)

Reply | Threaded
Open this post in threaded view
|

Re: that old INDEX file

Kenneth R Westerback-2
On Sat, Nov 10, 2018 at 08:00:02PM +0100, Marc Espie wrote:
> Now might be the time to retire it, specifically
> because it's almost always outdated.

Removing it is probably the only I'll be motivated to
learn the sql way. :-) No objections from me.

.... Ken

>
> The idea is that sqlports can generate something
> very close, not quite identical because of some
> insanity, but I have some sqlite3 script that does
> the trick.
>
> So, probably store the result in the portslist
> subpackage, so that you don't need any sqlite parts
> to use it, and have the actual generating script
> (along with some other scripts) in sqlports (or
> sqlports-compact) proper.
>
> Right now I have some shell that creates
> almost the same thing..
>
> e.g.,
>
> #! /bin/sh
> {
> echo 'select fullpkgname,fullpkgpath,'
> echo '(case prefix when "/usr/local" THEN "" else prefix end),'
> echo 'comment,descr,maintainer,categories,'
> echo 'lib_depends,build_depends,run_depends,'
> echo '(case 1 when fullpkgpath in (select fullpkgpath from onlyforarch) then only_for_archs else (case 1 when fullpkgpath in (select fullpkgpath from notforarch) then "!"||not_for_archs else "any" end) end),'
> echo '(case lower(PERMIT_PACKAGE_CDROM) when "yes" then "y" else "n" end),'
> echo '(case lower(PERMIT_PACKAGE_FTP) when "yes" then "y" else "n" end),'
> echo '(case lower(PERMIT_DISTFILES_FTP) when "yes" then "y" else "n" end)'
> echo ' from ports where fullpkgpath in (select distinct canonical from paths) order by fullpkgpath'; } \
> |sqlite3 /usr/local/share/sqlports
>
> main differences:
> - full set of pkgpaths from the ports tree, not just what's in subdir
> - depends are not sorted and not stripped of :patch/:configure
>
> apart from that it's pretty close...
>
>
> (this is a proof of concept, it probably ought to be based on sqlports-compact
> but it's not that difficult to adjust)
>

Reply | Threaded
Open this post in threaded view
|

Re: that old INDEX file

Marc Espie-2
In reply to this post by Marc Espie-2
Here's a more elaborate version of the print-index script.

It's without doubt the longest sql query I've ever written...

This *does* give identical lines to "make INDEX" apart from the
fact that the pkgpath selection mechanism is more thorough, so it may
give you identical paths, and also it does sort things in pkgpath order
instead of respecting the multi-packages order.

... but for any consumer, it can replace the 'index' file handily.


(todo: see how my sqlports-compact file works, maybe...)

#! /bin/sh
file=/usr/local/share/sqlports
cat <<'EOSQL' |sqlite3 $file
-- in order for group_concat to sort, you must do it in two steps
create temp view d1 (d, p, t) as
    select
    distinct((case pkgspec when '' then '' else pkgspec||":" end)||dependspath) as fd,
        fullpkgpath, type
    from depends order by fd;

-- and now the view that's going to be used 3 times in the main request
create temp view d2 as
    select group_concat(d, ' ') as dlist, p, t
    from d1 group by p, t;


select fullpkgname,fullpkgpath,
    (case prefix when '/usr/local' THEN "" else prefix end),
    comment,descr,maintainer,categories,
    libd.dlist, buildd.dlist, rund.dlist,

    (case 1 when fullpkgpath in
-- thankful for for 2ndary tables, because onlyforarch has a weird value
-- when !defined, that cannot be tested for
        (select fullpkgpath from onlyforarch)
        then only_for_archs
        else (case 1 when fullpkgpath in
            (select fullpkgpath from notforarch)
            then "!"||not_for_archs
            else "any"
        end)
    end),

    (case lower(PERMIT_PACKAGE_CDROM) when "yes" then "y" else "n" end),
    (case lower(PERMIT_PACKAGE_FTP) when "yes" then "y" else "n" end),
    (case lower(PERMIT_DISTFILES_FTP) when "yes" then "y" else "n" end)
    from ports
-- yep this has to be selects, can't be where, because left join!
    left join (select * from d2 where d2.t='L') as libd on libd.p=fullpkgpath
    left join (select * from d2 where d2.t='B') as buildd on buildd.p=fullpkgpath
    left join (select * from d2 where d2.t='R') as rund on rund.p=fullpkgpath
      where fullpkgpath in (select distinct canonical from paths)
        order by fullpkgpath
EOSQL