Author Topic: How to set up a packaging environment in VMware  (Read 6301 times)

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
How to set up a packaging environment in VMware
« on: March 07, 2009, 11:13:32 AM »
.
"How to set up a packaging environment in VMware"


Stumpy has a good set of instructions for creating a packaging environment in VMware over at mypclinuxos that I would like to condense and clarify here.  As this gets refined it may also make a good general VMware how-to for our wiki.  But before I get into it I would like to answer one likely FAQ first:

Why VMware and not VirtualBox?   ..because VMware will support ping, traceroute, etc and apparently VB does not (w. default NAT setup..  if this changes let me know!).  This small little detail can become important when dealing with network related software!  This VMware setup also easily handles screen resize, as well as drag & drop, copy & paste, and shared folders between guest & host.  


Now onto the How-To:

(WORK IN PROGRESS.. but still functional)

Go to this link and download VMware Workstation and Player for Linux. You will need to register to get through to the actual download link. If you are already registered, enter your login info, else fill out the form and register. Ignore the warnings about needing a serial number, we're not actually installing workstation so it's not needed. Once you're logged in continue to the license agreement. Scroll to the bottom of the page and click the "Yes" button to agree to the license, a new page will open. Click the download link,  and then select the 32-bit .bundle file:

Before leaving the download page make a copy of the md5sum shown by the download link. We will use it to verify the download integrity. When the download is complete, open a terminal (konsole) in the folder where you saved the workstation download. Type the following (adjust for your version):

Code: [Select]
md5sum VMware-Workstation-6.5.1-126130.i386.bundle
When the command completes, verify that the sum printed matches the one from the download page.  You can do the same for VMware Player. 

As you have probably noticed, new versions of VMware now come packaged as .bundle files.  We need to unpack only the Workstation bundle as follows (..from containing directory in console; command should be one line):

Code: [Select]
sh VMware-Workstation-6.5.1-126130.i386.bundle --extract=/share/virtualization/VMware_Setup/VMware6-5-1
Change the extract directory to a location of your choosing; the final folder in the path must not exist (it will be created)!  The linux iso  we need from this package can then be found in the subdirectory ../vmware-workstation/lib/isoimages.  If you created a VMware_setup (or similar)directory as I did, copy the linux.iso file there now (or elsewhere), and you may delete the rest of the unpacked VMware workstation files; we will only be using the linux.iso file from this package.



The next step is to grab a copy of the OS iso that you will be using to package from (..I used a remastered, fully updated to 2009 mini-me iso ) and make a note of its full path.

Now browse to the directory containing your downloaded copy of the VMware Player.  Open a console in that directory  (press F4) and install using the following command (adjust version if needed);

Code: [Select]
sh VMware-Player-2.5.1-126130.i386.bundle
Accept all the default settings; when the installation is complete we will be ready for the next step.




OK now we'll create a virtual machine file using easyvmx. Go to http://www.easyvmx.com/new-easyvmx.shtml in your browser. Note that there are only four mandatory fields (marked in green) but we'll use a couple others as well.

  • Under Virtual Hardware >> Virtual Machine Name enter the name for your vm, for example PackageVM. This name serves to identify this instance of the virtual machine, and when it's downloaded the archive will have all its files contained inside a folder with this name. For Select GuestOS select Generic Linux 2.6.x. For memory size make your selection as high as possible but not more than half of your total system memory. # of CPUs should be left at 1 CPU unless you have a dual core (or higher) setup.

  • Power ON / Power OFF settings can be left at the defaults.
  • Virtual Machine Description isn't really used and can be left blank, these fields are just for informational purposes so put whatever you want here.
  • Under Network Interface Cards leave both lines as-is.
  • Floppy Disk Drive can be left as-is unless you have a FDD in your system and even then you probably won't need it, so it can be disabled.
  • Under CDROM Drives leave the first line for CDROM #1 as-is. For the second line check the box to enable the CDROM #2. Enter the full path to the location of your copy of the OS iso file as noted previously. This line is particularly important because if it's not correct the vm won't be able to mount the cd image and will fail to boot to the minime livecd.

  • Under Hard Disk Drives the default for Disk #1 is OK unless you're planning on loading very large projects in your vm. Disk #2 can be left disabled also. Do however check the box to enable Shared Folder and in the combobox select Folder Name: "~/easyvmxfolder" (you can change this path later).

  • The remaining settings for Sound and I/O-Ports can be left at the defaults unless your system is not equipped with one or more of these. For example on my laptop I uncheck Parallel Port because there is none on it.
Finally click the Create Virtual Machine button. On the page which opens click the button to download your vm, and save it to your hard drive. Open the file with Ark and extract the contents to a convenient location on your hard drive, or unpack it from console using the unzip command. Note that this folder will contain the entire vm and can grow to be several gigs or more. If you have a separate data partition on your system with more storage space, that would be a good choice of location to extract the vm to.

Browse to your VM's directory and select the file with the .vmx extension (it's the configuration file for the vm) and open it with KWrite. We need to make just a couple of changes to the file which are not possible to configure when it is created on the easyvmx website. Scroll down and locate the section for the ethernet card:

Code: [Select]
# First network interface card
ethernet0.present = "TRUE"
ethernet0.virtualDev = "e1000"
ethernet0.connectionType = "nat"
ethernet0.addressType = "generated"
ethernet0.generatedAddressOffset = "0"

We will change it to use a fixed MAC address because using a generated address can be problematic (sometimes the network adapter isn't found when booting the vm and has to be reconfigured, a fixed address avoids this situation).

Code: [Select]
# First network interface card
ethernet0.present = "TRUE"
ethernet0.virtualDev = "e1000"
ethernet0.connectionType = "nat"
ethernet0.addressType = "static"
ethernet0.address = "00:50:56:34:69:98"


Now locate the section # EasyVMX! Shared Folder and change the line for the hostPath:
Code: [Select]
sharedFolder0.hostPath = "~/easyvmxfolder"
Change to:
Code: [Select]
sharedFolder0.hostPath = "/home/username/easyvmxfolder"
NOTE: You can use whatever folder you like, the main point is to get rid of the ~ and put the full pathname in its place, otherwise the vm may have problems locating the shared folder. So if you used /home/username/easyvmxfolder then you need to create the easyvmxfolder directory in your home folder. Note that this folder does not need to be specially configured for sharing (e.g. Samba share), it will only be shared between the host and guest OS and is handled automatically by VMware, once we have the VMware Tools installed.

It is also probably a good idea to verify that the OS iso file is set to load at boot; you should see  a line like this under the "Settings for the optional virtual CDROM, ISO-image" section (..if it is not set to TRUE; then fix it now):
Code: [Select]
ide1:1.startConnected = "TRUE"

Now save the file and close KWrite. At this point we are ready to start the vm. Right-click the .vmx file and select Open With, then enter vmplayer in the textbox at the top of the dialog and click the OK button. If all goes well you should be greated with the MiniMe startup screen running in the vm. Start the LiveCD and log in as root.

Launch the Install PCLinuxOS icon and follow the prompts to install the OS. Remember that now we're looking at the virtual hard drive so the default settings using the entire drive and installing Grub to the MBR is fine. When the installer finishes restart the (virtual) computer, there is no CD to eject so just press Enter and the system should boot back into the (virtual) hard drive. Note that VMware automatically changes the state of the CDROM .iso image to be disconnected so there is no need to modify the settings in the configuration file (this is a nice feature, otherwise it would continue booting to the CD image instead, until the config file is changed). At this point you can create your user and log in to MiniMe, and configure it the way you like.

To release the cursor back to the host, press the Ctrl & Alt keys simultaneously

I recommend starting Synaptic and doing a Reload and Mark All, Apply to get the newest files from stable installed. Make any other tweaks you see fit. When you are satisfied with the virtual system, shut it down. Then copy the entire vm folder and save it under a new name so in case something goes wrong later you will have this copy as a fallback base setup.

Note that as of now the vm has some limitations like screen resolution and the shared folder won't work yet. Next we will modify the vm configuration file to point to the VMware Tools (linux.iso that we extracted from the workstation download) and completing the configuration for these features.




To install the vmware tools do the following:

First, make sure you have the vm shut down. Now open the folder containing your vm files and open the .vmx file in KWrite. Locate the section for the virtual CDROM (2), and change the fileName entry to the full path for the linux.iso:

Code: [Select]
# Settings for the optional virtual CDROM, ISO-image
ide1:1.present = "TRUE"
ide1:1.fileName = "/full/path-to/linux.iso"
ide1:1.deviceType = "cdrom-image"
ide1:1.mode = "persistent"
ide1:1.startConnected = "TRUE"

Note above that the startConnected entry must be set to TRUE, else the files won't show up in the vm. Save the file and exit KWrite.

<<WORK STILL IN PROGRESS..  watch package names & version numbers!!>>

Now start the vm and log in as your normal user. Launch the My Computer icon from the Desktop and navigate to Storage Media, then the CDROM (VMware Tools), you should see two files listed. We will extract the tar.gz file.

Open a konsole in the home directory, then extract the files from the tarball:
Code: [Select]
cd ~
tar zxvf /media/VMware\ Tools/VMwareTools-6.0.4-93057.tar.gz

Now cd to the new vmware-tools-distrib folder, su to root and run the installer:
Code: [Select]
cd vmware-tools-distrib
su
<Enter root password>
./vmware-install.pl

Accept the defaults for each prompt and when the installer is finished you may may enable the Shared Folders by selecting Player > Shared Folders from the VMware Player menu bar at the top of the screen. Then check the radio button Always enabled, verify the path to your shared folder on your host under the Folders section and click the Save button. Note that the shared folder appears under /mnt/hgfs so you will probably want to create a link to it in your home folder (or on your Desktop) for easier navigation.

The other tools features are automatically enabled, the screen resolution should go to fullscreen if you maximize the vm window. You can also now copy/paste and drag/drop to/from the vm and the host system.

Note that if you decide to do a kernel update in the vm system you will need to rerun the command vmware-config-tools.pl to configure the vmware tools for the new kernel once you reboot into it.


You can now set up your packaging environment in the VM using gettinther's tutorial, or for a more automated approach, use Stumpy's pkgutils from the PCLOS repository:

Quote from: Stumpy842
Open Synaptic and select your repo if you want to change it from whatever it is currently set to now, just have main extra nonfree kde (and possibly gnome if you are using 2009+), but NOT testing. Hit Reload to refresh the package list, then hit Mark All Upgrades. Before you hit Apply, do a search for and select the package named pkgutils for install also. Now hit Apply.

When everything is done installing close Synaptic. Now open a terminal and type...<removed, see below> This script will

    * modify your sources.list to include testing (..not in v0.1.2-1)
    * download and install all required apps for rpm building
    * set up a src folder and subfolders under your home folder as needed for rpm building
    * create the .rpmmacros and .rpmrc files in your home folder needed for rpm building


For more info on the options to mkrepo type "mkrepo -u" before running the command the first time... you can change things like where the src folder gets created as well as the distribution suffix and release etc...

BTW I'm a lazy man, that's why I created pkgutils, which contains mkrepo  :mrgreen:


To package for BEL, use the following command instead of the one quoted above:
Code: [Select]
mkrepo -a -d PCLinuxOS -v PCLinuxOS -s <your PCLOS user name> -p <your PCLOS user name>

NOTE: The mkrepo script adds TESTING to your active repo; updating (mark all upgrades in synaptic, or using apt-get) with TESTING enabled can sometimes cause problems; I recommend you disable testing in synaptic now, before you forget that it is enabled!
« Last Edit: March 15, 2009, 11:53:56 PM by travisn000 »

Offline Joble

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6804
  • USA - Mountain Time
Re: How to set up a packaging environment in VMware
« Reply #1 on: April 04, 2009, 11:23:08 AM »
Hey Travis:

I get here:
Quote
Note above that the startConnected entry must be set to TRUE, else the files won't show up in the vm. Save the file and exit KWrite.

<<WORK STILL IN PROGRESS..  watch package names & version numbers!!>>

Now start the vm and log in as your normal user.
And it fails to boot.  Got an alert about a new version of playa to I'm going to try again with that.

Never mind.  Thanks for the new Kernels Tex!  27.21 fixed my VMware problem!

Spoke to soon.  Is seems when I close down my vmware session, I can't restart it. hmm.
« Last Edit: April 05, 2009, 10:06:26 AM by Joble »
Search First.
Forum Rules
Hero means I talk a lot, nothing more, nothing less!
Have an Awesome Day!
Healthy System

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
Re: How to set up a packaging environment in VMware
« Reply #2 on: April 05, 2009, 08:03:18 PM »
I don't know that I can offer too much help based on that description, but as you discovered..   ..I've noticed that I almost always loose sound after running any sort of driver / kernel update in a VM, and I have to run alsaconf.. maybe your issue is something similar?  Is PCLOS failing to boot, or is VMware giving errors before the VM tries to boot?  Details..

Offline Joble

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6804
  • USA - Mountain Time
Re: How to set up a packaging environment in VMware
« Reply #3 on: April 07, 2009, 08:12:49 PM »
Got It!

It's a service, and it wasn't started.  Did I miss that somewhere in the instructions?  PCC->System->Services
started the vmware service and I'm in!

Thanks to my good buddy, and Ubuntu Guru Bodhi_zazen for pointing me in the right direction!  Boy am I glad I attended that LUG meeting tonight!

Now, maybe I can get something accomplished.
Search First.
Forum Rules
Hero means I talk a lot, nothing more, nothing less!
Have an Awesome Day!
Healthy System

Offline glamdring

  • Hero Member
  • *****
  • Posts: 552
Re: How to set up a packaging environment in VMware
« Reply #4 on: November 03, 2011, 12:18:42 PM »
The new location of linux.iso in version 8 is /vmware-tools-linux/linux.iso

I was a bit confused until I used the search in dolphin, figured I would post in case another new person like me comes along confused.