From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-14) on finch.gentoo.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DMARC_REJECT,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=no autolearn_force=no version=4.0.0 Received: from mta02-svc.ntlworld.com (mta02-svc.ntlworld.com [62.253.162.42]) by chiba.3jane.net (Postfix) with ESMTP id DDA51AC398 for ; Sat, 8 Jun 2002 16:21:43 -0500 (CDT) Received: from localhost.localdomain ([213.105.250.141]) by mta02-svc.ntlworld.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020608212133.WSN4626.mta02-svc.ntlworld.com@localhost.localdomain> for ; Sat, 8 Jun 2002 22:21:33 +0100 Date: Sat, 8 Jun 2002 22:21:41 +0100 From: =?iso-8859-1?Q?Jos=E9?= Fonseca To: gentoo-dev@gentoo.org Message-ID: <20020608212141.GA22808@localhost> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="3uo+9/B/ebqu+fSQ" Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Mailer: Balsa 1.3.6 Subject: [gentoo-dev] Two scripts to automate the daily 'emerge rsync' with unmasked packages Sender: gentoo-dev-admin@gentoo.org Errors-To: gentoo-dev-admin@gentoo.org X-BeenThere: gentoo-dev@gentoo.org X-Mailman-Version: 2.0.6 Precedence: bulk Reply-To: gentoo-dev@gentoo.org List-Help: List-Post: List-Subscribe: , List-Id: Gentoo Linux developer list List-Unsubscribe: , List-Archive: X-Archives-Salt: 52aa2b8b-8f5b-4503-8729-f04f0fad235d X-Archives-Hash: 3c54e632b8d589e84175832f8b0550cd --3uo+9/B/ebqu+fSQ Content-Type: text/plain; format=flowed; charset=ISO-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Here two scripts to automate the daily 'emerge rsync' with unmasked packages. To use them gust have your unmasked packages in /usr/portage/profiles/package.mask by double commenting them out, i.e., inserting '##' before them, e.g., changing # spider@gentoo.org ; 21 May 2002; # =x11-libs/gtk+-1.2* doesn't work # this is now the gnome2 big bloated mask! # (gnome-2 that is ;) >=x11-libs/gtk-engines-1.9.0 >=gnome-base/libglade-1.99.10-r1 >=app-text/scrollkeeper-0.3.0 ... into # spider@gentoo.org ; 21 May 2002; # =x11-libs/gtk+-1.2* doesn't work # this is now the gnome2 big bloated mask! # (gnome-2 that is ;) ##>=x11-libs/gtk-engines-1.9.0 ##>=gnome-base/libglade-1.99.10-r1 ##>=app-text/scrollkeeper-0.3.0 ... and run (as root) the 'emerge_rsync.sh' script as many times you want! ;-) It will also present you with what has been changed in package.mask and in "world". Also give a look into the scripts to know a little more - I've minimally commented them and they are fairly simple. I hope that you find this useful. If yes, please tell, and I'll make sure that any fixes and improvements that I (or others) make get back to you (e.g., by hosting these scripts in my webpage). Regards, José Fonseca --3uo+9/B/ebqu+fSQ Content-Type: text/x-sh; charset=unknown-8bit Content-Disposition: attachment; filename="emerge_rsync.sh" Content-Transfer-Encoding: quoted-printable #!/bin/sh # emerge_rsync.sh # # Alternative shell script to 'emerge rsync' that tries to keep the unmaske= d packages' # # Just have your unmasked packages by double commenting them out, i.e., ins= erting '##' before them, and run this script # # Jos=E9 Fonseca PACKAGE_MASK=3D/usr/portage/profiles/package.mask PACKAGE_MASK_OLD=3D`mktemp` || exit 1 PACKAGE_MASK_NEW=3D`mktemp` || exit 1 # Copy the old package.mask cp $PACKAGE_MASK $PACKAGE_MASK_OLD || exit 1 emerge rsync || exit 1 # Mimic the packages unmasked by '#' in the old package.mask python package.py $PACKAGE_MASK_OLD $PACKAGE_MASK > $PACKAGE_MASK_NEW || ex= it 1 # One can choose between two diffs: # # diff -u $PACKAGE_MASK $PACKAGE_MASK_NEW #=20 # shows what has been unmasked again, while # # diff -u $PACKAGE_MASK_OLD $PACKAGE_MASK_NEW # # shows what changed between your previous and suggested package mask.=20 # The later shows also what has been added so I find it a little more inter= esting, and if there is no change then it's obvious too, and one doesn't ne= ed too take much attention to it. ;-) # # It would be nice if less allowed to quit with non-zero return value, but = unfortunately if you want to avoid the changes you'll have to hit Ctrl-Z an= d kill it... if diff -u $PACKAGE_MASK_OLD $PACKAGE_MASK_NEW | less then mv -f $PACKAGE_MASK_NEW $PACKAGE_MASK else rm -f $PACKAGE_MASK_NEW fi rm -f $PACKAGE_MASK_OLD # Leave this here if you also want to know what new stuff is available emerge --update --pretend world --3uo+9/B/ebqu+fSQ Content-Type: text/x-python; charset=unknown-8bit Content-Disposition: attachment; filename="package.py" Content-Transfer-Encoding: quoted-printable #!/usr/bin/env python # package.py # # Python program to mimic the packages unmasked by '##' in package.mask acr= oss an 'emerge rsync' # # Jos=E9 Fonseca def make_key(operator,category,package,version,release): key =3D package if operator: key =3D operator + key if operator =3D=3D '=3D': key =3D key + '-' + version return key =09 if __name__ =3D=3D "__main__": import sys, os, time, glob, re, string old =3D sys.argv[1] new =3D sys.argv[2] =09 # Regular expressions to match the packages masks OPERATOR_RE =3D r"([*<>=3D~]+)" CATEGORY_RE =3D r"([0-9a-zA-Z]+-[0-9a-zA-Z]+)" PACKAGE_RE =3D r"([a-zA-Z+][-+_0-9a-zA-Z]*?)" NUMBER_RE =3D r"(?:[a-zA-Z]*[0-9]+|[0-9]+[a-zA-Z]*)" VERSION_RE =3D r"(" + NUMBER_RE + r"(?:[._]" + NUMBER_RE + r")*)" RELEASE_RE =3D r"(r[0-9]+)" EXTENSION_RE =3D r"[0-9a-zA-Z]+" MASK_RE =3D OPERATOR_RE + r"?(?:" + CATEGORY_RE + r"/)?" + PACKAGE_RE + r"= (?:-" + VERSION_RE + r"\*?(?:-" + RELEASE_RE + r")?)?(?:\." + EXTENSION_RE = + r")?" UNMASK_RE =3D r"##" + MASK_RE BEGIN_RE =3D r"^" END_RE =3D r"(?:[ ].*)?\n$" =09 mask_re =3D re.compile(BEGIN_RE + MASK_RE + END_RE) unmask_re =3D re.compile(BEGIN_RE + UNMASK_RE + END_RE) =09 # Dictinary to old the unmasked packages keys. The key consists of the ope= rator and package name to cope with multiple ocurrences of the same package unmasked =3D {}; =09 # Search for unmasked packages in the old package.mask f =3D open(old) l =3D f.readline() while l !=3D "":=09 if unmask_re.match(l): begin,operator,category,package,version,release,end =3D unmask_re.split(= l) key =3D make_key(operator,category,package,version,release) unmasked[key] =3D 1; =09 l =3D f.readline() f.close() # Unmask them again on the new package.mask f =3D open(new) l =3D f.readline() while l !=3D "":=09 if mask_re.match(l): begin,operator,category,package,version,release,end =3D mask_re.split(l) key =3D make_key(operator,category,package,version,release) =09 if unmasked.has_key(key): print "##" + l, else: print l, else: print l, =09 l =3D f.readline() f.close() =09 --3uo+9/B/ebqu+fSQ--