You are not logged in.

#1 2005-11-28 17:20:39

swiergot
Member
From: Kraków, Poland
Registered: 2005-01-08
Posts: 145

dotpac - helps to handle .pacnew and .pacsave files

I wrote this simple script to speed up dealing with .pacnew and .pacsave files in my /etc directory. I was tired of doing it manually almost every day (find, diff, vi, mv, rm, again and again) and it was easy to make a mistake.

Additionally, it may be even more helpful for newbies who don't know where these files came from as it explains why pacman creates them.

All you need to do is to run dotpac (sorry, I didn't have time to think up a better name) and go through a few dialogs. Don't worry, dotpac will not do anything without your explicit command. Also please note that it doesn't offers automagic combining *.pac* files with their working equivalents.

Opinions, suggestions, ideas, bug reports are welcome.

Download: http://kenny.juvepoland.com/~swiergot/a … ils/dotpac
Wiki: http://wiki.archlinux.org/index.php/dotpac
PKGBUILD (by hellwoofa): http://aur.archlinux.org/packages.php?d … =1&ID=3017

Offline

#2 2005-11-28 18:56:51

Spider.007
Member
Registered: 2004-06-20
Posts: 1,175

Re: dotpac - helps to handle .pacnew and .pacsave files

Using `dialog` is nice, I never saw that one before. What you might add is some error checking, check if `rm` returned succesfull, or else display it's errormessage (like 'no permission') smile

I really quite like it btw  lol good job!

Offline

#3 2005-11-28 20:14:52

nbcjr
Member
From: BRAZIL!
Registered: 2004-12-04
Posts: 79

Re: dotpac - helps to handle .pacnew and .pacsave files

superb! thank you very much, this should be on 0.8

Offline

#4 2005-11-28 20:15:39

nightfrost
Member
From: Sweden
Registered: 2005-04-16
Posts: 647

Re: dotpac - helps to handle .pacnew and .pacsave files

This is a very nice tool. Thanks smile

I was first thinking that one might replace the lines that say "... the package that owns $file" with something using the output of pacman -Qo $file. But then I realized it might make the script really slow as sometimes pacman -Qo might take quite some time to give an output..

Offline

#5 2005-11-29 06:14:55

kakabaratruskia
Member
From: Santiago, Chile
Registered: 2003-08-24
Posts: 596

Re: dotpac - helps to handle .pacnew and .pacsave files

amazing tool.


And where were all the sportsmen who always pulled you though?
They're all resting down in Cornwall
writing up their memoirs for a paper-back edition
of the Boy Scout Manual.

Offline

#6 2005-12-01 17:24:04

swiergot
Member
From: Kraków, Poland
Registered: 2005-01-08
Posts: 145

Re: dotpac - helps to handle .pacnew and .pacsave files

I appears to be a bug in gpm. I can remember I used to have a similar error in mc but somehow it disappeared itself. I did some googling and it seems the only rescue for people experiencing this problem is running gpm. I have no idea why some people have this problem and some other don't.

Offline

#7 2005-12-05 09:37:14

swiergot
Member
From: Kraków, Poland
Registered: 2005-01-08
Posts: 145

Re: dotpac - helps to handle .pacnew and .pacsave files

I suppose the latest update to the gpm package should help.

Offline

#8 2005-12-24 08:25:01

jakob
Member
From: Berlin
Registered: 2005-10-27
Posts: 419

Re: dotpac - helps to handle .pacnew and .pacsave files

didn't you made a PKGBUILD for aur? Your homepage is down atm sad

Offline

#9 2005-12-24 14:32:59

Spider.007
Member
Registered: 2004-06-20
Posts: 1,175

Re: dotpac - helps to handle .pacnew and .pacsave files

hellwoofa wrote:

didn't you made a PKGBUILD for aur? Your homepage is down atm sad

I created a mirror for the moment smile

Offline

#10 2005-12-25 20:42:12

jakob
Member
From: Berlin
Registered: 2005-10-27
Posts: 419

Re: dotpac - helps to handle .pacnew and .pacsave files

i hope you don't mind me using your mirror in the PKGBUILD that i'll get into the aur now? if so, pls contact me!

greetings,

hellwoofa

Offline

#11 2005-12-25 21:02:49

LB06
Member
From: The Netherlands
Registered: 2003-10-29
Posts: 435

Re: dotpac - helps to handle .pacnew and .pacsave files

I could host it, if necessary. Only have 14GB per month spare, though. smile

Offline

#12 2005-12-25 22:10:27

swiergot
Member
From: Kraków, Poland
Registered: 2005-01-08
Posts: 145

Re: dotpac - helps to handle .pacnew and .pacsave files

Thank you guys. I have added an information about the PKGBUILD to the Wiki page. My website should be online by mid January but I think it would be safe to upload the script itself to the AUR.

Offline

#13 2005-12-25 23:41:49

jakob
Member
From: Berlin
Registered: 2005-10-27
Posts: 419

Re: dotpac - helps to handle .pacnew and .pacsave files

if you know how to upload it to AUR (including it into the tarfile which is upped during the submission?), why don't you do it? smile

i hope i put in the right depends, im quite new to the whole stuff and thought that "coreutils + bash" are right tongue

greetings,

hellwoofa

Offline

#14 2005-12-26 10:08:06

Spider.007
Member
Registered: 2004-06-20
Posts: 1,175

Re: dotpac - helps to handle .pacnew and .pacsave files

hellwoofa wrote:

if you know how to upload it to AUR (including it into the tarfile which is upped during the submission?), why don't you do it? smile

i hope i put in the right depends, im quite new to the whole stuff and thought that "coreutils + bash" are right tongue

greetings,

hellwoofa

You shouldn't forget `dialog` which isn't in base wink

Offline

#15 2006-03-26 14:24:23

pixel
Member
From: Living in the Server Room
Registered: 2005-02-21
Posts: 119

Re: dotpac - helps to handle .pacnew and .pacsave files

excellent tool, IMHO should be moved to [extra] in 0.8


Favorite systems: ArchLinux, OpenBSD
"Yes, I love UNIX"

Offline

#16 2006-03-26 19:08:00

MAC!EK
Member
Registered: 2005-09-27
Posts: 267

Re: dotpac - helps to handle .pacnew and .pacsave files

In english:

Hi
I found a "bug". I put a set -x at the begining of the bash script. This is the output after the crash:

+ '[' 0 '!=' 0 ']'
++ cat /tmp/tmp.Bnlek12255/exitcode
+ choice=1
++ expr 1 + 6
+ choice=7
++ sed -n 7p /tmp/tmp.Bnlek12255/dialog
++ cut -d ' ' -f 2
+ file=/etc/profile.pacold
+ [[ /etc/profile.pacold == *.pacnew ]]
+ [[ /etc/profile.pacold == *.pacsave ]]
+ echo 'It looks like you have found a bug. Please contact the author.'
It looks like you have found a bug. Please contact the author.
+ exit 3

I think I crated that /etc/profile.pacold file myself and the name is crashing dotpac.

A teraz po polsku:

Cześć
Znalazłem jakiś błąd, nie bardzo wiem o co chodzi, dopisałem set -x i wkleiłem powyżej komunikat który pozostał na ekranie po zakończeniu dotpac.

Z tego co pamiętam to sam stworzyłem ten plik /etc/profile.pacold a nazwa widocznie jest trochę nie fortunna. Może jakieś obejście jeśli nazwa nie pasuje do schematu?

Offline

#17 2006-03-26 19:35:58

swiergot
Member
From: Kraków, Poland
Registered: 2005-01-08
Posts: 145

Re: dotpac - helps to handle .pacnew and .pacsave files

Clearly a bug. By the way I have also added checking for presence of dialog and moved creation of tmpdir after all checks. New version of course at:

http://herkules.pcz.pl/~swiergot/dotpac

---

Dzięki. Nie przypuszczałem, że ten komunikat o błędzie na cokolwiek się przyda wink

Offline

#18 2006-04-01 22:54:39

MAC!EK
Member
Registered: 2005-09-27
Posts: 267

Re: dotpac - helps to handle .pacnew and .pacsave files

How about dotpac take care about all .pac files not only in /etc ?

# find / -name *.pac*
/boot/grub/menu.lst.pacnew
/boot/grub/menu.lst.pacsave
/boot/kconfig26.pacsave
/boot/kconfig26mm.pacsave
/boot/kconfig26archck.pacsave
/opt/kde/share/config/kdm/kdmrc.pacsave
(I omitted the .packlist files from perl)

Offline

#19 2006-10-10 11:34:40

swiergot
Member
From: Kraków, Poland
Registered: 2005-01-08
Posts: 145

Re: dotpac - helps to handle .pacnew and .pacsave files

New version at:

http://kenny.juvepoland.com/~swiergot/a … ils/dotpac

ChangeLog:
- fixed the explanation for lone .pacsave files,
- search also in /boot.

Offline

#20 2007-01-12 19:49:25

lateralus_
Member
From: Belgium
Registered: 2007-01-07
Posts: 17

Re: dotpac - helps to handle .pacnew and .pacsave files

Hi,

thanks for this little program : it works well  wink
I have just one remark   : instead of saying remove the new file, remove the new file and edit the old one, ... is it be possible to have the real file name instead of new and old ?


There are a lot of lies going around.... and half of them are true.
        -- Winston Churchill

Offline

#21 2007-05-14 04:32:25

Echo
Member
From: Ohio, United States
Registered: 2006-05-16
Posts: 239

Re: dotpac - helps to handle .pacnew and .pacsave files

I was looking for something to use on a remote box. This fits the bill nicely. I changed my editor to nano as I'm not
proficient enough with vim....

Thanks.

Offline

#22 2009-06-29 16:02:16

zebulon
Member
Registered: 2008-10-20
Posts: 349

Re: dotpac - helps to handle .pacnew and .pacsave files

Hi,

That's very handy, thanks. I realise this thread is 2 years old. Is it still maintained ?

Offline

#23 2009-06-29 16:29:24

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: dotpac - helps to handle .pacnew and .pacsave files

zebulon wrote:

I realise this thread is 2 years old. Is it still maintained ?

i wrote a similar script if you're interested:

#!/bin/bash
#
# PacNews
#
# pbrisbin 2009
#
###

message() {
  echo ""
  echo "pacnews is designed to streamline dealing with .pacnew files."
  echo ""
  echo "pacnews must be run as root, and will optionally accept a"
  echo "directory on which to act, otherwise /etc will be searched by"
  echo "default."
  echo ""
  echo "all *.pacnew files found will be presented to you one by one; "
  echo "you'll have the option of viewing/editing your current config"
  echo "file side by side with the pacnew file through vimdiff, then"
  echo "you can remove the pacnew file, replace you're existing"
  echo "config file with the .pacnew file, or do nothing."
  echo ""
  echo "answering anything other than \"y\" to the options will"
  echo "eventually bring you back without changing your system in any"
  echo "way."
  echo ""
  exit 1
}

errorout(){
  echo "==> ERROR: $1"
  exit 1
}

[ "$(whoami)" != "root" ] && errorout "You must be root"

which vimdiff >/dev/null 2>&1 || errorout "You need vimdiff installed"

if [ -z $1 ]; then
  DIR="/etc"
elif [ "$1" = "--help" ]; then
  message
else
  [ -d $1 ] || errorout "$1 is not a directory, try --help"
  DIR="$1"
fi

[ "$(find $DIR -name '*.pacnew')" = "" ] && {
  echo "No .pacnew files found."
  exit 0
}

for file in $(find $DIR -name '*.pacnew'); do
  current="$(echo $file | sed 's/\.pacnew//g')"
  echo -n ":: $file found, view differences? (Y/n) " && read A
  if [ "$A" = "y" ]; then
    vimdiff $current $file
    echo -n ":: Remove $file? (Y/n) " && read A
    if [ "$A" = "y" ]; then
      rm $file || errorout "could not remove the pacnew file"
      echo ">> $file was removed"
    else
      echo -n ":: Replace $current with $file? (Y/n) " && read A
      if [ "$A" = "y" ]; then
        cp $current $current.pacsave || errorout "could not back up existing config"
        echo ">> $current saved as $current.pacsave"
        mv $file $current || errorout "could not your config file"
        echo ">> $current replaced by $file"
      fi
    fi
  else
    echo ">> Skipping $file..."
  fi
done

exit 0

the most up to date version is always here as that's just a symlink to my ~/.bin

Offline

#24 2009-10-14 02:33:49

handy
Member
From: Oz
Registered: 2008-03-26
Posts: 719

Re: dotpac - helps to handle .pacnew and .pacsave files

Dotpac is in AUR, I just installed it & it works a treat.

Thanks swiergot for scripting it for us & thanks hellwoofa for the PKGBUILD. smile

I know there are a few other options that do similar jobs, I haven't tried them, Dotpac does it for me. smile


I used to be surprised that I was still surprised by my own stupidity, finding it strangely refreshing.
Well, now I don't find it refreshing.
I'm over it!

Offline

#25 2010-08-15 14:03:34

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,000
Website

Re: dotpac - helps to handle .pacnew and .pacsave files

dotpac is cool. simple and works.

found a bug:
- `diff -u "$1" "$2"` should be `diff -u "$2" "$1"` because now the pacnew gets '-' signs, and the pacold has '+', which is very confusing.

feature request:
- menu option for vimdiff.  or maybe just run vimdiff alltogether instead of normal diff.  you can use it to just view the diffs, and advanced users can use it to merge the files.  or use a commandline argument to run vimdiff instead of diff.

host the source code on github and i'll fix it for you smile

Last edited by Dieter@be (2010-08-15 14:05:33)


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

Board footer

Powered by FluxBB