Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Aug 2012 16:55:21 -0600
From:      John Nielsen <lists@jnielsen.net>
To:        Baptiste Daroussin <bapt@freebsd.org>
Cc:        "ports@freebsd.org" <ports@freebsd.org>, "current@freebsd.org" <current@freebsd.org>
Subject:   Re: Script to set/unset "automatic" status in PKGNG database
Message-ID:  <93748C09-084C-4B3D-9BDE-B69EFEF14EEA@jnielsen.net>
In-Reply-To: <20120830224006.GP64447@ithaqua.etoilebsd.net>
References:  <CFA2273E-4498-4A64-BC9F-CE5AA560409D@jnielsen.net> <20120830212833.GN64447@ithaqua.etoilebsd.net> <BC3A517F-CA9F-42A3-A1F5-9ACA2D07A860@jnielsen.net> <20120830224006.GP64447@ithaqua.etoilebsd.net>

next in thread | previous in thread | raw e-mail | index | archive | help

--Apple-Mail=_1224E63D-75A8-4607-B659-58DD6F4A6814
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

On Aug 30, 2012, at 4:40 PM, Baptiste Daroussin <bapt@freebsd.org> =
wrote:

> Thanks you should be enough, can you provide a git format-patch patch =
so that
> you get your name in the logs :D

Here you go.


--Apple-Mail=_1224E63D-75A8-4607-B659-58DD6F4A6814
Content-Disposition: attachment;
	filename=0001-Add-script-to-interactively-set-un-set-automatic-sta.patch
Content-Type: application/octet-stream; x-unix-mode=0644;
	name="0001-Add-script-to-interactively-set-un-set-automatic-sta.patch"
Content-Transfer-Encoding: quoted-printable

=46rom=20d8ac55e449a899431e0e99bce81337247d577ff2=20Mon=20Sep=2017=20=
00:00:00=202001=0AFrom:=20John=20Nielsen=20<john@jnielsen.net>=0ADate:=20=
Thu,=2030=20Aug=202012=2016:50:55=20-0600=0ASubject:=20[PATCH]=20Add=20=
script=20to=20interactively=20set/un-set=20'automatic'=20status=20of=0A=20=
installed=20packages.=0A=0A---=0A=20scripts/set_pkg_auto.sh=20|=20116=20=
++++++++++++++++++++++++++++++++++++++++++++++++=0A=201=20file=20=
changed,=20116=20insertions(+)=0A=20create=20mode=20100755=20=
scripts/set_pkg_auto.sh=0A=0Adiff=20--git=20a/scripts/set_pkg_auto.sh=20=
b/scripts/set_pkg_auto.sh=0Anew=20file=20mode=20100755=0Aindex=20=
0000000..6342e7a=0A---=20/dev/null=0A+++=20b/scripts/set_pkg_auto.sh=0A=
@@=20-0,0=20+1,116=20@@=0A+#!/bin/sh=0A+=0A+#=20Copyright=20(c)=202012=20=
John=20Nielsen=20<john@jnielsen.net>=0A+#=20All=20rights=20reserved.=0A=
+#=0A+#=20Redistribution=20and=20use=20in=20source=20and=20binary=20=
forms,=20with=20or=20without=0A+#=20modification,=20are=20permitted=20=
provided=20that=20the=20following=20conditions=0A+#=20are=20met:=0A+#=20=
1.=20Redistributions=20of=20source=20code=20must=20retain=20the=20above=20=
copyright=0A+#=20=20=20=20notice,=20this=20list=20of=20conditions=20and=20=
the=20following=20disclaimer=0A+#=20=20=20=20in=20this=20position=20and=20=
unchanged.=0A+#=202.=20Redistributions=20in=20binary=20form=20must=20=
reproduce=20the=20above=20copyright=0A+#=20=20=20=20notice,=20this=20=
list=20of=20conditions=20and=20the=20following=20disclaimer=20in=20the=0A=
+#=20=20=20=20documentation=20and/or=20other=20materials=20provided=20=
with=20the=20distribution.=0A+#=0A+#=20THIS=20SOFTWARE=20IS=20PROVIDED=20=
BY=20THE=20AUTHOR(S)=20``AS=20IS''=20AND=20ANY=20EXPRESS=20OR=0A+#=20=
IMPLIED=20WARRANTIES,=20INCLUDING,=20BUT=20NOT=20LIMITED=20TO,=20THE=20=
IMPLIED=20WARRANTIES=0A+#=20OF=20MERCHANTABILITY=20AND=20FITNESS=20FOR=20=
A=20PARTICULAR=20PURPOSE=20ARE=20DISCLAIMED.=0A+#=20IN=20NO=20EVENT=20=
SHALL=20THE=20AUTHOR(S)=20BE=20LIABLE=20FOR=20ANY=20DIRECT,=20INDIRECT,=0A=
+#=20INCIDENTAL,=20SPECIAL,=20EXEMPLARY,=20OR=20CONSEQUENTIAL=20DAMAGES=20=
(INCLUDING,=20BUT=0A+#=20NOT=20LIMITED=20TO,=20PROCUREMENT=20OF=20=
SUBSTITUTE=20GOODS=20OR=20SERVICES;=20LOSS=20OF=20USE,=0A+#=20DATA,=20OR=20=
PROFITS;=20OR=20BUSINESS=20INTERRUPTION)=20HOWEVER=20CAUSED=20AND=20ON=20=
ANY=0A+#=20THEORY=20OF=20LIABILITY,=20WHETHER=20IN=20CONTRACT,=20STRICT=20=
LIABILITY,=20OR=20TORT=0A+#=20(INCLUDING=20NEGLIGENCE=20OR=20OTHERWISE)=20=
ARISING=20IN=20ANY=20WAY=20OUT=20OF=20THE=20USE=20OF=0A+#=20THIS=20=
SOFTWARE,=20EVEN=20IF=20ADVISED=20OF=20THE=20POSSIBILITY=20OF=20SUCH=20=
DAMAGE.=0A+=0A+#=20This=20script=20presents=20a=20checklist=20of=20all=20=
PKGNG=20packages=20registered=20on=0A+#=20the=20system,=20showing=20for=20=
each=20whether=20or=20not=20it=20is=20marked=20as=20"automatic"=0A+#=20=
(i.e.=20not=20explicitly=20requested=20by=20the=20user).=20Any=20changes=20=
are=20recorded=0A+#=20via=20'pkg=20set=20...'.=20I=20wrote=20it=20to=20=
make=20"pkg=20autoremove"=20useful=20following=0A+#=20a=20pkg2ng=20=
migration,=20but=20other=20uses=20are=20conceivable.=0A+=0A+#=20Terminal=20=
geometry=0A+sz=3D`stty=20size`=0A+rows=3D`echo=20${sz}=20|=20cut=20-d=20=
'=20'=20-f=201`=0A+cols=3D`echo=20${sz}=20|=20cut=20-d=20'=20'=20-f=202`=0A=
+drows=3D$((=20${rows}=20-=203=20))=0A+dcols=3D$((=20${cols}=20-=206=20=
))=0A+=0A+#=20Dialog=20results=20are=20stored=20here=0A+tmpfile=3D`mktemp=20=
-t=20set_pkg_auto`=0A+=0A+#=20We=20always=20want=20the=20same=20style=20=
checklist=0A+export=20DIALOGOPTS=3D"--extra-button=20--extra-label=20=
\"Select=20All\"=20--cancel-label=20\"Deselect=20All\"=20--help-button=20=
--help-label=20Exit"=0A+=0A+#=20Exit=20with=20an=20error=20message=0A=
+die()=20{=0A+=09rm=20-f=20${tmpfile}=0A+=09echo=20"${1}"=0A+=09exit=201=0A=
+}=0A+=0A+#=20Don't=20leave=20tmpfile=20behind=20even=20if=20we=20are=20=
killed/interrupted=0A+trap=20"die=20\"Interrupt=20received.\""=202=2015=0A=
+=0A+#=20Run=20dialog=20to=20present=20the=20checklist=20and=20save=20=
the=20results=20in=20tmpfile=0A+run_dialog()=20{=0A+=09dialog=20=
--checklist=20"Select=20packages=20to=20consider=20for=20auto-removal"=20=
${drows}=20${dcols}=20${drows}=20$*=202>${tmpfile}=0A+=09return=20$?=0A=
+}=0A+=0A+#=20Show=20the=20current=20status=20from=20the=20package=20=
database=20in=20the=20checklist=0A+select_current()=20{=0A+=09run_dialog=20=
`pkg=20query=20'%n=20%o=20%a'=20|=20sed=20-e=20's/1$/on/g'=20-e=20=
's/0$/off/g'`=0A+=09return=20$?=0A+}=0A+=0A+#=20Select=20all=20packages=20=
in=20the=20checklist=0A+select_all()=20{=0A+=09run_dialog=20`pkg=20query=20=
'%n=20%o'=20|=20sed=20-e=20's/$/=20on/g'`=0A+=09return=20$?=0A+}=0A+=0A=
+#=20De-select=20all=20packages=20in=20the=20checklist=0A+select_none()=20=
{=0A+=09run_dialog=20`pkg=20query=20'%n=20%o'=20|=20sed=20-e=20's/$/=20=
off/g'`=0A+=09return=20$?=0A+}=0A+=0A+#=20Update=20the=20package=20=
database=20to=20match=20selections=20in=20the=20specified=20file=0A=
+do_update()=20{=0A+=09autopkgs=3D`sed=20-e=20's/"//g'=20${1}`=0A+=09#=20=
First=20unset=20all=0A+=09pkg=20set=20-ay=20-A=200=0A+=09#=20Then=20set=20=
selected=0A+=09pkg=20set=20-y=20-A=201=20${autopkgs}=0A+}=0A+=0A+#=20Run=20=
select_current=20for=20the=20first=20checklist=0A+pkgset=3Dcurrent=0A+=0A=
+#=20Show=20the=20checklist=20until=20"OK"=20or=20"Exit"=20is=20selected=0A=
+while=20:=20;=20do=0A+=09select_${pkgset}=0A+=09case=20$?=20in=0A+=09=09=
0)=20#=20OK,=20continue=20with=20updates=0A+=09=09=09break;=0A+=09=09=09=
;;=0A+=09=093)=20#=20Extra=20(Select=20all),=20show=20the=20checklist=20=
again=0A+=09=09=09pkgset=3Dall=0A+=09=09=09;;=0A+=09=091)=20#=20Cancel=20=
(Deselect=20all),=20show=20the=20checklist=20again=0A+=09=09=09=
pkgset=3Dnone=0A+=09=09=09;;=0A+=09=09*)=20#=204-Help=20(Exit)=20or=20=
ESC=20or=20error,=20exit.=0A+=09=09=09die=20"No=20changes=20made."=0A+=09=
=09=09;;=0A+=09esac=0A+done=0A+=0A+#=20If=20we=20got=20this=20far=20then=20=
tmpfile=20has=20a=20list=20of=20'automatic'=20packages=0A+do_update=20=
${tmpfile}=0A+=0A+#=20Clean=20up=0A+rm=20-f=20${tmpfile}=0A+echo=20=
"Updated=20successfully."=0A--=20=0A1.7.11.3=0A=0A=

--Apple-Mail=_1224E63D-75A8-4607-B659-58DD6F4A6814
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=us-ascii




--Apple-Mail=_1224E63D-75A8-4607-B659-58DD6F4A6814--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?93748C09-084C-4B3D-9BDE-B69EFEF14EEA>