LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 09-24-2013, 09:53 AM   #1
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Rep: Reputation: 221Reputation: 221Reputation: 221
Lightbulb [Request] Slackpkg custom merge tool.


Hi,

I checked slackpkg sources, and found that it was using sdiff to merge configurations files.

I'd like to use another merge tool (emacs to be precise ).

Would it be possible to make the merge tool customizable ?

It would be great to be able to change the sdiff default using an environment variable.

If any help needed, I'd be glad to participate (at least for testing ).

Thanks !

Bests,

Garry.

Edit: It could be in slackpkg.conf too, but an external environment variable could make this more "versatile".

Last edited by NoStressHQ; 09-24-2013 at 09:58 AM.
 
Old 09-24-2013, 10:15 AM   #2
willysr
Senior Member
 
Registered: Jul 2004
Location: Jogja, Indonesia
Distribution: Slackware-Current
Posts: 4,651

Rep: Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772
so that means all users wanting to use slackpkg should install emacs?
i don't think most users will agree on this one

i personally don't install emacs and i think sdiff works for me
 
1 members found this post helpful.
Old 09-24-2013, 10:18 AM   #3
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Original Poster
Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by willysr View Post
so that means all users wanting to use slackpkg should install emacs?
i don't think most users will agree on this one

i personally don't install emacs and i think sdiff works for me
That's not at all what I wrote...

I asked to be able to choose which merge tool you want to use. With an environment variable. I mentioned emacs just because it's the one I want to use in my particular situation...
 
Old 09-24-2013, 10:22 AM   #4
willysr
Senior Member
 
Registered: Jul 2004
Location: Jogja, Indonesia
Distribution: Slackware-Current
Posts: 4,651

Rep: Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772
i guess the main important is what's the advantage of using emacs compared to sdiff?
 
Old 09-24-2013, 10:27 AM   #5
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Original Poster
Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by willysr View Post
i guess the main important is what's the advantage of using emacs compared to sdiff?
... Is it a joke ? Do I tell you how you need to work ?
 
Old 09-24-2013, 10:32 AM   #6
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by NoStressHQ View Post
... Is it a joke ? Do I tell you how you need to work ?
willysr indeed has a point there. Having multiple options for that means that someone has to implement and test that every time changes are made to slackpkg, with all possible options. If there isn't an obvious advantage of using Emacs or anything else to do the job I don't see why the developer should add this.

But I am really curious about that, what exactly do you want to achieve with the switch to Emacs?
 
Old 09-24-2013, 10:36 AM   #7
willysr
Senior Member
 
Registered: Jul 2004
Location: Jogja, Indonesia
Distribution: Slackware-Current
Posts: 4,651

Rep: Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772
no, it's not a joke
i know emacs is a great application and some might like it and prefer it compared to vi or nano, but i don't see anything different with the results of diff by changing to emacs (please, CMIIW)
 
Old 09-24-2013, 10:41 AM   #8
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Original Poster
Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by TobiSGD View Post
willysr indeed has a point there. Having multiple options for that means that someone has to implement and test that every time changes are made to slackpkg, with all possible options. If there isn't an obvious advantage of using Emacs or anything else to do the job I don't see why the developer should add this.

But I am really curious about that, what exactly do you want to achieve with the switch to Emacs?
Alright, that's a better approach to the question. At least I cant understand your point about maintainability.

It's before all a matter of being more productive to be able to use the tool you're used to use in your daily tasks. That's seems obvious to me.

Beside I don't ask for emacs (I thought my OP was clear about that)...

I ask to be able to have an environment variable to be able to customize.

Default would be ie:

Code:
SLACKPKG_MERGE_TOOL=sdiff -s -o
And people would be able to do something else
Code:
SLACKPKG_MERGE_TOOL=mymergetool-of-my-choice --with --my --args
That's it. I might be wrong but those modifying (customizing) this variable should be aware enough to understand how it works and being responsible to maintain their own customization.

I use emacs, but many others use vim so I'm not doing some "emacs evangelization" and don't want to enter in this mode...

I was just talking about giving slackpkg some more flexibility.

And I'm open to any point which could be about "not in the plan" or "difficult to maintain" although I really don't see (I might be wrong) any difficult problem here.

In practice it could even be a wrapper script that shuffle arguments if the wanted merge tool is too exotic.

Thanks

Garry.

Last edited by NoStressHQ; 09-24-2013 at 10:52 AM. Reason: fixed typos
 
Old 09-24-2013, 10:45 AM   #9
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Original Poster
Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by willysr View Post
no, it's not a joke
i know emacs is a great application and some might like it and prefer it compared to vi or nano, but i don't see anything different with the results of diff by changing to emacs (please, CMIIW)
Ok sorry I took it badly, it's just it was not at all the point of my post.

And I don't see the need to argue "which one is better" because ultimately, it's a matter of choice, is it personal or professional/corporate... Anyway.

I'm not saying sdiff is rubbish, sdiff is good when you don't have anything else accessible.

I'd just rather use emacs for that, it's a choice as any choice.

Edit: obviously, I hope there's no difference in the 'result of diff' haha... It's on the way you do the merge, which color you want etc. Usability in short, productivity for a longer word.

Edit2: also it's less error prone to use something you're used to use... And config files merges can sometimes be "sensible".

Edit3: sorry, I can understand the problem now, I'm talking about having 'interactive merge tool'. And now I see that it might introduce more changes in slackpkg behavior. But I guess it's not something impossible. So that was maybe the source of misunderstanding. But sdiff is interactive too so at the end, it seems to me that the point is the same.

Last edited by NoStressHQ; 09-24-2013 at 11:28 AM.
 
Old 09-24-2013, 05:34 PM   #10
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,357

Rep: Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739
Slackpkg is designed to be easy to customise. I actually implement a custom merge using vimdiff. I find it useful for updating large config files with custom entries e.g. for cups and ssh. Adapting this for emacs should not be difficult.
I edit /usr/libexec/slackpkg/functions.d/postfunctions.sh
Code:
--- post-functions.sh.orig	2013-02-21 21:07:05.408637573 +1100
+++ post-functions.sh	2013-02-21 22:08:22.885260049 +1100
@@ -10,6 +10,18 @@
 	fi
 }
 
+runvimdiff() {
+	BASENAME=$(basename $i .new)
+	FILEPATH=$(dirname $i)
+	FULLNAME="${FILEPATH}/${BASENAME}"
+
+	if [ -e ${FULLNAME} ]; then
+	    vimdiff ${FULLNAME} ${FULLNAME}.new
+	else
+	    echo "file $FULLNAME doesn't exist"
+	fi
+}
+
 showmenu() {
 	echo -e "$1 - \c"
 	tput sc
@@ -166,7 +178,7 @@
 					GOEX=0
 					while [ $GOEX -eq 0 ]; do
 						echo
-						showmenu $i "(K)eep" "(O)verwrite" "(R)emove" "(D)iff" "(M)erge"
+						showmenu $i "(K)eep" "(O)verwrite" "(R)emove" "(D)iff" "(M)erge" "(V)imdiff [dp put, do obtain, ^W^W switch]"
 						read ANSWER
 						case $ANSWER in
 							O|o)
@@ -183,6 +195,9 @@
 							M|m)
 								mergenew $1
 							;;
+							V|v)
+								runvimdiff $1
+							;;
 							K|k|*)
 								GOEX=1
 							;;
 
1 members found this post helpful.
Old 09-24-2013, 06:02 PM   #11
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Original Poster
Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by allend View Post
Slackpkg is designed to be easy to customise. I actually implement a custom merge using vimdiff. I find it useful for updating large config files with custom entries e.g. for cups and ssh. Adapting this for emacs should not be difficult.
I edit /usr/libexec/slackpkg/functions.d/postfunctions.sh
Yes, that's what I meant !

I know this file, it's just I'd rather not modify/patch it, and I myself don't want to use emacs all the time. That's why I was talking about an environment variable... In the function mergenew(),

instead of:

Code:
sdiff -s -o "${FULLNAME}.smerge" "${FULLNAME}" "${FULLNAME}.new"
it could be:

Code:
$SLACKPKG_MERGE_TOOL "${FULLNAME}.smerge" "${FULLNAME}" "${FULLNAME}.new"
While in slackpkg.conf we could have (bash syntax, dunno for "pure" /bin/sh):

Code:
SLACKPKG_MERGE_TOOL=${SLACKPKG_MERGE_TOOL:-sdiff -s -o}
Then slackpkg should work as usual, but if we want a another merge tool we could just set the SLACKPKG_MERGE_TOOL variable to the right command...

As simple as this. No one lose anything, does it ?

Cheers

Garry.

Last edited by NoStressHQ; 09-24-2013 at 09:34 PM. Reason: Added the forgotten '$' on variable reference :).
 
Old 09-24-2013, 07:52 PM   #12
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,357

Rep: Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739
I find that having another menu entry is more convenient than setting an environment variable.
Editing postfunctions.sh is only a problem when it gets overwritten by a package update.
 
Old 09-24-2013, 08:04 PM   #13
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Original Poster
Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by allend View Post
I find that having another menu entry is more convenient than setting an environment variable.
Editing postfunctions.sh is only a problem when it gets overwritten by a package update.
Well here are my points:
- consistency: it's like the common $EDITOR env var used in many places.
- complexity: a menu requires more modification and imply to know which options you want to provide, and each must be tested upstream (this might become a PITA for developers)
- flexibility: a variable can be set to anything the user want, even a yet unknown tool or a wrapper script that provide an "unified" interface.

Plus you can set the variable in a script (or the .bashrc file) and it's not difficult.

On my point of view the variable is more "UNIX" in style and flavor, it's a very tiny modification and open to more choice.

BTW, it's my developer reflex and my preference, I don't know what slackpkg developers prefer, it's up to them.
 
Old 09-24-2013, 08:09 PM   #14
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,357

Rep: Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739Reputation: 2739
One argument for avoiding using emacs is that it requires X to be running. I prefer to do my upgrades from run level 3, so vimdiff is a viable choice for that.
 
Old 09-24-2013, 08:12 PM   #15
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Original Poster
Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by allend View Post
One argument for avoiding using emacs is that it requires X to be running. I prefer to do my upgrades from run level 3, so vimdiff is a viable choice for that.
Have you noticed "emacs-24.2-no-x11" ? As a matter of fact I got an alias as "emacs-console" for my headless server...

(Edit: And even in graphical environment I tend to use the console version of emacs...)
 
  


Reply

Tags
custom, merge, slackpkg


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Meld 1.7.5 Diff and Merge Tool Is Available for Download LXer Syndicated Linux News 0 09-02-2013 08:51 AM
Custom kernel, slackpkg upgrade-all vjayz Slackware 2 01-26-2012 02:48 AM
Using slackpkg as a Tool to Create a New Installation on Removable Media JazzItSelf Slackware 1 07-12-2010 02:02 AM
how to install .tgz files with the slackpkg tool james2b Slackware 6 12-16-2008 06:49 PM
need a server side pdf merge tool siyisoy General 2 06-05-2006 10:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 11:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration