About Features Downloads Getting Started Documentation Events Support GitHub

Love VuFind®? Consider becoming a financial supporter. Your support helps build a better VuFind®!

Site Tools


Warning: This page has not been updated in over over a year and may be outdated or deprecated.
videos:upgrading_vufind_using_git

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
videos:upgrading_vufind_using_git [2023/04/25 20:09] – [Transcript] crhallbergvideos:upgrading_vufind_using_git [2023/04/26 13:30] (current) – [Transcript] crhallberg
Line 14: Line 14:
 ===== Transcript ===== ===== Transcript =====
  
-With the recent release of VuFind™ 7.0, I thought now would be a good time to share my upgrade workflow to show how I use Git to upgrade VuFind. This video is going to assume that you have a basic familiarity with Git, and if you do not, I strongly, strongly recommend learning at least the basics. Doing software development and deployment without version control is like driving without a seatbelt, and you will find that investing a little time in learning these tools will save you all kinds of trouble down the road.+With the recent release of VuFind 7.0, I thought now would be a good time to share my upgrade workflow to show how I use Git to upgrade VuFind. This video is going to assume that you have a basic familiarity with Git, and if you do not, I strongly, strongly recommend learning at least the basics. Doing software development and deployment without version control is like driving without a seatbelt, and you will find that investing a little time in learning these tools will save you all kinds of trouble down the road.
  
-So this video will cover two basic topics. The first will be turning an existing installation of VuFind™ into a Git repository so that you can use Git to manage it, and the second part will show some processes and tools for using Git to perform actual upgrades.+So this video will cover two basic topics. The first will be turning an existing installation of VuFind into a Git repository so that you can use Git to manage it, and the second part will show some processes and tools for using Git to perform actual upgrades.
  
-So the virtual machine I've been using for this series of tutorials was initially set up by installing VuFind™ from the Debian package, which just puts the files on disk but does not include any kind of version control. We are going to take advantage of a useful characteristic of Git, namely that all of the version control data is stored in a dot Git subdirectory, which can be easily moved around, and we're going to use that to turn our existing installation into a Git repository. We will check out a temporary clone of the repo, move the dot Git directory into our VuFind™ home, and then we'll be able to work from there.+So the virtual machine I've been using for this series of tutorials was initially set up by installing VuFind from the Debian package, which just puts the files on disk but does not include any kind of version control. We are going to take advantage of a useful characteristic of Git, namely that all of the version control data is stored in a dot Git subdirectory, which can be easily moved around, and we're going to use that to turn our existing installation into a Git repository. We will check out a temporary clone of the repo, move the dot Git directory into our VuFind home, and then we'll be able to work from there.
  
-But before we can begin doing all of that, the most important thing we need to do first is figure out exactly which version of VuFind™ we are already running, because that will enable us to put Git into the correct state to start all of the work that we need to do. There are a couple of ways to identify which version of VuFind™ you're running. A simple one, particularly useful if you don't have access to the server running VuFind, is to simply view the page source while looking at any VuFind™ webpage, and look for the generator meta tag, which should have a version number embedded in it, so we can see here 6.1.1. However, the generator meta tag is not 100% reliable, because it's actually created based on a config.ini setting, and if that configuration file gets out of date or is customized, it's possible that what it's reporting is not actually the truth. If you want to be more confident that you have the right number, you should go to the command line, switch to your VuFind™ home directory, and edit the build.xml file. This is the control file used by the Thing Automation tool to do various VuFind™ related build tasks. Most users don't have to worry about it on a day-to-day basis, but it does have the useful characteristic of having a version number embedded in it. So if you scroll down until you find the property named version, you can see that once again this confirms we are working with you find 6.1.1.+But before we can begin doing all of that, the most important thing we need to do first is figure out exactly which version of VuFind we are already running, because that will enable us to put Git into the correct state to start all of the work that we need to do. There are a couple of ways to identify which version of VuFind you're running. A simple one, particularly useful if you don't have access to the server running VuFind, is to simply view the page source while looking at any VuFind webpage, and look for the generator meta tag, which should have a version number embedded in it, so we can see here 6.1.1. However, the generator meta tag is not 100% reliable, because it's actually created based on a config.ini setting, and if that configuration file gets out of date or is customized, it's possible that what it's reporting is not actually the truth. If you want to be more confident that you have the right number, you should go to the command line, switch to your VuFind home directory, and edit the build.xml file. This is the control file used by the phing automation tool to do various VuFind related build tasks. Most users don't have to worry about it on a day-to-day basis, but it does have the useful characteristic of having a version number embedded in it. So if you scroll down until you find the property named version, you can see that once again this confirms we are working with you find 6.1.1.
  
-Now that we know what version we're running, as I said, we can start creating a Git repository to turn this bare file collection into a tracked version controlled repository. And before I begin, I'm just going to confirm if I run a Git status from my VuFind™ home, it tells me it's not a Git repository. So let's go get one.+Now that we know what version we're running, as I said, we can start creating a Git repository to turn this bare file collection into a tracked version controlled repository. And before I begin, I'm just going to confirm if I run a Git status from my VuFind home, it tells me it's not a Git repository. So let's go get one.
  
 If we go to the temp directory, we can run git clone https github.com/vufind-org/vufind.git, and that will get us a copy of the full repository and all of the history of VuFind development. And while this takes time to download, I wanted to talk a little bit about how we use Git to track various versions of VuFind. First of all, mainline bleeding edge development takes place in a branch called dev. So if you want the latest code, the most up-to-date, the most current you would want to check out dev. But of course, bleeding edge code comes with risks because there may be some recently introduced bugs. And while we try to never break the dev branch, less tested code is always more risky. If you want more stable code, we have a series of release branches. So for every major or minor release, we create a branch named release dash and a number. So for example, release-7.0 or release-6.1. And these branches are where we do bug fixing on existing releases. So we'll never add a new feature to a release branch, but we will add fixes as needed. And it's these release branches that we use to issue bug fix releases that only include fixes even after development in the main dev branch has moved on to further new exciting territory. A final tool that you may find useful is that we also tag every release. So if you want the exact point in time for a particular VuFind release, you can check out a tag which is just going to be V and a number. So for example, V7.0 or V6.1.1. So if you want to get to a very precise state in the code, you can use a tag. And that will be useful, for example, in this situation where we're trying to sync up with a particular known version. But if you're trying to get the latest stable code on a particular thread of development, use a release branch instead. All that being said, the Git repo is now cloned. We need to switch into the directory that the Git clone operation created, CD vufind. And then we need to check out the appropriate version tag, in this case, the 6.1.1. Now Git is going to complain that it's in a detached head state because we've selected a tag rather than a branch. We will clean up that mess in a moment. But first, since we now have Git at the same point in time as the release of VuFind we're working with, we should be able to move that didn't get directory into the VuFind home directory to turn it into a Git repo. So now I'm going to switch to VuFind home. And now if I do a Git status, instead of telling me this is not a repository, it's going to re-index itself and then tell me we're at a detached head at version 6.1.1. And there are a whole bunch of untracked files. This is exactly what we want. We're not seeing any diffs, which means that we picked the right version and we haven't accidentally edited any core files. But it is seeing all of the local files that we added in our local directory and our custom theme. So what we want to do now is to establish a branch for our local code so that we can begin to track the things that we change and customize over time. If we go to the temp directory, we can run git clone https github.com/vufind-org/vufind.git, and that will get us a copy of the full repository and all of the history of VuFind development. And while this takes time to download, I wanted to talk a little bit about how we use Git to track various versions of VuFind. First of all, mainline bleeding edge development takes place in a branch called dev. So if you want the latest code, the most up-to-date, the most current you would want to check out dev. But of course, bleeding edge code comes with risks because there may be some recently introduced bugs. And while we try to never break the dev branch, less tested code is always more risky. If you want more stable code, we have a series of release branches. So for every major or minor release, we create a branch named release dash and a number. So for example, release-7.0 or release-6.1. And these branches are where we do bug fixing on existing releases. So we'll never add a new feature to a release branch, but we will add fixes as needed. And it's these release branches that we use to issue bug fix releases that only include fixes even after development in the main dev branch has moved on to further new exciting territory. A final tool that you may find useful is that we also tag every release. So if you want the exact point in time for a particular VuFind release, you can check out a tag which is just going to be V and a number. So for example, V7.0 or V6.1.1. So if you want to get to a very precise state in the code, you can use a tag. And that will be useful, for example, in this situation where we're trying to sync up with a particular known version. But if you're trying to get the latest stable code on a particular thread of development, use a release branch instead. All that being said, the Git repo is now cloned. We need to switch into the directory that the Git clone operation created, CD vufind. And then we need to check out the appropriate version tag, in this case, the 6.1.1. Now Git is going to complain that it's in a detached head state because we've selected a tag rather than a branch. We will clean up that mess in a moment. But first, since we now have Git at the same point in time as the release of VuFind we're working with, we should be able to move that didn't get directory into the VuFind home directory to turn it into a Git repo. So now I'm going to switch to VuFind home. And now if I do a Git status, instead of telling me this is not a repository, it's going to re-index itself and then tell me we're at a detached head at version 6.1.1. And there are a whole bunch of untracked files. This is exactly what we want. We're not seeing any diffs, which means that we picked the right version and we haven't accidentally edited any core files. But it is seeing all of the local files that we added in our local directory and our custom theme. So what we want to do now is to establish a branch for our local code so that we can begin to track the things that we change and customize over time.
Line 30: Line 30:
 This is why it's important to be disciplined about separating your localizations from the core. And one of the advantages of using Git is that it helps you to do this because if you accidentally change a core file that will show up when you do a Git status and then you'll know oh I shouldn't have done that I need to move that to the appropriate place. This is why it's important to be disciplined about separating your localizations from the core. And one of the advantages of using Git is that it helps you to do this because if you accidentally change a core file that will show up when you do a Git status and then you'll know oh I shouldn't have done that I need to move that to the appropriate place.
  
-In any case once you're comfortable that you understand your local customizations in their scope the next thing I highly recommend doing is looking at the change log in the VuFind™ wiki and I will link to this from the video recording. But for every release of VuFind™ we include notes not only on new features that might be of interest but also of changes to code and configuration that could potentially cause problems during an upgrade. We are very inclusive here because we want to catch every possible issue that might be a problem. Most of these are unlikely to affect most users but that's why it's helpful to have a broad idea of what you've customized because you can then read through this list and take note of which issues are likely to be a problem and which ones you can very safely ignore.+In any case once you're comfortable that you understand your local customizations in their scope the next thing I highly recommend doing is looking at the change log in the VuFind wiki and I will link to this from the video recording. But for every release of VuFind we include notes not only on new features that might be of interest but also of changes to code and configuration that could potentially cause problems during an upgrade. We are very inclusive here because we want to catch every possible issue that might be a problem. Most of these are unlikely to affect most users but that's why it's helpful to have a broad idea of what you've customized because you can then read through this list and take note of which issues are likely to be a problem and which ones you can very safely ignore.
  
-In the case of this specific upgrade that we are about to run the one change log note that I need to be concerned about is this one. Starting with VuFind™ 7 we changed the default port that Solr runs on from 8080 to 8983. This is because 8983 is the standard port number used by Solr and using 8080 historically has caused port conflicts with other applications. It seems to make sense to standardize that but now at upgrade time we need to be aware of this change so that we can deal with it appropriately. Right now our Solr is running on port 8080 and after the upgrade VuFind™ will be looking for it on port 8983. I'll show you how to deal with that after the rest of the process and of course this particular issue only applies to VuFind™ 7 but this is just an example of the kind of thing you should be aware of when you're reviewing the change log.+In the case of this specific upgrade that we are about to run the one change log note that I need to be concerned about is this one. Starting with VuFind 7 we changed the default port that Solr runs on from 8080 to 8983. This is because 8983 is the standard port number used by Solr and using 8080 historically has caused port conflicts with other applications. It seems to make sense to standardize that but now at upgrade time we need to be aware of this change so that we can deal with it appropriately. Right now our Solr is running on port 8080 and after the upgrade VuFind will be looking for it on port 8983. I'll show you how to deal with that after the rest of the process and of course this particular issue only applies to VuFind 7 but this is just an example of the kind of thing you should be aware of when you're reviewing the change log.
  
 Finally the third thing that you should always do before attempting an upgrade is back everything up and of course it's best to test an upgrade on a non-production server before you dive in in the real world. In this instance I'm not going to show you how I backed things up because this is a virtual machine and I've just backed up the whole disk image before I started so I can roll back if I have to but whatever your situation just be sure that you have a rollback plan so if something goes wrong during upgrade you haven't broken your system and gotten into an unrecoverable position. Finally the third thing that you should always do before attempting an upgrade is back everything up and of course it's best to test an upgrade on a non-production server before you dive in in the real world. In this instance I'm not going to show you how I backed things up because this is a virtual machine and I've just backed up the whole disk image before I started so I can roll back if I have to but whatever your situation just be sure that you have a rollback plan so if something goes wrong during upgrade you haven't broken your system and gotten into an unrecoverable position.
  
-With all that background out of the way we're just about ready to begin. There's only one other thing to watch out for and this is that when we use Git to do updates the user running the git command needs to have permission to write to all of the folders and files in your VuFind™ home because it's going to be updating core files. So it's a good idea to check and make sure that you're using an appropriate user. So in this instance if I look at the file ownership of my VuFind™ directory I see that most of these are owned by me, dkatz, except for some reason this batch file is owned by root and the Solr directory is owned by Solr.+With all that background out of the way we're just about ready to begin. There's only one other thing to watch out for and this is that when we use Git to do updates the user running the git command needs to have permission to write to all of the folders and files in your VuFind home because it's going to be updating core files. So it's a good idea to check and make sure that you're using an appropriate user. So in this instance if I look at the file ownership of my VuFind directory I see that most of these are owned by me, dkatz, except for some reason this batch file is owned by root and the Solr directory is owned by Solr.
  
 We changed the Solr ownership because the user running the Solr process needs to be able to write there but what we can do is work around this with a group ownership. I will leave Solr owned by Solr but I'm going to add it to the dkatz group which will give my user account permission to update files in that directory and I'm going to do that with the ''sudo chgrp -R dkatz'' Solr so that's going to recursively change the group ownership of the Solr directory and then I'm going to use ''chmod -R g+w'' to add group write permissions to that directory so now because all these files and folders have my group and they have group write permission I will be able to modify them. Again the way that you actually modify your VuFind directory permissions in a real world situation will depend very much on your strategy for deployment but if you're using Git to update things you need to make sure that Git can write to all the files. So now that that's done all I need to do is run a Git merge operation to pull in all of the changes between release 6.1.1 where we are currently and the target endpoint we want to get to. So if I wanted to upgrade to specifically the 7.0 release I could say Git merge v7.0 using the v7.0 tag and I would get exactly to the code as it was released in 7.0. However in this instance I happen to know that there were some bugs in 7.0 that have been subsequently fixed and that would cause me problems on this test box so I'm instead going to choose to merge the release 7.0 branch which is the stable code from release 7.0 with subsequent bug fixes applied. So all I need to do is say git merge origin/release 7.0. The origin part is because origin is the default remote repository name that you get when you clone something so that refers to the public VuFind repo and of course release 7.0 is the branch I want. So when I run that command I am prompted to customize the commit message if I want to but I'm happy to take the default so I'll just exit out of this text editor and now I watched a bunch of changes flyby and my core code has been upgraded to VuFind 7.0. But we're not quite done. First of all we need to make sure that all of our dependencies are up to date because some parts of VuFind loaded in with composer and updating the code with git will have changed the composer configuration but it won't have automatically triggered a composer install. So if I just say composer install following my merge that will bring all of our dependencies up to date and there are quite a few changes in play with this upgrade because this is where we switch from zend framework to its successor laminots. So almost every core dependency of VuFind changed its name here even though the functionality is the same. So we have to wait for all of that to download and update itself. The other thing we want to be sure to clean up is VuFind's cache because it's possible that there is data in the cache that is now out of date that could cause problems post upgrade. We changed the Solr ownership because the user running the Solr process needs to be able to write there but what we can do is work around this with a group ownership. I will leave Solr owned by Solr but I'm going to add it to the dkatz group which will give my user account permission to update files in that directory and I'm going to do that with the ''sudo chgrp -R dkatz'' Solr so that's going to recursively change the group ownership of the Solr directory and then I'm going to use ''chmod -R g+w'' to add group write permissions to that directory so now because all these files and folders have my group and they have group write permission I will be able to modify them. Again the way that you actually modify your VuFind directory permissions in a real world situation will depend very much on your strategy for deployment but if you're using Git to update things you need to make sure that Git can write to all the files. So now that that's done all I need to do is run a Git merge operation to pull in all of the changes between release 6.1.1 where we are currently and the target endpoint we want to get to. So if I wanted to upgrade to specifically the 7.0 release I could say Git merge v7.0 using the v7.0 tag and I would get exactly to the code as it was released in 7.0. However in this instance I happen to know that there were some bugs in 7.0 that have been subsequently fixed and that would cause me problems on this test box so I'm instead going to choose to merge the release 7.0 branch which is the stable code from release 7.0 with subsequent bug fixes applied. So all I need to do is say git merge origin/release 7.0. The origin part is because origin is the default remote repository name that you get when you clone something so that refers to the public VuFind repo and of course release 7.0 is the branch I want. So when I run that command I am prompted to customize the commit message if I want to but I'm happy to take the default so I'll just exit out of this text editor and now I watched a bunch of changes flyby and my core code has been upgraded to VuFind 7.0. But we're not quite done. First of all we need to make sure that all of our dependencies are up to date because some parts of VuFind loaded in with composer and updating the code with git will have changed the composer configuration but it won't have automatically triggered a composer install. So if I just say composer install following my merge that will bring all of our dependencies up to date and there are quite a few changes in play with this upgrade because this is where we switch from zend framework to its successor laminots. So almost every core dependency of VuFind changed its name here even though the functionality is the same. So we have to wait for all of that to download and update itself. The other thing we want to be sure to clean up is VuFind's cache because it's possible that there is data in the cache that is now out of date that could cause problems post upgrade.
Line 72: Line 72:
 Right now, I'm just going to move quickly past the rest of config.ini. And now I've reached my import settings where the only change is related to the solar port number change once again. And this is so that the mark import tool knows where to find solar. So we have two files with that port number changing. We have some new examples added to our mark local dot properties. Again, it's all just comments, so it won't hurt anything, but it brings our local version up to date in case we want to turn this on in the future. And finally, a little bit of adjustment to our local custom theme to reflect some style changes that were made to the core and which have been automatically applied correctly here thanks to the merge script. Right now, I'm just going to move quickly past the rest of config.ini. And now I've reached my import settings where the only change is related to the solar port number change once again. And this is so that the mark import tool knows where to find solar. So we have two files with that port number changing. We have some new examples added to our mark local dot properties. Again, it's all just comments, so it won't hurt anything, but it brings our local version up to date in case we want to turn this on in the future. And finally, a little bit of adjustment to our local custom theme to reflect some style changes that were made to the core and which have been automatically applied correctly here thanks to the merge script.
  
-So that's it, our VuFind™ is now fully upgraded. We just have one last thing to deal with, which is the issue I raised earlier of the change solar port number. Because right now, we haven't done anything the solar during this upgrade process, so it's still running on port 8080 where it used to live. So first, let's stop it by saying solar port equals 8080 systemctl stop VuFind. This is taking advantage of the system deconfiguration that was set up in an earlier video.+So that's it, our VuFind is now fully upgraded. We just have one last thing to deal with, which is the issue I raised earlier of the change solar port number. Because right now, we haven't done anything the solar during this upgrade process, so it's still running on port 8080 where it used to live. So first, let's stop it by saying solar port equals 8080 systemctl stop VuFind. This is taking advantage of the system deconfiguration that was set up in an earlier video.
  
-So VuFind™ has now stopped, but we are going to need to make one small adjustment to the system deconfiguration because the port number is embedded in the PID file that VuFind™ uses to keep track of running processes. So we need to tell systemd that this 8080 dot PID has changed to an 8983 PID. And because we made a change to a systemd file, we need to say pseudo systemctl demon reload to make sure that the latest version of that is already. And then we can start the VuFind™ service once again.+So VuFind has now stopped, but we are going to need to make one small adjustment to the system deconfiguration because the port number is embedded in the PID file that VuFind uses to keep track of running processes. So we need to tell systemd that this 8080 dot PID has changed to an 8983 PID. And because we made a change to a systemd file, we need to say pseudo systemctl demon reload to make sure that the latest version of that is already. And then we can start the VuFind service once again.
  
 There's just one important finishing touch, which is of course that we want to commit all of the files that were customized by the merge scripts to get so that the whole history is tracked. And we're ready to move on to our next set of changes when the time comes. So let's just do a git status to look again at what has changed. Not too much. So we can say git add local config local import dm/tutorial. Do one more git status to be sure all the right files were selected. They were, so that we can get commit with a message like merge 7.0 changes to local files and we're all set. There's just one important finishing touch, which is of course that we want to commit all of the files that were customized by the merge scripts to get so that the whole history is tracked. And we're ready to move on to our next set of changes when the time comes. So let's just do a git status to look again at what has changed. Not too much. So we can say git add local config local import dm/tutorial. Do one more git status to be sure all the right files were selected. They were, so that we can get commit with a message like merge 7.0 changes to local files and we're all set.
  
-And now, if all has gone smoothly, I should be able to refresh my VuFind™ homepage. And if I view the source of it, I see that my generator now says 7.0 instead of 6.1.1. That's a good sign. And let's perform a search and confirm that yes, the whole thing still works. We are now upgraded to VuFind™ 7.0.+And now, if all has gone smoothly, I should be able to refresh my VuFind homepage. And if I view the source of it, I see that my generator now says 7.0 instead of 6.1.1. That's a good sign. And let's perform a search and confirm that yes, the whole thing still works. We are now upgraded to VuFind 7.0.
  
-So just to summarize, upgrading VuFind™ with git. It's not an easy process. It requires an understanding of your local system and configuration. It requires some problem solving and resolving conflicts. It's always good to have backups before you attempt to tackle it. But as you become familiar with the tools of git and the supplemental merge script, it does automate the vast majority of the work for you and draws your attention to key areas that might require additional work. So I hope this demonstration has been of some help and will help you form useful habits to keep up to date on VuFind™ in the future. And as always, if you have problems or questions, please reach out to me directly or to the VuFind™ mailing lists, and I'll be happy to help. Thank you for your time.+So just to summarize, upgrading VuFind with git. It's not an easy process. It requires an understanding of your local system and configuration. It requires some problem solving and resolving conflicts. It's always good to have backups before you attempt to tackle it. But as you become familiar with the tools of git and the supplemental merge script, it does automate the vast majority of the work for you and draws your attention to key areas that might require additional work. So I hope this demonstration has been of some help and will help you form useful habits to keep up to date on VuFind in the future. And as always, if you have problems or questions, please reach out to me directly or to the VuFind mailing lists, and I'll be happy to help. Thank you for your time.
  
 //This is an edited version of an automated transcript. Apologies for any errors.// //This is an edited version of an automated transcript. Apologies for any errors.//
videos/upgrading_vufind_using_git.1682453340.txt.gz · Last modified: 2023/04/25 20:09 by crhallberg