Skip to content

Commit

Permalink
SERVER-30995 Add Compass Installer to MongoDB packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
chasinglogic authored and Mathew Robinson committed Oct 16, 2017
1 parent 1265944 commit a9299df
Show file tree
Hide file tree
Showing 23 changed files with 961 additions and 648 deletions.
86 changes: 43 additions & 43 deletions buildscripts/msitrim.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
"""Script to fix up our MSI files """

import argparse;
import msilib
import shutil;

parser = argparse.ArgumentParser(description='Trim MSI.')
parser.add_argument('file', type=argparse.FileType('r'), help='file to trim')
parser.add_argument('out', type=argparse.FileType('w'), help='file to output to')

args = parser.parse_args()

def exec_delete(query):
view = db.OpenView(query)
view.Execute(None)

cur_record = view.Fetch()
view.Modify(msilib.MSIMODIFY_DELETE, cur_record)
view.Close()


def exec_update(query, column, value):
view = db.OpenView(query)
view.Execute(None)

cur_record = view.Fetch()
cur_record.SetString(column, value)
view.Modify(msilib.MSIMODIFY_REPLACE, cur_record)
view.Close()


print "Trimming MSI"

db = msilib.OpenDatabase(args.file.name, msilib.MSIDBOPEN_DIRECT)

exec_delete("select * from ControlEvent WHERE Dialog_ = 'LicenseAgreementDlg' AND Control_ = 'Next' AND Event = 'NewDialog' AND Argument = 'CustomizeDlg'")
exec_delete("select * from ControlEvent WHERE Dialog_ = 'CustomizeDlg' AND Control_ = 'Back' AND Event = 'NewDialog' AND Argument = 'LicenseAgreementDlg'")

exec_update("select * from ControlEvent WHERE Dialog_ = 'VerifyReadyDlg' AND Control_ = 'Back' AND Event = 'NewDialog' AND Argument = 'CustomizeDlg'", 5, "WixUI_InstallMode = \"InstallCustom\"")

db.Commit()

shutil.copyfile(args.file.name, args.out.name);
"""Script to fix up our MSI files """

import argparse;
import msilib
import shutil;

parser = argparse.ArgumentParser(description='Trim MSI.')
parser.add_argument('file', type=argparse.FileType('r'), help='file to trim')
parser.add_argument('out', type=argparse.FileType('w'), help='file to output to')

args = parser.parse_args()

def exec_delete(query):
view = db.OpenView(query)
view.Execute(None)

cur_record = view.Fetch()
view.Modify(msilib.MSIMODIFY_DELETE, cur_record)
view.Close()


def exec_update(query, column, value):
view = db.OpenView(query)
view.Execute(None)

cur_record = view.Fetch()
cur_record.SetString(column, value)
view.Modify(msilib.MSIMODIFY_REPLACE, cur_record)
view.Close()


print "Trimming MSI"

db = msilib.OpenDatabase(args.file.name, msilib.MSIDBOPEN_DIRECT)

exec_delete("select * from ControlEvent WHERE Dialog_ = 'LicenseAgreementDlg' AND Control_ = 'Next' AND Event = 'NewDialog' AND Argument = 'CustomizeDlg'")
exec_delete("select * from ControlEvent WHERE Dialog_ = 'CustomizeDlg' AND Control_ = 'Back' AND Event = 'NewDialog' AND Argument = 'LicenseAgreementDlg'")
exec_delete("select * from ControlEvent WHERE Dialog_ = 'CustomizeDlg' AND Control_ = 'Next' AND Event = 'NewDialog' AND Argument = 'VerifyReadyDlg'")
exec_delete("select * from ControlEvent WHERE Dialog_ = 'VerifyReadyDlg' AND Control_ = 'Back' AND Event = 'NewDialog' AND Argument = 'CustomizeDlg'")

db.Commit()

shutil.copyfile(args.file.name, args.out.name);
2 changes: 2 additions & 0 deletions debian/mongodb-enterprise-unstable.rules
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ clean:
rm -f mongorestore
rm -f mongodump
rm -f mongofiles
rm -f install_compass
rm -f .sconsign.dblite
rm -f libmongoclient.a
rm -rf client/*.o
Expand All @@ -87,6 +88,7 @@ install: build
cp -v $(CURDIR)/bin/mongo $(CURDIR)/debian/mongodb-enterprise-unstable-shell/usr/bin
cp -v $(CURDIR)/bin/mongod $(CURDIR)/debian/mongodb-enterprise-unstable-server/usr/bin
cp -v $(CURDIR)/bin/mongos $(CURDIR)/debian/mongodb-enterprise-unstable-mongos/usr/bin
cp -v $(CURDIR)/bin/install_compass $(CURDIR)/debian/mongodb-enterprise-unstable-tools/usr/bin

for binary in ${TOOLS} ; \
do \
Expand Down
2 changes: 2 additions & 0 deletions debian/mongodb-enterprise.rules
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ clean:
rm -f mongorestore
rm -f mongodump
rm -f mongofiles
rm -f install_compass
rm -f .sconsign.dblite
rm -f libmongoclient.a
rm -rf client/*.o
Expand All @@ -86,6 +87,7 @@ install: build
cp -v $(CURDIR)/bin/mongo $(CURDIR)/debian/mongodb-enterprise-shell/usr/bin
cp -v $(CURDIR)/bin/mongod $(CURDIR)/debian/mongodb-enterprise-server/usr/bin
cp -v $(CURDIR)/bin/mongos $(CURDIR)/debian/mongodb-enterprise-mongos/usr/bin
cp -v $(CURDIR)/bin/install_compass $(CURDIR)/debian/mongodb-enterprise-tools/usr/bin

for binary in ${TOOLS} ; \
do \
Expand Down
2 changes: 2 additions & 0 deletions debian/mongodb-org-unstable.rules
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ clean:
rm -f mongorestore
rm -f mongodump
rm -f mongofiles
rm -f install_compass
rm -f .sconsign.dblite
rm -f libmongoclient.a
rm -rf client/*.o
Expand All @@ -84,6 +85,7 @@ install: build
cp -v $(CURDIR)/bin/mongo $(CURDIR)/debian/mongodb-org-unstable-shell/usr/bin
cp -v $(CURDIR)/bin/mongod $(CURDIR)/debian/mongodb-org-unstable-server/usr/bin
cp -v $(CURDIR)/bin/mongos $(CURDIR)/debian/mongodb-org-unstable-mongos/usr/bin
cp -v $(CURDIR)/bin/install_compass $(CURDIR)/debian/mongodb-org-unstable-tools/usr/bin

for binary in ${TOOLS} ; \
do \
Expand Down
2 changes: 2 additions & 0 deletions debian/mongodb-org.rules
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ clean:
rm -f mongorestore
rm -f mongodump
rm -f mongofiles
rm -f install_compass
rm -f .sconsign.dblite
rm -f libmongoclient.a
rm -rf client/*.o
Expand All @@ -83,6 +84,7 @@ install: build
cp -v $(CURDIR)/bin/mongo $(CURDIR)/debian/mongodb-org-shell/usr/bin
cp -v $(CURDIR)/bin/mongod $(CURDIR)/debian/mongodb-org-server/usr/bin
cp -v $(CURDIR)/bin/mongos $(CURDIR)/debian/mongodb-org-mongos/usr/bin
cp -v $(CURDIR)/bin/install_compass $(CURDIR)/debian/mongodb-org-tools/usr/bin

for binary in ${TOOLS} ; \
do \
Expand Down
1 change: 1 addition & 0 deletions rpm/mongo.mdv.spec
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ fi
%defattr(-,root,root,-)
%doc README GNU-AGPL-3.0.txt

%{_bindir}/install_compass
%{_bindir}/mongo
%{_bindir}/mongodump
%{_bindir}/mongoexport
Expand Down
1 change: 1 addition & 0 deletions rpm/mongodb-enterprise-init.spec
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ fi
#%doc README GNU-AGPL-3.0.txt

%{_bindir}/bsondump
%{_bindir}/install_compass
%{_bindir}/mongodecrypt
%{_bindir}/mongoldap
%{_bindir}/mongodump
Expand Down
1 change: 1 addition & 0 deletions rpm/mongodb-enterprise-unstable-init.spec
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ fi
#%doc README GNU-AGPL-3.0.txt

%{_bindir}/bsondump
%{_bindir}/install_compass
%{_bindir}/mongodecrypt
%{_bindir}/mongoldap
%{_bindir}/mongodump
Expand Down
1 change: 1 addition & 0 deletions rpm/mongodb-enterprise-unstable.spec
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ fi
#%doc README GNU-AGPL-3.0.txt

%{_bindir}/bsondump
%{_bindir}/install_compass
%{_bindir}/mongodecrypt
%{_bindir}/mongoldap
%{_bindir}/mongodump
Expand Down
1 change: 1 addition & 0 deletions rpm/mongodb-enterprise.spec
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ fi
#%doc README GNU-AGPL-3.0.txt

%{_bindir}/bsondump
%{_bindir}/install_compass
%{_bindir}/mongodecrypt
%{_bindir}/mongoldap
%{_bindir}/mongodump
Expand Down
1 change: 1 addition & 0 deletions rpm/mongodb-org-init.spec
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ fi
#%doc README GNU-AGPL-3.0.txt

%{_bindir}/bsondump
%{_bindir}/install_compass
%{_bindir}/mongodump
%{_bindir}/mongoexport
%{_bindir}/mongofiles
Expand Down
1 change: 1 addition & 0 deletions rpm/mongodb-org-unstable-init.spec
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ fi
#%doc README GNU-AGPL-3.0.txt

%{_bindir}/bsondump
%{_bindir}/install_compass
%{_bindir}/mongodump
%{_bindir}/mongoexport
%{_bindir}/mongofiles
Expand Down
1 change: 1 addition & 0 deletions rpm/mongodb-org-unstable.spec
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ fi
#%doc README GNU-AGPL-3.0.txt

%{_bindir}/bsondump
%{_bindir}/install_compass
%{_bindir}/mongodump
%{_bindir}/mongoexport
%{_bindir}/mongofiles
Expand Down
1 change: 1 addition & 0 deletions rpm/mongodb-org.spec
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ fi
#%doc README GNU-AGPL-3.0.txt

%{_bindir}/bsondump
%{_bindir}/install_compass
%{_bindir}/mongodump
%{_bindir}/mongoexport
%{_bindir}/mongofiles
Expand Down
22 changes: 22 additions & 0 deletions src/mongo/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,26 @@ for full_dir, archive_dir in env["ARCHIVE_ADDITION_DIR_MAP"].items():
for target in env["DIST_BINARIES"]:
installBinary(env, "db/modules/" + target)

# Set the download url to the right place
compass_type = 'compass-community'
if 'enterprise' in env['MONGO_MODULES']:
compass_type = 'compass'

compass_script = "install_compass"
if env.TargetOSIs('windows'):
# On windows the .in needs to be explicitly added to the file.
compass_script = "Install-Compass.ps1.in"

compass_installer = env.Substfile('#/src/mongo/installer/compass/' + compass_script,
SUBST_DICT=[
('@compass_type@', compass_type)
])
distBinaries.append(compass_installer)
compass_script_installer = env.Install("$INSTALL_DIR/bin", compass_installer)

if env.TargetOSIs('posix'):
env.AddPostAction( compass_script_installer, 'chmod 755 $TARGET' )

# "dist" target is valid only when --use-new-tools is specified
# Attempts to build release artifacts without tools must fail
if has_option("use-new-tools"):
Expand All @@ -604,6 +624,7 @@ if has_option("use-new-tools"):
'--transform $BUILD_DIR/mongo=$SERVER_DIST_BASENAME/bin',
'--transform $BUILD_DIR/mongo/stripped/src/mongo-tools=$SERVER_DIST_BASENAME/bin',
'--transform src/mongo-tools=$SERVER_DIST_BASENAME/bin',
'--transform src/mongo/installer/compass=$SERVER_DIST_BASENAME/bin',
'${TEMPFILE(SOURCES[1:])}'
],
),
Expand All @@ -630,6 +651,7 @@ debug_symbols_dist = env.Command(
),
BUILD_DIR=env.Dir('$BUILD_DIR').path
)

env.Alias('dist-debugsymbols', debug_symbols_dist)

#final alias
Expand Down
43 changes: 43 additions & 0 deletions src/mongo/installer/compass/Install-Compass.ps1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#Requires -Version 3.0
<#
.SYNOPSIS
Download and install latest version of MongoDB Compass.

.DESCRIPTION
A longer description.

.INPUTS
Description of objects that can be piped to the script

.OUTPUTS
Description of objects that are output by the script

.EXAMPLE
Example of how to run the script

.LINK
Links to further documentation

.NOTES
Detail on what the script does, if this is needed
#>
param()
$ErrorActionPreference = 'Stop'

$CompassUrl = 'https://compass.mongodb.com/api/v2/download/latest/@compass_type@/stable/windows'

$TemporaryDir = [System.IO.Path]::GetTempPath()
$CompassExe = "$TemporaryDir" + "compass-install.exe"

Remove-Item $CompassExe -ErrorAction:Ignore

Write-Output "Downloading Compass from $CompassUrl"
Invoke-WebRequest -Uri $CompassUrl -OutFile $CompassExe

Write-Output "Installing Compass"
& $CompassExe

# Remove the binary we downloaded
Remove-Item $CompassExe -ErrorAction:Ignore

Write-Output "Successfully installed Compass"
Loading

0 comments on commit a9299df

Please sign in to comment.