Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed install paths on unix #80

Merged
merged 4 commits into from
Sep 1, 2014
Merged

Changed install paths on unix #80

merged 4 commits into from
Sep 1, 2014

Conversation

cen1
Copy link
Collaborator

@cen1 cen1 commented Aug 9, 2014

From /usr/local/var to /usr/local/var/pvpgn and /usr/local/etc to /usr/local/etc/pvpgn

@HarpyWar
Copy link
Member

It seems to be ok to use these paths. Several questions:

  • Is man path correct or need pvpgn directory inside?
  • I can not find var in /usr/local. Is it normal if there will be var with only one pvpgn directory?
  • Where is ${APPLICATION_NAME} defined by default?
  • Does ${EXEC_INSTALL_PREFIX} set to /usr/local/ by default? So this cmake parameter will be unnecessary to define in command line.

@cen1
Copy link
Collaborator Author

cen1 commented Aug 10, 2014

man is correct
The system /var means that the content in the directory will grow in size. It has the same functionality here, /usr/local just means that the program was installed and is not part of the system. It's like a new root prefix.
APPLICATION_NAME is defined on top of DefineInstallationPaths.cmake, if not set it gets the value of PROJECT_NAME which is defined in the main CMakeLists.cmake file. It does not seem to be defined by default anywhere. It could be used in case you wanted the install name to be different than the project name for whatever reason (maybe versioning?).
EXEC_INSTALL_PREFIX is just a copy of CMAKE_INSTALL_PREXIX. I believe it is there in case you want to change the default install path for some reason. It is /usr/local by default on unix and Program Files on Windows.

I noticed that on Windows, the project installs into Program Files/pvpgn and then with all the unix paths like /var, /etc and so on. It also installs the config to Program Files/pvpgnconf so you end up with two entries in Program Files for one application. This is very "un-Windowsy" because normally you have a single entry for the program. Having unix subpaths on windows also looks weird to be honest. Perhaps the windows paths should be rewritten completely to fit better. Or, we should at least move the config into /pvpgn.

@HarpyWar
Copy link
Member

How PvPGN can be fully uninstalled in this case?

@cen1
Copy link
Collaborator Author

cen1 commented Aug 10, 2014

You just rm all the files you installed. And there is a list of them (install_manifest.txt is created in project root): http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F

There is no make uninstall target at the moment. Would be good to have one.

@HarpyWar
Copy link
Member

Will you create uninstall script in this pull request or should I merge patch without it?

Now in addition to cmake we have also make files (*.am extension). Should we stay only cmake or support both?
Is it hard to add pvpgn package into apt-get to get feature install/uninstall it as other programs?

@cen1
Copy link
Collaborator Author

cen1 commented Aug 10, 2014

I will add make uninstall target and do the windows fix I mentioned above so wait with the merge.

Cmake can generate makefiles anyway so it's just duplicate work. I'd just use cmake personally.

As for apt-get, you first need to make a .deb package (or rpm, depends on the distro) and then submit it to debian/ubuntu/whatever distro. Something similar goes for FreeBSD ports. I have absolutely no experience with this but basically, you need to package it in the correct "format" and then submit for review.

I think it's a good idea but perhaps it should be done with a major stable release version.

@HarpyWar
Copy link
Member

Ok, waiting for updates. Please, remove make files then.

I agree that there should be only a stable release. But I also have no experience with it, and I'm not a linux user. It will be great if you or somebody else will find out how to make packages for most popular unix systems.

@cen1
Copy link
Collaborator Author

cen1 commented Aug 10, 2014

I can take the development code and try to make a deb package for starters, so we know what to do when major version is rolled out. I will open a separate issue when I start with that.

@cen1
Copy link
Collaborator Author

cen1 commented Aug 11, 2014

make uninstall works nicely. It removes all the installed files but leaves the directories (like /etc/pvpgn/*) and any database files such as /var/users and other files created by bnetd at runtime. Does this seem good to you? Do you think we should leave /etc/pvpgn intact to preserve config? I believe apt-get remove does not remove the config files.

As for distro packaging, there is a tool in cmake called CPack which can produce them so it might actually be very easy to do.

@cen1 cen1 mentioned this pull request Aug 12, 2014
…ed make uninstall target: removes all files that were installed but leaves runtime generated files (db) and directories. Added make purge: removes everything, not leaving a trace on the disk.
@cen1
Copy link
Collaborator Author

cen1 commented Aug 12, 2014

Hopefully did not miss anything. I tested a few times on win and linux, seems good.

@HarpyWar
Copy link
Member

Does it ready for merge now?

@cen1
Copy link
Collaborator Author

cen1 commented Aug 31, 2014

Yes.

@HarpyWar
Copy link
Member

Now CMAKE_INSTALL_PATH should be /usr/local when installing, but not /usr/local/pvpgn. Right?

@HarpyWar
Copy link
Member

When I do not add CMAKE_INSTALL_PATH in cmake arguments it installs into /usr/local/pvpgn by default.

@cen1
Copy link
Collaborator Author

cen1 commented Aug 31, 2014

I can't find CMAKE_INSTALL_PATH anywhere. Do you mean CMAKE_INSTALL_PREFIX?

@HarpyWar
Copy link
Member

Yes sure, CMAKE_INSTALL_PREFIX

@cen1
Copy link
Collaborator Author

cen1 commented Aug 31, 2014

CMAKE_INSTALL_PREFIX is /usr/local by default. There is no /usr/local/pvpgn created. How are you getting this? I just re-tested on my vps. Check DefineInstallationPaths.cmake and see the definition of EXEC_INSTALL_PREFIX, no app name attached.

@cen1
Copy link
Collaborator Author

cen1 commented Aug 31, 2014

Apparently CMake attaches application name to CMAKE_INSTALL_PREFIX on Windows but not on linux. Unless it depends on the distro and it attaches the name on some distros? Or maybe it depends on CMake version? I use Debian and cmake 2.8.9. As per docs: http://www.cmake.org/cmake/help/v3.0/variable/CMAKE_INSTALL_PREFIX.html it should not attach the application name on Windows either but it does on Windows 7, cmake v 2.8.11.2. I will try to get the same version of CMake on both platforms and see if they changed the way it works.

@HarpyWar
Copy link
Member

Well, It was my mistake I forgot clean cmake build directory.
How to make uninstall? I run it from the same directory where was make install but error ocurrs:

make: *** No rule to make target 'uninstall'`. Stop.

@cen1
Copy link
Collaborator Author

cen1 commented Aug 31, 2014

Works for me.

cen@root:~/pvpgn-harpywar/build$ sudo make uninstall
-- Uninstalling /usr/local/bin/bncdb
-- Uninstalling /usr/local/sbin/bntrackd
-- Uninstalling /usr/local/bin/bnchat
-- Uninstalling /usr/local/bin/bnftp
-- Uninstalling /usr/local/bin/bnbot
-- Uninstalling /usr/local/bin/bnstat
-- Uninstalling /usr/local/bin/bnilist
-- Uninstalling /usr/local/bin/bni2tga
-- Uninstalling /usr/local/bin/bniextract
-- Uninstalling /usr/local/bin/bnibuild
-- Uninstalling /usr/local/bin/tgainfo
-- Uninstalling /usr/local/bin/bnpass
-- Uninstalling /usr/local/bin/sha1hash
-- Uninstalling /usr/local/sbin/bnetd
-- Uninstalling /usr/local/sbin/d2cs
-- Uninstalling /usr/local/sbin/d2dbs
-- Uninstalling /usr/local/etc/pvpgn/bnetd_default_user.cdb
-- Uninstalling /usr/local/etc/pvpgn/bnetd.conf
-- Uninstalling /usr/local/etc/pvpgn/ad.conf
-- Uninstalling /usr/local/etc/pvpgn/anongame_infos.conf
-- Uninstalling /usr/local/etc/pvpgn/address_translation.conf
-- Uninstalling /usr/local/etc/pvpgn/autoupdate.conf
-- Uninstalling /usr/local/etc/pvpgn/bnalias.conf
-- Uninstalling /usr/local/etc/pvpgn/bnban.conf
-- Uninstalling /usr/local/etc/pvpgn/bnetd_default_user.plain
-- Uninstalling /usr/local/etc/pvpgn/bnissue.txt
-- Uninstalling /usr/local/etc/pvpgn/bnmaps.conf
-- Uninstalling /usr/local/etc/pvpgn/bnxpcalc.conf
-- Uninstalling /usr/local/etc/pvpgn/bnxplevel.conf
-- Uninstalling /usr/local/etc/pvpgn/channel.conf
-- Uninstalling /usr/local/etc/pvpgn/command_groups.conf
-- Uninstalling /usr/local/etc/pvpgn/realm.conf
-- Uninstalling /usr/local/etc/pvpgn/sql_DB_layout.conf
-- Uninstalling /usr/local/etc/pvpgn/sql_DB_layout2.conf
-- Uninstalling /usr/local/etc/pvpgn/supportfile.conf
-- Uninstalling /usr/local/etc/pvpgn/topics.conf
-- Uninstalling /usr/local/etc/pvpgn/tournament.conf
-- Uninstalling /usr/local/etc/pvpgn/versioncheck.conf
-- Uninstalling /usr/local/etc/pvpgn/icons.conf
-- Uninstalling /usr/local/etc/pvpgn/d2cs.conf
-- Uninstalling /usr/local/etc/pvpgn/anongame_infos.conf
-- File /usr/local/etc/pvpgn/anongame_infos.conf does not exist.
-- Uninstalling /usr/local/etc/pvpgn/d2dbs.conf
-- Uninstalling /usr/local/etc/pvpgn/i18n/bnhelp.conf
-- Uninstalling /usr/local/etc/pvpgn/i18n/termsofservice.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/chathelp-war3.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/w3motd.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/common.xml
-- Uninstalling /usr/local/etc/pvpgn/i18n/news.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/newaccount.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/bnmotd.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/plPL/bnmotd.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/svSE/bnmotd.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/bgBG/bnmotd.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/koKR/bnmotd.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/esES/bnhelp.conf
-- Uninstalling /usr/local/etc/pvpgn/i18n/esES/termsofservice.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/esES/chathelp-war3.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/esES/w3motd.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/esES/common.xml
-- Uninstalling /usr/local/etc/pvpgn/i18n/esES/newaccount.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/esES/bnmotd.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/zhTW/bnmotd.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/itIT/bnmotd.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/csCZ/bnmotd.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/zhCN/chathelp-war3.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/zhCN/bnmotd.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/jpJA/bnmotd.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/nlNL/bnmotd.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/ptBR/bnmotd.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/frFR/chathelp-war3.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/frFR/bnmotd.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/ruRU/chathelp-war3.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/ruRU/bnmotd.txt
-- Uninstalling /usr/local/etc/pvpgn/i18n/deDE/bnmotd.txt
-- Uninstalling /usr/local/share/man/bnbot.1
-- Uninstalling /usr/local/share/man/bnchat.1
-- Uninstalling /usr/local/share/man/bnetd.1
-- Uninstalling /usr/local/share/man/bnetd.conf.5
-- Uninstalling /usr/local/share/man/bnftp.1
-- Uninstalling /usr/local/share/man/bni2tga.1
-- Uninstalling /usr/local/share/man/bnibuild.1
-- Uninstalling /usr/local/share/man/bniextract.1
-- Uninstalling /usr/local/share/man/bnilist.1
-- Uninstalling /usr/local/share/man/bnpass.1
-- Uninstalling /usr/local/share/man/bnpcap.1
-- Uninstalling /usr/local/share/man/bnproxy.1
-- Uninstalling /usr/local/share/man/bnstat.1
-- Uninstalling /usr/local/share/man/bntext.5
-- Uninstalling /usr/local/share/man/bntrackd.1
-- Uninstalling /usr/local/share/man/tgainfo.1
-- Uninstalling /usr/local/var/pvpgn/files/ad000001.mng
-- Uninstalling /usr/local/var/pvpgn/files/ad000001.smk
-- Uninstalling /usr/local/var/pvpgn/files/ad000002.mng
-- Uninstalling /usr/local/var/pvpgn/files/ad000003.mng
-- Uninstalling /usr/local/var/pvpgn/files/ad000004.mng
-- Uninstalling /usr/local/var/pvpgn/files/ad000075.mng
-- Uninstalling /usr/local/var/pvpgn/files/newbie.save
-- Uninstalling /usr/local/var/pvpgn/files/bnserver.ini
-- Uninstalling /usr/local/var/pvpgn/files/bnserver-D2DV.ini
-- Uninstalling /usr/local/var/pvpgn/files/bnserver-D2XP.ini
-- Uninstalling /usr/local/var/pvpgn/files/bnserver-WAR3.ini
-- Uninstalling /usr/local/var/pvpgn/files/ver-ix86-1.mpq
-- Uninstalling /usr/local/var/pvpgn/files/IX86ver1.mpq
-- Uninstalling /usr/local/var/pvpgn/files/PMACver1.mpq
-- Uninstalling /usr/local/var/pvpgn/files/XMACver1.mpq
-- Uninstalling /usr/local/var/pvpgn/files/icons.bni
-- Uninstalling /usr/local/var/pvpgn/files/icons_STAR.bni
-- Uninstalling /usr/local/var/pvpgn/files/icons-WAR3.bni
Built target uninstall

@HarpyWar
Copy link
Member

Yes, it works fine (I tried it with your master branch before).

But now I receive cmake errors if build your code using Magic Builder:

CMake Error at src/bnetd/CMakeLists.txt:57 (install):
  install TARGETS given no RUNTIME DESTINATION for executable target "bnetd".


CMake Error at src/d2cs/CMakeLists.txt:19 (install):
  install TARGETS given no RUNTIME DESTINATION for executable target "d2cs".


CMake Error at src/d2dbs/CMakeLists.txt:15 (install):
  install TARGETS given no RUNTIME DESTINATION for executable target "d2dbs".


CMake Error at src/bntrackd/CMakeLists.txt:3 (install):
  install TARGETS given no RUNTIME DESTINATION for executable target
  "bntrackd".


-- Configuring incomplete, errors occurred!
See also "D:/pvpgn-magic-builder-2.04/build/CMakeFiles/CMakeOutput.log".
See also "D:/pvpgn-magic-builder-2.04/build/CMakeFiles/CMakeError.log".

@cen1
Copy link
Collaborator Author

cen1 commented Aug 31, 2014

I'll take a look tomorrow.

@cen1
Copy link
Collaborator Author

cen1 commented Sep 1, 2014

It is because build_pvpgn.bat invokes a cmake flag -D CMAKE_INSTALL_PREFIX="" which means that SBINDIR on Windows becomes empty string (because we moved it out of sbin) and cmake fails because install DESTINATION becomes empty. Removing the flag solves the problem and I did not notice any breakage.

HarpyWar added a commit to pvpgn/pvpgn-magic-builder that referenced this pull request Sep 1, 2014
@HarpyWar HarpyWar merged commit a245200 into pvpgn:master Sep 1, 2014
@HarpyWar
Copy link
Member

HarpyWar commented Sep 1, 2014

Good job!

@HarpyWar HarpyWar added this to the PvPGN 2.0 milestone Sep 1, 2014
@HarpyWar
Copy link
Member

HarpyWar commented Sep 3, 2014

Please, look into the new issue that appears only on Linux and caused by you commits.
Log without errors, but the process closes after successful start.

Sep 03 07:52:31 [info ] _setup_listensock: listening for bnet connections on 0.0.0.0:6112 TCP
Sep 03 07:52:31 [info ] _setup_listensock: listening for w3route connections on 0.0.0.0:6200 TCP
Sep 03 07:52:31 [debug] attrlayer_flush: flushed 1 user accounts

I've checked with my revision before yours and it works.
git checkout8d3f36e
But after your 3 commits this wierd problem occurs:
git checkout92ee335

@cen1
Copy link
Collaborator Author

cen1 commented Sep 3, 2014

Works fine for me. ps aux shows bnetd daemon running. tail -f /usr/local/var/pvpgn/bnetd.log shows log to continue to build up if I try to connect to the server. So.. process works normally, it just goes to background as all daemons do, not closes.

How to reproduce?

@HarpyWar
Copy link
Member

HarpyWar commented Sep 3, 2014

I tried on local VMs (debian 3.2.54-2, ubuntu 12.04) and VPS from @Grief-Code (ubuntu 14.04).
To reproduce you can use the latest version with standart compilation steps:

git clone https://github.com/HarpyWar/pvpgn.git
mkdir build
cd build
cmake -D WITH_MYSQL=true -D WITH_LUA=true ../
make && make install

And basic test for opened port which fails (logs are in my prev post), bnetd process is also not running after:

bnetd
telnet 127.0.0.1 6112

@cen1
Copy link
Collaborator Author

cen1 commented Sep 3, 2014

Can you try a build without MYSQL and LUA? If that works it might be dependency issue.

@HarpyWar
Copy link
Member

HarpyWar commented Sep 3, 2014

Just tested without mysql and lua, but the same issue.

It stops working after the commit 12b9374 where path to program is /usr/local/sbin/bnetd.
Previous revision works fine from /usr/local/pvpgn/sbin/bnetd

@cen1
Copy link
Collaborator Author

cen1 commented Sep 3, 2014

Hmm.. could I get access to one of the VMs? I can't reproduce this so I am completely helpless at the moment.

@HarpyWar
Copy link
Member

HarpyWar commented Sep 4, 2014

@cen1 please, share your email or write on my email.

@cen1
Copy link
Collaborator Author

cen1 commented Sep 4, 2014

imbacen@gmail.com

@HarpyWar
Copy link
Member

HarpyWar commented Sep 4, 2014

I send you email, did you receive it?

@cen1
Copy link
Collaborator Author

cen1 commented Sep 4, 2014

Yes. It works fine. I left it open for you to check out. You can ctrl+c out of tail and backtrack my commands.

@HarpyWar
Copy link
Member

HarpyWar commented Sep 4, 2014

Well, it seems I did mistake somewhere - it really works (without Lua).
I have determine that bnetd crashes when it compiled with -D WITH_LUA=true. Even without scripts in lua directory.
But why it works with previous path and doesn't work with a new?

@cen1
Copy link
Collaborator Author

cen1 commented Sep 4, 2014

No idea. I will build with LUA on my vps and see what happens.

@cen1
Copy link
Collaborator Author

cen1 commented Sep 5, 2014

FindLua.cmake fails on debian. I did apt-get install lua5.1 to no avail. What exactly do I need to provide? Header files? The executable? Liblua?

@HarpyWar
Copy link
Member

HarpyWar commented Sep 5, 2014

You can install needed libraries using apt-get install liblua5.1-0-dev

@cen1
Copy link
Collaborator Author

cen1 commented Sep 6, 2014

I don't yet know what is causing the termination but it has to be inside some LUA handler in the main loop that starts after the bnetd init. If there was an error inside a LUA script, would it be displayed in console or written to some log file and where? I was checking for an obvious problem like hardcoded system path but no such thing exists. bnetd.conf also has correct LUA scriptdir and scripts are loaded well as the log states.

I will add a shitton debug info tomorrow to pinpoint the fail.

@HarpyWar
Copy link
Member

HarpyWar commented Sep 7, 2014

Yes, if error occured in Lua script then error message should be logged into bnetd.log. There may be several options when bad data is passed into "api" functions from a script and PvPGN crashes without error, because it appears outside Lua wrappers (in PvPGN code). I will look around this issue in the coming future.

But as I said program terminates even without directory lua with scripts (you can remove it). So, the issue is not in scripts.

Lua support is implemented using http://luasp.org

@cen1
Copy link
Collaborator Author

cen1 commented Sep 8, 2014

Process hangs at output_write_to_file(); server.cpp line 1340. Investigating the reason now.

@cen1
Copy link
Collaborator Author

cen1 commented Sep 8, 2014

Going in deeper, output.cpp, gamelist_traverse(_glist_cb_simple, fp); line 182

This line seems to be the culprit:
if (cbdata->identifier && strcmp(cbdata->identifier, "gamelist_join") == 0) and it is indeed wrapped in LUA. Please check this out yourself since I don't actually know what is this supposed to do in the first place. :)

@HarpyWar
Copy link
Member

HarpyWar commented Sep 9, 2014

I've added "identifier" into glist_cbdata struct to identify event when a player clicks "join game" to handle game list in Lua (because gamelist_traverse called from many places). 5d05d6c

  src\bnetd\game.h(266):            const char * identifier;
  src\bnetd\handle_bnet.cpp(3771):  cbdata.identifier = "gamelist_join"; // just an unique string that allow to identify the structure in gamelist_traverse()
  src\bnetd\game.cpp(2200):         if (cbdata->identifier && strcmp(cbdata->identifier, "gamelist_join") == 0)

I don't know what's wrong with that and how it relates to the installation paths.

@cen1
Copy link
Collaborator Author

cen1 commented Sep 9, 2014

The only reason this would kill the process is some kind of segmentation fault, meaning that pointer to identifier does not actually exist. I see you simply cast void * data to glist_cbdata so perhaps the data is initialized the old way without the new identifier somewhere. I will try to traverse upwards and see if anything like this is happening.

@cen1
Copy link
Collaborator Author

cen1 commented Sep 9, 2014

The second parameter is a file pointer and it is statically cast to a struct. How does that even work?

@HarpyWar
Copy link
Member

Well, I see that second parameter for gamelist_traverse is a file pointer in the function output_standard_writer. I don't know how it worked earlier too :)
Thanks for the research. Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants